dfs 2002/09/19 09:54:58
Modified: net/src/java/org/apache/commons/net/telnet
TelnetInputStream.java
Log:
Applied a fix for potential deadlock by changing a wait() to a wait(100).
Revision Changes Path
1.3 +5 -20
jakarta-commons-sandbox/net/src/java/org/apache/commons/net/telnet/TelnetInputStream.java
Index: TelnetInputStream.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/net/src/java/org/apache/commons/net/telnet/TelnetInputStream.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TelnetInputStream.java 12 Apr 2002 04:42:47 -0000 1.2
+++ TelnetInputStream.java 19 Sep 2002 16:54:58 -0000 1.3
@@ -265,11 +265,9 @@
__queue.notify();
try
{
- //System.out.println("READ WAIT");
__readIsWaiting = true;
__queue.wait();
__readIsWaiting = false;
- //System.out.println("READ END WAIT");
}
catch (InterruptedException e)
{
@@ -384,23 +382,15 @@
synchronized (__queue)
{
__hasReachedEOF = true;
+ __isClosed = true;
+
if (__thread.isAlive())
{
- __isClosed = true;
__thread.interrupt();
}
+
__queue.notifyAll();
}
- /*
- while(__thread.isAlive()) {
- __thread.interrupt();
- try {
- __thread.join();
- } catch(InterruptedException e) {
- // If this happens, we just continue to loop
- }
- }
- */
}
public void run()
@@ -422,12 +412,10 @@
synchronized (__queue)
{
__ioException = e;
- __queue.notify();
+ __queue.notifyAll();
try
{
- //System.out.println("THREAD WAIT B");
- __queue.wait();
- //System.out.println("THREAD END WAIT B");
+ __queue.wait(100);
}
catch (InterruptedException interrupted)
{
@@ -448,9 +436,7 @@
__queue.notify();
try
{
- //System.out.println("THREAD WAIT");
__queue.wait();
- //System.out.println("THREAD END WAIT");
}
catch (InterruptedException e)
{
@@ -462,7 +448,6 @@
// Need to do this in case we're not full, but block on a read
if (__readIsWaiting)
{
- //System.out.println("NOTIFY");
__queue.notify();
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>