com.sun.nio.sctp.NotificationHandler Java Examples

The following examples show how to use com.sun.nio.sctp.NotificationHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SctpChannelImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer,
                               T attachment,
                               NotificationHandler<T> handler)
        throws IOException {
    return receive(buffer, attachment, handler, false);
}
 
Example #2
Source File: SctpChannelImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer,
                               T attachment,
                               NotificationHandler<T> handler)
        throws IOException {
    return receive(buffer, attachment, handler, false);
}
 
Example #3
Source File: SctpChannelImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer,
                               T attachment,
                               NotificationHandler<T> handler)
        throws IOException {
    return receive(buffer, attachment, handler, false);
}
 
Example #4
Source File: SctpChannelImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer,
                               T attachment,
                               NotificationHandler<T> handler)
        throws IOException {
    return receive(buffer, attachment, handler, false);
}
 
Example #5
Source File: SctpChannelImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private <T> HandlerResult invokeNotificationHandler
                             (ResultContainer resultContainer,
                              NotificationHandler<T> handler,
                              T attachment) {
    SctpNotification notification = resultContainer.notification();
    synchronized (stateLock) {
        notification.setAssociation(association);
    }

    if (!(handler instanceof AbstractNotificationHandler)) {
        return handler.handleNotification(notification, attachment);
    }

    /* AbstractNotificationHandler */
    AbstractNotificationHandler<T> absHandler =
            (AbstractNotificationHandler<T>)handler;
    switch(resultContainer.type()) {
        case ASSOCIATION_CHANGED :
            return absHandler.handleNotification(
                    resultContainer.getAssociationChanged(), attachment);
        case PEER_ADDRESS_CHANGED :
            return absHandler.handleNotification(
                    resultContainer.getPeerAddressChanged(), attachment);
        case SEND_FAILED :
            return absHandler.handleNotification(
                    resultContainer.getSendFailed(), attachment);
        case SHUTDOWN :
            return absHandler.handleNotification(
                    resultContainer.getShutdown(), attachment);
        default :
            /* implementation specific handlers */
            return absHandler.handleNotification(
                    resultContainer.notification(), attachment);
    }
}
 
Example #6
Source File: SctpChannelImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer,
                               T attachment,
                               NotificationHandler<T> handler)
        throws IOException {
    return receive(buffer, attachment, handler, false);
}
 
Example #7
Source File: SctpChannelImpl.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private <T> HandlerResult invokeNotificationHandler
                             (ResultContainer resultContainer,
                              NotificationHandler<T> handler,
                              T attachment) {
    SctpNotification notification = resultContainer.notification();
    synchronized (stateLock) {
        notification.setAssociation(association);
    }

    if (!(handler instanceof AbstractNotificationHandler)) {
        return handler.handleNotification(notification, attachment);
    }

    /* AbstractNotificationHandler */
    AbstractNotificationHandler<T> absHandler =
            (AbstractNotificationHandler<T>)handler;
    switch(resultContainer.type()) {
        case ASSOCIATION_CHANGED :
            return absHandler.handleNotification(
                    resultContainer.getAssociationChanged(), attachment);
        case PEER_ADDRESS_CHANGED :
            return absHandler.handleNotification(
                    resultContainer.getPeerAddressChanged(), attachment);
        case SEND_FAILED :
            return absHandler.handleNotification(
                    resultContainer.getSendFailed(), attachment);
        case SHUTDOWN :
            return absHandler.handleNotification(
                    resultContainer.getShutdown(), attachment);
        default :
            /* implementation specific handlers */
            return absHandler.handleNotification(
                    resultContainer.notification(), attachment);
    }
}
 
Example #8
Source File: SctpChannelImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private <T> HandlerResult invokeNotificationHandler
                             (ResultContainer resultContainer,
                              NotificationHandler<T> handler,
                              T attachment) {
    SctpNotification notification = resultContainer.notification();
    synchronized (stateLock) {
        notification.setAssociation(association);
    }

    if (!(handler instanceof AbstractNotificationHandler)) {
        return handler.handleNotification(notification, attachment);
    }

    /* AbstractNotificationHandler */
    AbstractNotificationHandler<T> absHandler =
            (AbstractNotificationHandler<T>)handler;
    switch(resultContainer.type()) {
        case ASSOCIATION_CHANGED :
            return absHandler.handleNotification(
                    resultContainer.getAssociationChanged(), attachment);
        case PEER_ADDRESS_CHANGED :
            return absHandler.handleNotification(
                    resultContainer.getPeerAddressChanged(), attachment);
        case SEND_FAILED :
            return absHandler.handleNotification(
                    resultContainer.getSendFailed(), attachment);
        case SHUTDOWN :
            return absHandler.handleNotification(
                    resultContainer.getShutdown(), attachment);
        default :
            /* implementation specific handlers */
            return absHandler.handleNotification(
                    resultContainer.notification(), attachment);
    }
}
 
