Revision: ddfa23904d4d
Author: vralev <vralev@8e71dc83-d81e-6649-80f2-80b843a9b2be>
Date: Mon Jul 16 02:49:59 2012
Log: Backport to TelScale branch
JSIP-416
Fix mid-tx socket reconnect for NIO TCP and close NIO sockets properly on
stack termination.
git-svn-id:
https://svn.java.net/svn/jsip~svn/branches/JAIN-SIP-NIO-year-2012@2131
8e71dc83-d81e-6649-80f2-80b843a9b2be
(cherry picked from commit 4b7b84f01bd00c60959d8fad6f8278ee05b88b07)
http://code.google.com/p/jain-sip/source/detail?r=ddfa23904d4d
Modified:
/src/gov/nist/javax/sip/stack/NioTcpMessageChannel.java
/src/gov/nist/javax/sip/stack/SIPTransactionStack.java
=======================================
--- /src/gov/nist/javax/sip/stack/NioTcpMessageChannel.java Thu Jul 5
22:32:44 2012
+++ /src/gov/nist/javax/sip/stack/NioTcpMessageChannel.java Mon Jul 16
02:49:59 2012
@@ -237,7 +237,7 @@
*/
SocketChannel sock = null;
NIOHandler nioHandler = ((NioTcpMessageProcessor)
messageProcessor).nioHandler;
- if(this.socketChannel != null &&
this.socketChannel.isConnected()) {
+ if(this.socketChannel != null && this.socketChannel.isConnected() &&
this.socketChannel.isOpen()) {
nioHandler.putSocket(NIOHandler.makeKey(this.peerAddress,
this.peerPort), this.socketChannel);
}
IOException problem = null;
=======================================
--- /src/gov/nist/javax/sip/stack/SIPTransactionStack.java Fri Jul 13
05:08:46 2012
+++ /src/gov/nist/javax/sip/stack/SIPTransactionStack.java Mon Jul 16
02:49:59 2012
@@ -2068,7 +2068,7 @@
for (int processorIndex = 0; processorIndex <
processorList.length; processorIndex++) {
removeMessageProcessor(processorList[processorIndex]);
}
- this.ioHandler.closeAll();
+ closeAllSockets();
// Let the processing complete.
if (this.timer != null)
@@ -2084,6 +2084,16 @@
this.serverLogger.closeLogFile();
}
+
+ public void closeAllSockets() {
+ this.ioHandler.closeAll();
+ for(MessageProcessor p : messageProcessors) {
+ if(p instanceof NioTcpMessageProcessor) {
+ NioTcpMessageProcessor niop = (NioTcpMessageProcessor)p;
+ niop.nioHandler.closeAll();
+ }
+ }
+ }
/**
* Put a transaction in the pending transaction list. This is to avoid
a