Skip to content

Commit

Permalink
Remove unnecessary loop and quit in CronetChunkedOutputStream
Browse files Browse the repository at this point in the history
The MessageLoop.loop() in CronetChunkedOutputStream.close()
is potentially problematic. If the user closes the
OutputStream unintentionally when MessageLoop is not going
to be quit, it might wait forever. This removes the
corresponding unnecessary quit().

BUG=626653

Review-Url: https://codereview.chromium.org/1657103002
Cr-Commit-Position: refs/heads/master@{#404391}
  • Loading branch information
xunjieli authored and Commit bot committed Jul 8, 2016
1 parent 2ccd50c commit 5789507
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,8 @@ public void write(byte[] buffer, int offset, int count) throws IOException {

@Override
public void close() throws IOException {
if (!mLastChunk) {
// Write last chunk.
mLastChunk = true;
mMessageLoop.loop();
}
// Last chunk is written.
mLastChunk = true;
mClosed = true;
}

Expand Down Expand Up @@ -137,9 +134,11 @@ public void read(final UploadDataSink uploadDataSink, final ByteBuffer byteBuffe
byteBuffer.put(mBuffer);
// Reuse this buffer.
mBuffer.clear();
// Quit message loop so embedder can write more data.
mMessageLoop.quit();
uploadDataSink.onReadSucceeded(mLastChunk);
if (!mLastChunk) {
// Quit message loop so embedder can write more data.
mMessageLoop.quit();
}
}
}

Expand Down

0 comments on commit 5789507

Please sign in to comment.