Browse Source

Fix flush call race condition in StreamCopyThread

If there was a new flush() call during flush previous bytes, we need to
catch it in order to process the new bytes between the two flush()
calls instead of going to last catch IOException clause and end the
thread.

Change-Id: Ibc58a1fa97559238c13590aedbb85e482d85e465
Signed-off-by: Zhen Chen <czhen@google.com>
stable-4.6
Zhen Chen 8 years ago
parent
commit
feefcb02b0
  1. 8
      org.eclipse.jgit/src/org/eclipse/jgit/util/io/StreamCopyThread.java

8
org.eclipse.jgit/src/org/eclipse/jgit/util/io/StreamCopyThread.java

@ -118,7 +118,13 @@ public class StreamCopyThread extends Thread {
for (;;) {
try {
if (readInterrupted) {
dst.flush();
try {
dst.flush();
} catch (InterruptedIOException e) {
// There was a new flush() call during flush previous bytes
// need continue read/write/flush for the new bytes
continue;
}
readInterrupted = false;
if (!flushCount.compareAndSet(flushCountBeforeRead, 0)) {
// There was a flush() call since last blocked read.

Loading…
Cancel
Save