Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions okhttp/src/main/java/io/grpc/okhttp/OkHttpClientTransport.java
Original file line number Diff line number Diff line change
Expand Up @@ -1207,8 +1207,15 @@ private void stopIfNecessary() {
frameWriter.goAway(0, ErrorCode.NO_ERROR, new byte[0]);
}

// We will close the underlying socket in the writing thread to break out the reader
// thread, which will close the frameReader and notify the listener.
// Close the frameReader first to stop the ClientFrameHandler thread, then
// close the frameWriter (which closes the underlying socket through the
// writing thread). This prevents a TSAN data race between the socket close
// and the ClientFrameHandler's read from the same socket.
try {
clientFrameHandler.frameReader.close();
} catch (IOException e) {
log.log(java.util.logging.Level.FINE, "Exception closing frame reader", e);
}
frameWriter.close();
}

Expand Down
Loading