cvs commit: spread/javalib SpreadConnection.java

[email protected]
Newsgroups gmane.network.spread.cvs
Message-ID <[email protected]>
wyvern      04/12/02 18:58:08

  Modified:    javalib  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
  1.10      +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.10
  diff -u -r1.9 -r1.10
  --- SpreadConnection.java	6 Oct 2004 14:08:18 -0000	1.9
  +++ SpreadConnection.java	2 Dec 2004 23:58:07 -0000	1.10
  @@ -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.