Example #9
Source File: SctpChannelImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private <T> HandlerResult invokeNotificationHandler
                             (ResultContainer resultContainer,
                              NotificationHandler<T> handler,
                              T attachment) {
    SctpNotification notification = resultContainer.notification();
    synchronized (stateLock) {
        notification.setAssociation(association);
    }

    if (!(handler instanceof AbstractNotificationHandler)) {
        return handler.handleNotification(notification, attachment);
    }

    /* AbstractNotificationHandler */
    AbstractNotificationHandler<T> absHandler =
            (AbstractNotificationHandler<T>)handler;
    switch(resultContainer.type()) {
        case ASSOCIATION_CHANGED :
            return absHandler.handleNotification(
                    resultContainer.getAssociationChanged(), attachment);
        case PEER_ADDRESS_CHANGED :
            return absHandler.handleNotification(
                    resultContainer.getPeerAddressChanged(), attachment);
        case SEND_FAILED :
            return absHandler.handleNotification(
                    resultContainer.getSendFailed(), attachment);
        case SHUTDOWN :
            return absHandler.handleNotification(
                    resultContainer.getShutdown(), attachment);
        default :
            /* implementation specific handlers */
            return absHandler.handleNotification(
                    resultContainer.notification(), attachment);
    }
}
 
Example #10
Source File: SctpChannelImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer,
                               T attachment,
                               NotificationHandler<T> handler)
        throws IOException {
    return receive(buffer, attachment, handler, false);
}
 
Example #11
Source File: SctpChannelImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private <T> HandlerResult invokeNotificationHandler
                             (ResultContainer resultContainer,
                              NotificationHandler<T> handler,
                              T attachment) {
    SctpNotification notification = resultContainer.notification();
    synchronized (stateLock) {
        notification.setAssociation(association);
    }

    if (!(handler instanceof AbstractNotificationHandler)) {
        return handler.handleNotification(notification, attachment);
    }

    /* AbstractNotificationHandler */
    AbstractNotificationHandler<T> absHandler =
            (AbstractNotificationHandler<T>)handler;
    switch(resultContainer.type()) {
        case ASSOCIATION_CHANGED :
            return absHandler.handleNotification(
                    resultContainer.getAssociationChanged(), attachment);
        case PEER_ADDRESS_CHANGED :
            return absHandler.handleNotification(
                    resultContainer.getPeerAddressChanged(), attachment);
        case SEND_FAILED :
            return absHandler.handleNotification(
                    resultContainer.getSendFailed(), attachment);
        case SHUTDOWN :
            return absHandler.handleNotification(
                    resultContainer.getShutdown(), attachment);
        default :
            /* implementation specific handlers */
            return absHandler.handleNotification(
                    resultContainer.notification(), attachment);
    }
}
 
Example #12
Source File: SctpChannelImpl.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer,
                               T attachment,
                               NotificationHandler<T> handler)
        throws IOException {
    return receive(buffer, attachment, handler, false);
}
 
Example #13
Source File: SctpChannelImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer,
                               T attachment,
                               NotificationHandler<T> handler)
        throws IOException {
    return receive(buffer, attachment, handler, false);
}
 
Example #14
Source File: SctpChannelImpl.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer dst, T attachment,
        NotificationHandler<T> handler) throws IOException {
    throw new UnsupportedOperationException(message);
}
 
