Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Unified Diff: plugins/org.chromium.sdk.wipbackend.dev/src/org/chromium/sdk/internal/websocket/Hybi17WsConnection.java

Issue 9959080: Issue 66: closing browser results into "SocketException: Broken pipe" (Closed) Base URL: https://chromedevtools.googlecode.com/svn/trunk
Patch Set: format Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: plugins/org.chromium.sdk.wipbackend.dev/src/org/chromium/sdk/internal/websocket/Hybi17WsConnection.java
diff --git a/plugins/org.chromium.sdk.wipbackend.dev/src/org/chromium/sdk/internal/websocket/Hybi17WsConnection.java b/plugins/org.chromium.sdk.wipbackend.dev/src/org/chromium/sdk/internal/websocket/Hybi17WsConnection.java
index c05ded8ea8f7dcf2f17a31da051d95a4c88fbfcc..b1d13f928fea14acdf63d7d0e3db4b926175427d 100644
--- a/plugins/org.chromium.sdk.wipbackend.dev/src/org/chromium/sdk/internal/websocket/Hybi17WsConnection.java
+++ b/plugins/org.chromium.sdk.wipbackend.dev/src/org/chromium/sdk/internal/websocket/Hybi17WsConnection.java
@@ -147,7 +147,11 @@ public class Hybi17WsConnection extends AbstractWsConnection<LoggableInput, Logg
return runListenLoopImpl(loggableReader);
} catch (IOException e) {
String stackTrace = BasicUtil.getStacktraceString(e);
- sendClosingMessage(StatusCode.PROTOCOL_ERROR, stackTrace);
+ try {
+ sendClosingMessage(StatusCode.PROTOCOL_ERROR, stackTrace);
+ } catch (IOException e2) {
+ // Connection may be closed by this time. We probably don't want to log this exception.
+ }
throw new IOException(e);
} catch (IncomingProtocolException e) {
String stackTrace = BasicUtil.getStacktraceString(e);
@@ -174,7 +178,7 @@ public class Hybi17WsConnection extends AbstractWsConnection<LoggableInput, Logg
if (isClosingGracefully()) {
return CloseReason.USER_REQUEST;
} else {
- throw new IOException("Unexpected end of stream");
+ return CloseReason.REMOTE_SILENTLY_CLOSED;
}
}
@@ -387,6 +391,11 @@ public class Hybi17WsConnection extends AbstractWsConnection<LoggableInput, Logg
throw new IOException("WebSocket is already closed for output");
}
+ if (isClosingMessage) {
+ // Close it before actually sending, because we can fail on it.
+ setOutputClosed(true);
+ }
+
byte firstByte = (byte) (FrameBits.FIN_BIT | OpCode.TEXT);
output.writeByte(firstByte);
@@ -415,10 +424,6 @@ public class Hybi17WsConnection extends AbstractWsConnection<LoggableInput, Logg
output.writeBytes(maskBytes);
}
loggablePayload.send(output, maskBytes);
-
- if (isClosingMessage) {
- setOutputClosed(true);
- }
}
output.markSeparatorForLog();

Powered by Google App Engine
This is Rietveld 408576698