I am not sure declaring this field as volatile is the right way to fix it
because the increment is still not atomic. If this counter doesn't have to
be precise, I think it's OK to allow data races on this field. Otherwise,
it should be declared as atomic.

Yilong

On Tue, Sep 15, 2015 at 6:43 AM, <ma...@apache.org> wrote:

> Author: markt
> Date: Tue Sep 15 13:43:55 2015
> New Revision: 1703194
>
> URL: http://svn.apache.org/r1703194
> Log:
> Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=58384
> Calls to backgroundProcess() may come from different threads
>
> Modified:
>     tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
>
> Modified:
> tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
> URL:
> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java?rev=1703194&r1=1703193&r2=1703194&view=diff
>
> ==============================================================================
> ---
> tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
> (original)
> +++
> tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java Tue
> Sep 15 13:43:55 2015
> @@ -92,7 +92,7 @@ public class WsWebSocketContainer implem
>      private int maxBinaryMessageBufferSize =
> Constants.DEFAULT_BUFFER_SIZE;
>      private int maxTextMessageBufferSize = Constants.DEFAULT_BUFFER_SIZE;
>      private volatile long defaultMaxSessionIdleTimeout = 0;
> -    private int backgroundProcessCount = 0;
> +    private volatile int backgroundProcessCount = 0;
>      private int processPeriod = Constants.DEFAULT_PROCESS_PERIOD;
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>
>

Reply via email to