Example #15
Source File: SctpChannelImpl.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private <T> MessageInfo receive(ByteBuffer buffer,
                                T attachment,
                                NotificationHandler<T> handler,
                                boolean fromConnect)
        throws IOException {
    if (buffer == null)
        throw new IllegalArgumentException("buffer cannot be null");

    if (buffer.isReadOnly())
        throw new IllegalArgumentException("Read-only buffer");

    if (receiveInvoked.get())
        throw new IllegalReceiveException(
                "cannot invoke receive from handler");
    receiveInvoked.set(Boolean.TRUE);

    try {
        ResultContainer resultContainer = new ResultContainer();
        do {
            resultContainer.clear();
            synchronized (receiveLock) {
                if (!ensureReceiveOpen())
                    return null;

                int n = 0;
                try {
                    begin();

                    synchronized (stateLock) {
                        if(!isOpen())
                            return null;
                        receiverThread = NativeThread.current();
                    }

                    do {
                        n = receive(fdVal, buffer, resultContainer, fromConnect);
                    } while ((n == IOStatus.INTERRUPTED) && isOpen());
                } finally {
                    receiverCleanup();
                    end((n > 0) || (n == IOStatus.UNAVAILABLE));
                    assert IOStatus.check(n);
                }

                if (!resultContainer.isNotification()) {
                    /* message or nothing */
                    if (resultContainer.hasSomething()) {
                        /* Set the association before returning */
                        MessageInfoImpl info =
                                resultContainer.getMessageInfo();
                        synchronized (stateLock) {
                            assert association != null;
                            info.setAssociation(association);
                        }
                        return info;
                    } else
                        /* Non-blocking may return null if nothing available*/
                        return null;
                } else { /* notification */
                    synchronized (stateLock) {
                        handleNotificationInternal(
                                resultContainer);
                    }
                }

                if (fromConnect)  {
                    /* If we reach here, then it was connect that invoked
                     * receive and received the COMM_UP. We have already
                     * handled the COMM_UP with the internal notification
                     * handler. Simply return. */
                    return null;
                }
            }  /* receiveLock */
        } while (handler == null ? true :
            (invokeNotificationHandler(resultContainer, handler, attachment)
             == HandlerResult.CONTINUE));

        return null;
    } finally {
        receiveInvoked.set(Boolean.FALSE);
    }
}
 
Example #16
Source File: SctpMultiChannelImpl.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private <T> HandlerResult invokeNotificationHandler(
                               ResultContainer resultContainer,
                               NotificationHandler<T> handler,
                               T attachment) {
    HandlerResult result;
    SctpNotification notification = resultContainer.notification();
    notification.setAssociation(lookupAssociation(notification.assocId()));

    if (!(handler instanceof AbstractNotificationHandler)) {
        result = handler.handleNotification(notification, attachment);
    } else { /* AbstractNotificationHandler */
        AbstractNotificationHandler<T> absHandler =
                (AbstractNotificationHandler<T>)handler;
        switch(resultContainer.type()) {
            case ASSOCIATION_CHANGED :
                result = absHandler.handleNotification(
                        resultContainer.getAssociationChanged(), attachment);
                break;
            case PEER_ADDRESS_CHANGED :
                result = absHandler.handleNotification(
                        resultContainer.getPeerAddressChanged(), attachment);
                break;
            case SEND_FAILED :
                result = absHandler.handleNotification(
                        resultContainer.getSendFailed(), attachment);
                break;
            case SHUTDOWN :
                result =  absHandler.handleNotification(
                        resultContainer.getShutdown(), attachment);
                break;
            default :
                /* implementation specific handlers */
                result =  absHandler.handleNotification(
                        resultContainer.notification(), attachment);
        }
    }

    if (!(handler instanceof InternalNotificationHandler)) {
        /* Only remove associations after user handler
         * has finished with them */
        Association assoc = associationToRemove.get();
        if (assoc != null) {
            removeAssociation(assoc);
            associationToRemove.set(null);
        }

    }

    return result;
}
 
