Author: markt
Date: Fri Sep 18 14:12:41 2015
New Revision: 1703865
URL: http://svn.apache.org/viewvc?rev=1703865&view=rev
Log:
Fix various data races reported by RV-Predict.
Mostly caused by completion handlers that execute in a new thread
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java
tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java
tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java?rev=1703865&r1=1703864&r2=1703865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameBase.java Fri Sep 18
14:12:41 2015
@@ -78,13 +78,13 @@ public abstract class WsFrameBase {
private final byte[] mask = new byte[4];
private int maskIndex = 0;
private long payloadLength = 0;
- private long payloadWritten = 0;
+ private volatile long payloadWritten = 0;
// Attributes tracking state
- private State state = State.NEW_FRAME;
+ private volatile State state = State.NEW_FRAME;
private volatile boolean open = true;
- private int readPos = 0;
- protected int writePos = 0;
+ private volatile int readPos = 0;
+ protected volatile int writePos = 0;
public WsFrameBase(WsSession wsSession, Transformation transformation) {
inputBuffer = new byte[Constants.DEFAULT_BUFFER_SIZE];
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java?rev=1703865&r1=1703864&r2=1703865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsFrameClient.java Fri Sep 18
14:12:41 2015
@@ -37,7 +37,7 @@ public class WsFrameClient extends WsFra
private final AsyncChannelWrapper channel;
private final CompletionHandler<Integer,Void> handler;
// Not final as it may need to be re-sized
- private ByteBuffer response;
+ private volatile ByteBuffer response;
public WsFrameClient(ByteBuffer response, AsyncChannelWrapper channel,
WsSession wsSession, Transformation transformation) {
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java?rev=1703865&r1=1703864&r2=1703865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java Fri Sep 18
14:12:41 2015
@@ -84,10 +84,10 @@ public class WsSession implements Sessio
private final String id;
// Expected to handle message types of <String> only
- private MessageHandler textMessageHandler = null;
+ private volatile MessageHandler textMessageHandler = null;
// Expected to handle message types of <ByteBuffer> only
- private MessageHandler binaryMessageHandler = null;
- private MessageHandler.Whole<PongMessage> pongMessageHandler = null;
+ private volatile MessageHandler binaryMessageHandler = null;
+ private volatile MessageHandler.Whole<PongMessage> pongMessageHandler =
null;
private volatile State state = State.OPEN;
private final Object stateLock = new Object();
private final Map<String,Object> userProperties = new
ConcurrentHashMap<>();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]