JBoss Community

Re: SSL bisocket socketWrite0() hangs, while holding Messaging Post Office lock (on a network failure)

created by Todd Sandor in JBoss Remoting - View the full discussion

I found a workaround to this SSL defect which is to set the socket linger option in OutputTimerTask.run()

before the close() is performed.

 

I've never contributed to the community source, but below are the

diffs, hopefully someone can get this into the community version to tell me how I go about contributing

this change into the community version.

 

 

File to change: (e.g. for tag 2.5.4.SP3)

 

org.jboss.remoting.transport.socket.ClientSocketWrapper.java

org.jboss.remoting.transport.socket.TimedOutputStream.java

 

 

diff ClientSocketWrapper.java ../ClientSocketWrapper.java

223c223,224

<          os = new TimedOutputStream(os, writeTimeout);

---

>           Socket mySkt = super.getSocket();

>           os = new TimedOutputStream(os, writeTimeout, mySkt);

 

 

 

 

 

diff TimedOutputStream.java ../TimedOutputStream.java

26a27

> import java.net.Socket;

47a49,60

>    private Socket mySkt;

>

>     public Socket getMySkt() {

>         return mySkt;

>     }

>

>     public TimedOutputStream(OutputStream os, int outputTimeout, Socket pmySkt)

>     {

>         this.os = os;

>         this.outputTimeout = outputTimeout;

>         this.mySkt = pmySkt;

>     }

134c147

<      

---

>

142,151c155,192

<          try

<          {

<             log.debug(this + " closing: " + tos);

<             tos.close();

<             tos = null;

<          }

<          catch (IOException e)

<          {

<             log.debug("unable to close " + tos);

<          }

---

>           try

>           {

>

>               Socket mySocket = tos.getMySkt();

>               if (mySocket != null)

>               {

>                   // set the linger on with duration 0, results RST being sent

>                   // and socket send and receive buffers being discarded (does not

>                   // wait of the existing write() to complete].  There is no use in

>                   // setting the soLingerDuration longer then 0 (thus waiting for the write to

>                   // complete), since we've already waited "writeTimeout" seconds on this write.

>                   boolean on = true;

>                   int soLingerDuration = 0;

>                   log.debug(this + " socketWrite TIMEOUT: set soLinger(ON,0): " + tos);

>                   mySocket.setSoLinger(on, soLingerDuration);

>

>               }

>           }

>           catch (IOException e)

>           {

>               log.debug(" socketWrite TIMEOUT: Attempting to set linger on socket stream [" + tos +

>                       "], Exception [" + e.toString() + "]");

>           }

>           finally

>           {

>               log.debug(this + " socketWrite TIMEOUT: close(): " + tos);

>               try

>               {

>                   tos.close();

>               }

>               catch (Exception e)

>               {

>                   // ignore - log log error

>                   log.error("Failed to close() socket stream Exception: ", e);

>               }

>               log.debug(this + " socketWrite TIMEOUT: close() completed.");

>               tos = null;

>           }

153c194

<      

---

>

Reply to this message by going to Community

Start a new discussion in JBoss Remoting at Community