Example #17
Source File: SctpMultiChannelImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer,
                               T attachment,
                               NotificationHandler<T> handler)
        throws IOException {
    if (buffer == null)
        throw new IllegalArgumentException("buffer cannot be null");

    if (buffer.isReadOnly())
        throw new IllegalArgumentException("Read-only buffer");

    if (receiveInvoked.get())
        throw new IllegalReceiveException(
                "cannot invoke receive from handler");
    receiveInvoked.set(Boolean.TRUE);

    try {
        ResultContainer resultContainer = new ResultContainer();
        do {
            resultContainer.clear();
            synchronized (receiveLock) {
                ensureOpen();
                if (!isBound())
                    throw new NotYetBoundException();

                int n = 0;
                try {
                    begin();

                    synchronized (stateLock) {
                        if(!isOpen())
                            return null;
                        receiverThread = NativeThread.current();
                    }

                    do {
                        n = receive(fdVal, buffer, resultContainer);
                    } while ((n == IOStatus.INTERRUPTED) && isOpen());

                } finally {
                    receiverCleanup();
                    end((n > 0) || (n == IOStatus.UNAVAILABLE));
                    assert IOStatus.check(n);
                }

                if (!resultContainer.isNotification()) {
                    /* message or nothing */
                    if (resultContainer.hasSomething()) {
                        /* Set the association before returning */
                        MessageInfoImpl info =
                                resultContainer.getMessageInfo();
                        info.setAssociation(lookupAssociation(info.
                                associationID()));
                        SecurityManager sm = System.getSecurityManager();
                        if (sm != null) {
                            InetSocketAddress isa  = (InetSocketAddress)info.address();
                            if (!addressMap.containsKey(isa)) {
                                /* must be a new association */
                                try {
                                    sm.checkAccept(isa.getAddress().getHostAddress(),
                                                   isa.getPort());
                                } catch (SecurityException se) {
                                    buffer.clear();
                                    throw se;
                                }
                            }
                        }

                        assert info.association() != null;
                        return info;
                    } else  {
                      /* Non-blocking may return null if nothing available*/
                        return null;
                    }
                } else { /* notification */
                    synchronized (stateLock) {
                        handleNotificationInternal(
                                resultContainer);
                    }
                }
            } /* receiveLock */
        } while (handler == null ? true :
            (invokeNotificationHandler(resultContainer, handler, attachment)
             == HandlerResult.CONTINUE));
    } finally {
        receiveInvoked.set(Boolean.FALSE);
    }

    return null;
}
 
Example #18
Source File: SctpMultiChannelImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer, T attachment,
        NotificationHandler<T> handler) throws IOException {
    throw new UnsupportedOperationException(message);
}
 
Example #19
Source File: SctpMultiChannelImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer, T attachment,
        NotificationHandler<T> handler) throws IOException {
    throw new UnsupportedOperationException(message);
}
 
Example #20
Source File: SctpMultiChannelImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer, T attachment,
        NotificationHandler<T> handler) throws IOException {
    throw new UnsupportedOperationException(message);
}
 
Example #21
Source File: SctpChannelImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer dst, T attachment,
        NotificationHandler<T> handler) throws IOException {
    throw new UnsupportedOperationException(message);
}
 
Example #22
Source File: SctpMultiChannelImpl.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer,
                               T attachment,
                               NotificationHandler<T> handler)
        throws IOException {
    if (buffer == null)
        throw new IllegalArgumentException("buffer cannot be null");

    if (buffer.isReadOnly())
        throw new IllegalArgumentException("Read-only buffer");

    if (receiveInvoked.get())
        throw new IllegalReceiveException(
                "cannot invoke receive from handler");
    receiveInvoked.set(Boolean.TRUE);

    try {
        ResultContainer resultContainer = new ResultContainer();
        do {
            resultContainer.clear();
            synchronized (receiveLock) {
                ensureOpen();
                if (!isBound())
                    throw new NotYetBoundException();

                int n = 0;
                try {
                    begin();

                    synchronized (stateLock) {
                        if(!isOpen())
                            return null;
                        receiverThread = NativeThread.current();
                    }

                    do {
                        n = receive(fdVal, buffer, resultContainer);
                    } while ((n == IOStatus.INTERRUPTED) && isOpen());

                } finally {
                    receiverCleanup();
                    end((n > 0) || (n == IOStatus.UNAVAILABLE));
                    assert IOStatus.check(n);
                }

                if (!resultContainer.isNotification()) {
                    /* message or nothing */
                    if (resultContainer.hasSomething()) {
                        /* Set the association before returning */
                        MessageInfoImpl info =
                                resultContainer.getMessageInfo();
                        info.setAssociation(lookupAssociation(info.
                                associationID()));
                        SecurityManager sm = System.getSecurityManager();
                        if (sm != null) {
                            InetSocketAddress isa  = (InetSocketAddress)info.address();
                            if (!addressMap.containsKey(isa)) {
                                /* must be a new association */
                                try {
                                    sm.checkAccept(isa.getAddress().getHostAddress(),
                                                   isa.getPort());
                                } catch (SecurityException se) {
                                    buffer.clear();
                                    throw se;
                                }
                            }
                        }

                        assert info.association() != null;
                        return info;
                    } else  {
                      /* Non-blocking may return null if nothing available*/
                        return null;
                    }
                } else { /* notification */
                    synchronized (stateLock) {
                        handleNotificationInternal(
                                resultContainer);
                    }
                }
            } /* receiveLock */
        } while (handler == null ? true :
            (invokeNotificationHandler(resultContainer, handler, attachment)
             == HandlerResult.CONTINUE));
    } finally {
        receiveInvoked.set(Boolean.FALSE);
    }

    return null;
}
 
