protected void nowReconnectedAsync ( ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Reconnected async for " + this ) ; } // reset the data buffers first if ( ! resetWriteBuffers ( ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Resetting buffers (async) failed" ) ; } // otherwise pass the error along to the channel above us, or close // the connection if nobody is above IOException ioe = new IOException ( "Failed reconnect" ) ; if ( null != getAppWriteCallback ( ) ) { getAppWriteCallback ( ) . error ( getVC ( ) , ioe ) ; } else { // nobody above us, just close the connection getLink ( ) . getDeviceLink ( ) . close ( getVC ( ) , ioe ) ; } return ; } // now that we've reconnected, we should reset the "broken" flag. First // we set it to the default and then recheck the request msg setPersistent ( true ) ; updatePersistence ( getRequestImpl ( ) ) ; // in case we previously read any partial data, clean out the response resetRead ( ) ; // attempt to write the data VirtualConnection rc = getTSC ( ) . getWriteInterface ( ) . write ( TCPWriteRequestContext . WRITE_ALL_DATA , HttpOSCWriteCallback . getRef ( ) , isForceAsync ( ) , getWriteTimeout ( ) ) ; if ( null != rc ) { // if we've finished writing part of a request, let the channel // above know that it can write more, otherwise start the read // for the response if ( ! isMessageSent ( ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Calling callback.complete of app channel." ) ; } getAppWriteCallback ( ) . complete ( getLink ( ) . getVirtualConnection ( ) ) ; } else { if ( isReadAheadEnabled ( ) ) { // after a reconnect, there is no more read-ahead active this . bReadAheadEnabled = false ; } // force an async read for the response now. Avoid trying to // re-use any existing read buffer to skip complexity with // adjusting for partial reads before the reconnect. setupJITRead ( getHttpConfig ( ) . getIncomingHdrBufferSize ( ) ) ; getTSC ( ) . getReadInterface ( ) . read ( 1 , HttpOSCReadCallback . getRef ( ) , true , getReadTimeout ( ) ) ; } } }
Once we know we are reconnected to the target server reset the TCP buffers and start the async resend .