SCTP association shutdown cleanup

This commit is contained in:
Jestan Nirojan 2012-02-20 01:39:42 +05:30
parent 0bb1fe2656
commit 6eabd343c4
2 changed files with 3 additions and 17 deletions

View File

@ -59,7 +59,7 @@ class SctpNotificationHandler extends AbstractNotificationHandler {
@Override @Override
public HandlerResult handleNotification(ShutdownNotification notification, Object o) { public HandlerResult handleNotification(ShutdownNotification notification, Object o) {
Channels.fireChannelDisconnected(sctpChannel); sctpChannel.worker.close(sctpChannel, Channels.succeededFuture(sctpChannel));
return HandlerResult.RETURN; return HandlerResult.RETURN;
} }

View File

@ -307,26 +307,12 @@ class SctpWorker implements Runnable {
final int predictedRecvBufSize = predictor.nextReceiveBufferSize(); final int predictedRecvBufSize = predictor.nextReceiveBufferSize();
boolean messageReceived = false; boolean messageReceived = false;
boolean failure = true;
MessageInfo messageInfo = null; MessageInfo messageInfo = null;
ByteBuffer bb = recvBufferPool.acquire(predictedRecvBufSize); ByteBuffer bb = recvBufferPool.acquire(predictedRecvBufSize);
try { try {
messageInfo = channel.channel.receive(bb, null, notificationHandler); messageInfo = channel.channel.receive(bb, null, notificationHandler);
if (messageInfo != null) { messageReceived = messageInfo != null;
messageReceived = true;
if (!messageInfo.isUnordered()) {
failure = false;
} else {
if (logger.isErrorEnabled()) {
logger.error("Received unordered SCTP Packet");
}
failure = true;
}
} else {
messageReceived = false;
failure = false;
}
} catch (ClosedChannelException e) { } catch (ClosedChannelException e) {
// Can happen, and does not need a user attention. // Can happen, and does not need a user attention.
} catch (Throwable t) { } catch (Throwable t) {
@ -356,7 +342,7 @@ class SctpWorker implements Runnable {
recvBufferPool.release(bb); recvBufferPool.release(bb);
} }
if (channel.channel.isBlocking() && !messageReceived || failure) { if (channel.channel.isBlocking() && !messageReceived) {
k.cancel(); // Some JDK implementations run into an infinite loop without this. k.cancel(); // Some JDK implementations run into an infinite loop without this.
close(channel, succeededFuture(channel)); close(channel, succeededFuture(channel));
return false; return false;