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>
This commit is contained in:
parent
83555e7e30
commit
feefcb02b0
|
@ -118,7 +118,13 @@ public void run() {
|
|||
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…
Reference in New Issue