Example #23
Source File: SctpChannelImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer dst, T attachment,
        NotificationHandler<T> handler) throws IOException {
    throw new UnsupportedOperationException(message);
}
 
Example #24
Source File: SctpMultiChannelImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer,
                               T attachment,
                               NotificationHandler<T> handler)
        throws IOException {
    if (buffer == null)
        throw new IllegalArgumentException("buffer cannot be null");

    if (buffer.isReadOnly())
        throw new IllegalArgumentException("Read-only buffer");

    if (receiveInvoked.get())
        throw new IllegalReceiveException(
                "cannot invoke receive from handler");
    receiveInvoked.set(Boolean.TRUE);

    try {
        ResultContainer resultContainer = new ResultContainer();
        do {
            resultContainer.clear();
            synchronized (receiveLock) {
                ensureOpen();
                if (!isBound())
                    throw new NotYetBoundException();

                int n = 0;
                try {
                    begin();

                    synchronized (stateLock) {
                        if(!isOpen())
                            return null;
                        receiverThread = NativeThread.current();
                    }

                    do {
                        n = receive(fdVal, buffer, resultContainer);
                    } while ((n == IOStatus.INTERRUPTED) && isOpen());

                } finally {
                    receiverCleanup();
                    end((n > 0) || (n == IOStatus.UNAVAILABLE));
                    assert IOStatus.check(n);
                }

                if (!resultContainer.isNotification()) {
                    /* message or nothing */
                    if (resultContainer.hasSomething()) {
                        /* Set the association before returning */
                        MessageInfoImpl info =
                                resultContainer.getMessageInfo();
                        info.setAssociation(lookupAssociation(info.
                                associationID()));
                        SecurityManager sm = System.getSecurityManager();
                        if (sm != null) {
                            InetSocketAddress isa  = (InetSocketAddress)info.address();
                            if (!addressMap.containsKey(isa)) {
                                /* must be a new association */
                                try {
                                    sm.checkAccept(isa.getAddress().getHostAddress(),
                                                   isa.getPort());
                                } catch (SecurityException se) {
                                    buffer.clear();
                                    throw se;
                                }
                            }
                        }

                        assert info.association() != null;
                        return info;
                    } else  {
                      /* Non-blocking may return null if nothing available*/
                        return null;
                    }
                } else { /* notification */
                    synchronized (stateLock) {
                        handleNotificationInternal(
                                resultContainer);
                    }
                }
            } /* receiveLock */
        } while (handler == null ? true :
            (invokeNotificationHandler(resultContainer, handler, attachment)
             == HandlerResult.CONTINUE));
    } finally {
        receiveInvoked.set(Boolean.FALSE);
    }

    return null;
}
 
