2012/9/18  <kfuj...@apache.org>:
> Author: kfujino
> Date: Tue Sep 18 09:45:17 2012
> New Revision: 1387073
>
> URL: http://svn.apache.org/viewvc?rev=1387073&view=rev
> Log:
> Fix a behavior of TcpPingInterceptor#useThread.
> If set to false, ping thread is never started.
>
> Modified:
>     
> tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptor.java
>     tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
>     tomcat/tc7.0.x/trunk/webapps/docs/config/cluster-interceptor.xml
>
> Modified: 
> tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptor.java
> URL: 
> http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptor.java?rev=1387073&r1=1387072&r2=1387073&view=diff
> ==============================================================================
> --- 
> tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptor.java
>  (original)
> +++ 
> tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptor.java
>  Tue Sep 18 09:45:17 2012
> @@ -64,8 +64,8 @@ public class TcpPingInterceptor extends
>      @Override
>      public synchronized void start(int svc) throws ChannelException {
>          super.start(svc);
> -        running = true;
> -        if ( thread == null ) {
> +        if ( thread == null && useThread) {
> +            running = true;
>              thread = new PingThread();
>              thread.setDaemon(true);
>              
> thread.setName("TcpPingInterceptor.PingThread-"+cnt.addAndGet(1));
> @@ -86,9 +86,11 @@ public class TcpPingInterceptor extends
>
>      @Override
>      public void stop(int svc) throws ChannelException {
> -        running = false;
> -        if ( thread != null ) thread.interrupt();
> -        thread = null;
> +        if ( thread != null ) {
> +            running = false;
> +            thread.interrupt();
> +            thread = null;
> +        }
>          super.stop(svc);
>      }

The above changes the meaning of the "running" flag.

IMHO, the flag is supposed to say whether TcpPingInterceptor itself is
running or not. It does not matter whether you started a thread or
not.  So I would move it out of the "if" block.


Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to