wyvern 04/12/02 18:56:52
Modified: javalib Tag: branch_3_17 SpreadConnection.java
Log:
Changed routine that removes listener thread to call join on the thread
after instructing it to exit, to avoid a race-condition when disconnecting.
Also, corrected handling of one-byte return codes received with
InputStream.read(byte), to correctly display/examine negative numbers.
Revision Changes Path
No revision
No revision
1.9.2.1 +7 -3 spread/javalib/SpreadConnection.java
Index: SpreadConnection.java
===================================================================
RCS file: /storage/cvsroot/spread/javalib/SpreadConnection.java,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- SpreadConnection.java 6 Oct 2004 14:08:18 -0000 1.9
+++ SpreadConnection.java 2 Dec 2004 23:56:52 -0000 1.9.2.1
@@ -474,9 +474,9 @@
}
// Check if it was a response code
//////////////////////////////////
- if( len < -1 )
+ if( len >= 128 )
{
- throw new SpreadException("Connection attempt rejected=" + (byte)len);
+ throw new SpreadException("Connection attempt rejected=" + (0xffffff00 | len));
}
// Read the name.
@@ -585,7 +585,7 @@
///////////////////
if(accepted != ACCEPT_SESSION)
{
- throw new SpreadException("Connection attempt rejected=" + (byte)accepted);
+ throw new SpreadException("Connection attempt rejected=" + (0xffffff00 | accepted));
}
}
@@ -1477,6 +1477,10 @@
//////////////////
listener.signal = true;
+ // Wait for the thread to die, to avoid inconsistencies.
+ ////////////////////////////////////////////////////////
+ listener.join();
+
// Clear the variable.
//////////////////////
listener = null;
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.