Menu ▾ ▴

#13 Thread safety patch for InputDataStream

open
9
2005-01-21
2005-01-20
No

This patch fixes a race condition that can potentially
cause problems reading data from a peer. Without this
patch, it is possible for InputDataStreamAdapter.read()
to return -1 prematurely, or
InputDataStreamAdapter.read(byte,int,int) to go into an
endless loop.

Index: InputDataStream.java

RCS file:
/cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/InputDataStream.java,v
retrieving revision 1.6
diff -u -r1.6 InputDataStream.java
--- InputDataStream.java 23 Apr 2003 15:23:04 -0000 1.6
+++ InputDataStream.java 20 Jan 2005 23:33:24 -0000
@@ -90,9 +90,9 @@

synchronized (this.buffers) {
this.buffers.addLast(segment);
+ this.availableBytes += segment.getLength();
this.buffers.notify();
}
- this.availableBytes += segment.getLength();
}

public int available()

Discussion

  • Warren Janssens

    Warren Janssens - 2005-01-21
    • priority: 5 --> 9
     

Log in to post a comment.