You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/11/20 21:57:52 UTC
svn commit: r1543943 -
/tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
Author: markt
Date: Wed Nov 20 20:57:52 2013
New Revision: 1543943
URL: http://svn.apache.org/r1543943
Log:
Further work on https://issues.apache.org/bugzilla/show_bug.cgi?id=55799
If an IO error occurs while sending (or receiving) a WebSocket message pretty much the only thing that can be done is to close the connection - hopefully in a graceful manner. Therefore, leave the state machine in the "message in progress" state if an error occurs as this will prevent further attempts to send non-control messages. The close message is a control message so it will not be blocked. Note that the close message may not reach the other end of the connection.
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java?rev=1543943&r1=1543942&r2=1543943&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java Wed Nov 20 20:57:52 2013
@@ -116,11 +116,8 @@ public abstract class WsRemoteEndpointIm
public void sendBytes(ByteBuffer data) throws IOException {
stateMachine.binaryStart();
- try {
- startMessageBlock(Constants.OPCODE_BINARY, data, true);
- } finally {
- stateMachine.complete(true);
- }
+ startMessageBlock(Constants.OPCODE_BINARY, data, true);
+ stateMachine.complete(true);
}
@@ -141,11 +138,8 @@ public abstract class WsRemoteEndpointIm
public void sendPartialBytes(ByteBuffer partialByte, boolean last)
throws IOException {
stateMachine.binaryPartialStart();
- try {
- startMessageBlock(Constants.OPCODE_BINARY, partialByte, last);
- } finally {
- stateMachine.complete(last);
- }
+ startMessageBlock(Constants.OPCODE_BINARY, partialByte, last);
+ stateMachine.complete(last);
}
@@ -646,9 +640,11 @@ public abstract class WsRemoteEndpointIm
@Override
public void onResult(SendResult result) {
- if (isDone || !result.isOK()) {
+ if (isDone) {
endpoint.stateMachine.complete(isLast);
handler.onResult(result);
+ } else if(!result.isOK()) {
+ handler.onResult(result);
} else {
write();
}
@@ -1024,7 +1020,9 @@ public abstract class WsRemoteEndpointIm
@Override
public void onResult(SendResult result) {
- stateMachine.complete(true);
+ if (result.isOK()) {
+ stateMachine.complete(true);
+ }
handler.onResult(result);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org