Example #25
Source File: SctpChannelImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private <T> MessageInfo receive(ByteBuffer buffer,
                                T attachment,
                                NotificationHandler<T> handler,
                                boolean fromConnect)
        throws IOException {
    if (buffer == null)
        throw new IllegalArgumentException("buffer cannot be null");

    if (buffer.isReadOnly())
        throw new IllegalArgumentException("Read-only buffer");

    if (receiveInvoked.get())
        throw new IllegalReceiveException(
                "cannot invoke receive from handler");
    receiveInvoked.set(Boolean.TRUE);

    try {
        ResultContainer resultContainer = new ResultContainer();
        do {
            resultContainer.clear();
            synchronized (receiveLock) {
                if (!ensureReceiveOpen())
                    return null;

                int n = 0;
                try {
                    begin();

                    synchronized (stateLock) {
                        if(!isOpen())
                            return null;
                        receiverThread = NativeThread.current();
                    }

                    do {
                        n = receive(fdVal, buffer, resultContainer, fromConnect);
                    } while ((n == IOStatus.INTERRUPTED) && isOpen());
                } finally {
                    receiverCleanup();
                    end((n > 0) || (n == IOStatus.UNAVAILABLE));
                    assert IOStatus.check(n);
                }

                if (!resultContainer.isNotification()) {
                    /* message or nothing */
                    if (resultContainer.hasSomething()) {
                        /* Set the association before returning */
                        MessageInfoImpl info =
                                resultContainer.getMessageInfo();
                        synchronized (stateLock) {
                            assert association != null;
                            info.setAssociation(association);
                        }
                        return info;
                    } else
                        /* Non-blocking may return null if nothing available*/
                        return null;
                } else { /* notification */
                    synchronized (stateLock) {
                        handleNotificationInternal(
                                resultContainer);
                    }
                }

                if (fromConnect)  {
                    /* If we reach here, then it was connect that invoked
                     * receive and received the COMM_UP. We have already
                     * handled the COMM_UP with the internal notification
                     * handler. Simply return. */
                    return null;
                }
            }  /* receiveLock */
        } while (handler == null ? true :
            (invokeNotificationHandler(resultContainer, handler, attachment)
             == HandlerResult.CONTINUE));

        return null;
    } finally {
        receiveInvoked.set(Boolean.FALSE);
    }
}
 
Example #26
Source File: SctpChannelImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private <T> MessageInfo receive(ByteBuffer buffer,
                                T attachment,
                                NotificationHandler<T> handler,
                                boolean fromConnect)
        throws IOException {
    if (buffer == null)
        throw new IllegalArgumentException("buffer cannot be null");

    if (buffer.isReadOnly())
        throw new IllegalArgumentException("Read-only buffer");

    if (receiveInvoked.get())
        throw new IllegalReceiveException(
                "cannot invoke receive from handler");
    receiveInvoked.set(Boolean.TRUE);

    try {
        ResultContainer resultContainer = new ResultContainer();
        do {
            resultContainer.clear();
            synchronized (receiveLock) {
                if (!ensureReceiveOpen())
                    return null;

                int n = 0;
                try {
                    begin();

                    synchronized (stateLock) {
                        if(!isOpen())
                            return null;
                        receiverThread = NativeThread.current();
                    }

                    do {
                        n = receive(fdVal, buffer, resultContainer, fromConnect);
                    } while ((n == IOStatus.INTERRUPTED) && isOpen());
                } finally {
                    receiverCleanup();
                    end((n > 0) || (n == IOStatus.UNAVAILABLE));
                    assert IOStatus.check(n);
                }

                if (!resultContainer.isNotification()) {
                    /* message or nothing */
                    if (resultContainer.hasSomething()) {
                        /* Set the association before returning */
                        MessageInfoImpl info =
                                resultContainer.getMessageInfo();
                        synchronized (stateLock) {
                            assert association != null;
                            info.setAssociation(association);
                        }
                        return info;
                    } else
                        /* Non-blocking may return null if nothing available*/
                        return null;
                } else { /* notification */
                    synchronized (stateLock) {
                        handleNotificationInternal(
                                resultContainer);
                    }
                }

                if (fromConnect)  {
                    /* If we reach here, then it was connect that invoked
                     * receive and received the COMM_UP. We have already
                     * handled the COMM_UP with the internal notification
                     * handler. Simply return. */
                    return null;
                }
            }  /* receiveLock */
        } while (handler == null ? true :
            (invokeNotificationHandler(resultContainer, handler, attachment)
             == HandlerResult.CONTINUE));

        return null;
    } finally {
        receiveInvoked.set(Boolean.FALSE);
    }
}
 
Example #27
Source File: SctpChannelImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer dst, T attachment,
        NotificationHandler<T> handler) throws IOException {
    throw new UnsupportedOperationException(message);
}
 
Example #28
Source File: SctpMultiChannelImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer, T attachment,
        NotificationHandler<T> handler) throws IOException {
    throw new UnsupportedOperationException(message);
}
 
Example #29
Source File: SctpChannelImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer dst, T attachment,
        NotificationHandler<T> handler) throws IOException {
    throw new UnsupportedOperationException(message);
}
 
Example #30
Source File: SctpMultiChannelImpl.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> MessageInfo receive(ByteBuffer buffer, T attachment,
        NotificationHandler<T> handler) throws IOException {
    throw new UnsupportedOperationException(message);
}