Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't hold the connection lock when calling receiveRstStream. #1106

Merged
merged 1 commit into from
Oct 26, 2014
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -734,18 +733,19 @@ private void ackSettingsLater(final Settings peerSettings) {
@Override public void goAway(int lastGoodStreamId, ErrorCode errorCode, ByteString debugData) {
if (debugData.size() > 0) { // TODO: log the debugData
}

// Copy the streams first. We don't want to hold a lock when we call receiveRstStream().
SpdyStream[] streamsCopy;
synchronized (SpdyConnection.this) {
streamsCopy = streams.values().toArray(new SpdyStream[streams.size()]);
shutdown = true;
}

// Fail all streams created after the last good stream ID.
for (Iterator<Map.Entry<Integer, SpdyStream>> i = streams.entrySet().iterator();
i.hasNext(); ) {
Map.Entry<Integer, SpdyStream> entry = i.next();
int streamId = entry.getKey();
if (streamId > lastGoodStreamId && entry.getValue().isLocallyInitiated()) {
entry.getValue().receiveRstStream(ErrorCode.REFUSED_STREAM);
i.remove();
}
// Fail all streams created after the last good stream ID.
for (SpdyStream spdyStream : streamsCopy) {
if (spdyStream.getId() > lastGoodStreamId && spdyStream.isLocallyInitiated()) {
spdyStream.receiveRstStream(ErrorCode.REFUSED_STREAM);
removeStream(spdyStream.getId());
}
}
}
Expand Down