a patch to avoid a deadlock

Bernardo F Costa <[email protected]>
Newsgroups gmane.comp.java.sshtools.user
Message-ID <[email protected]>
My dear friends, I have faced a situation that maybe
you could get too: a closed socket when trying to
opena session. In my case, it would lead to a infinite
wait of the thread. Looking at the code, I found a
release of a lock that was bypassed at such
situations. I replaced it and thigs started to work.
Take a look at this patch and, if you have faced such
situation, consider on applying it to the sources.

---
src/com/sshtools/j2ssh/transport/TransportProtocolOutputStream.java
2003-12-
08 10:54:52.000000000 -0200
+++
src/com/sshtools/j2ssh/transport/TransportProtocolOutputStream.java
2007-01-
06 22:33:59.000000000 -0200
@@ -178,7 +178,7 @@
             out.write(message.toByteArray());
 
             out.flush();
-            algorithms.release();
+            //algorithms.release(); an exception at
out.write and deadlock !!!
 
             // Increment the sequence no
             if (sequenceNo < sequenceWrapLimit) {
@@ -191,6 +191,8 @@
                 throw new
TransportProtocolException("IO Error on socket: " +
                     ioe.getMessage());
             }
-        }
+        } finally {
+          algorithms.release();
+       }
     }
 }


__________________________________________________
Fale com seus amigos  de graça com o novo Yahoo! Messenger 
http://br.messenger.yahoo.com/

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Sshtools-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sshtools-users
patch.txt (text/plain, 747 B)
--- src/com/sshtools/j2ssh/transport/TransportProtocolOutputStream.java	2003-12-08 10:54:52.000000000 -0200
+++ src/com/sshtools/j2ssh/transport/TransportProtocolOutputStream.java	2007-01-06 22:33:59.000000000 -0200
@@ -178,7 +178,7 @@
             out.write(message.toByteArray());
 
             out.flush();
-            algorithms.release();
+            //algorithms.release(); an exception at out.write an deadlock !!!
 
             // Increment the sequence no
             if (sequenceNo < sequenceWrapLimit) {
@@ -191,6 +191,8 @@
                 throw new TransportProtocolException("IO Error on socket: " +
                     ioe.getMessage());
             }
-        }
+        } finally {
+	   algorithms.release();
+	}
     }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.