Author: fhanik Date: Mon May 7 04:30:17 2007 New Revision: 535852 URL: http://svn.apache.org/viewvc?view=rev&rev=535852 Log: Fix direct connect, which apparently happens on Solaris
Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioSender.java Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioSender.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioSender.java?view=diff&rev=535852&r1=535851&r2=535852 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioSender.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioSender.java Mon May 7 04:30:17 2007 @@ -30,6 +30,7 @@ import org.apache.catalina.tribes.transport.DataSender; import org.apache.catalina.tribes.RemoteProcessException; import java.io.EOFException; +import java.net.*; /** * This class is NOT thread safe and should never be used with more than one thread at a time @@ -85,21 +86,7 @@ if ( !key.isValid() ) throw new IOException("Key is not valid, it must have been cancelled."); if ( key.isConnectable() ) { if ( socketChannel.finishConnect() ) { - //we connected, register ourselves for writing - setConnected(true); - connecting = false; - setRequestCount(0); - setConnectTime(System.currentTimeMillis()); - socketChannel.socket().setSendBufferSize(getTxBufSize()); - socketChannel.socket().setReceiveBufferSize(getRxBufSize()); - socketChannel.socket().setSoTimeout((int)getTimeout()); - socketChannel.socket().setSoLinger(false,0); - socketChannel.socket().setTcpNoDelay(getTcpNoDelay()); - socketChannel.socket().setKeepAlive(getSoKeepAlive()); - socketChannel.socket().setReuseAddress(getSoReuseAddress()); - socketChannel.socket().setOOBInline(getOoBInline()); - socketChannel.socket().setSoLinger(getSoLingerOn(),getSoLingerTime()); - socketChannel.socket().setTrafficClass(getSoTrafficClass()); + completeConnect(); if ( current != null ) key.interestOps(key.interestOps() | SelectionKey.OP_WRITE); return false; } else { @@ -141,6 +128,24 @@ }//end if return false; } + + private void completeConnect() throws SocketException { + //we connected, register ourselves for writing + setConnected(true); + connecting = false; + setRequestCount(0); + setConnectTime(System.currentTimeMillis()); + socketChannel.socket().setSendBufferSize(getTxBufSize()); + socketChannel.socket().setReceiveBufferSize(getRxBufSize()); + socketChannel.socket().setSoTimeout((int)getTimeout()); + socketChannel.socket().setSoLinger(false,0); + socketChannel.socket().setTcpNoDelay(getTcpNoDelay()); + socketChannel.socket().setKeepAlive(getSoKeepAlive()); + socketChannel.socket().setReuseAddress(getSoReuseAddress()); + socketChannel.socket().setOOBInline(getOoBInline()); + socketChannel.socket().setSoLinger(getSoLingerOn(),getSoLingerTime()); + socketChannel.socket().setTrafficClass(getSoTrafficClass()); + } @@ -215,8 +220,12 @@ if ( socketChannel != null ) throw new IOException("Socket channel has already been established. Connection might be in progress."); socketChannel = SocketChannel.open(); socketChannel.configureBlocking(false); - socketChannel.connect(addr); - socketChannel.register(getSelector(),SelectionKey.OP_CONNECT,this); + if ( socketChannel.connect(addr) ) { + completeConnect(); + socketChannel.register(getSelector(), SelectionKey.OP_WRITE, this); + } else { + socketChannel.register(getSelector(), SelectionKey.OP_CONNECT, this); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]