tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r407615 - /tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java
Date Thu, 18 May 2006 19:03:28 GMT
Author: fhanik
Date: Thu May 18 12:03:27 2006
New Revision: 407615

URL: http://svn.apache.org/viewvc?rev=407615&view=rev
Log:
Fixed synchronization issues upon startup, and always using a soTimeout

Modified:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java?rev=407615&r1=407614&r2=407615&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java
Thu May 18 12:03:27 2006
@@ -166,11 +166,12 @@
                 log.info("Setting multihome multicast interface to:" +mcastBindAddress);
             socket.setInterface(mcastBindAddress);
         } //end if
-        if ( mcastSoTimeout >= 0 ) {
- 			if(log.isInfoEnabled())
-                log.info("Setting cluster mcast soTimeout to "+mcastSoTimeout);
-            socket.setSoTimeout(mcastSoTimeout);
-        }
+        //force a so timeout so that we don't block forever
+        if ( mcastSoTimeout <= 0 ) mcastSoTimeout = (int)sendFrequency;
+        if(log.isInfoEnabled())
+            log.info("Setting cluster mcast soTimeout to "+mcastSoTimeout);
+        socket.setSoTimeout(mcastSoTimeout);
+
         if ( mcastTTL >= 0 ) {
 			if(log.isInfoEnabled())
                 log.info("Setting cluster mcast TTL to " + mcastTTL);
@@ -198,6 +199,8 @@
             if(log.isInfoEnabled())
                 log.info("Sleeping for "+memberwait+" milliseconds to establish cluster membership");
             try {Thread.sleep(memberwait);}catch (InterruptedException ignore){}
+            if(log.isInfoEnabled())
+                log.info("Done sleeping, membership established.");
         } 
         if ( (level & Channel.MBR_TX_SEQ)==Channel.MBR_TX_SEQ ) {
             if ( sender != null ) throw new IllegalStateException("McastService.send already
running.");
@@ -260,7 +263,6 @@
      * @throws IOException
      */
     public void receive() throws IOException {
-        checkExpired();
         try {
             socket.receive(receivePacket);
             byte[] data = new byte[receivePacket.getLength()];
@@ -283,17 +285,21 @@
             //since the receive thread is the same thread
             //that does membership expiration
         }
+        checkExpired();
     }
-
-    protected synchronized void checkExpired() {
-        MemberImpl[] expired = membership.expire(timeToExpiration);
-        for ( int i=0; i<expired.length; i++) {
-            if(log.isDebugEnabled())
-                log.debug("Mcast exipre  member " + expired[i]);
-            try {
-                service.memberDisappeared(expired[i]);
-            }catch ( Exception x ) { 
-                log.error("Unable to process member disappeared message.",x);
+    
+    protected Object expiredMutex = new Object();
+    protected void checkExpired() {
+        synchronized (expiredMutex) {
+            MemberImpl[] expired = membership.expire(timeToExpiration);
+            for (int i = 0; i < expired.length; i++) {
+                if (log.isDebugEnabled())
+                    log.debug("Mcast exipre  member " + expired[i]);
+                try {
+                    service.memberDisappeared(expired[i]);
+                } catch (Exception x) {
+                    log.error("Unable to process member disappeared message.", x);
+                }
             }
         }
     }



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


Mime
View raw message