tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1143379 - in /tomcat/trunk: java/org/apache/catalina/tribes/transport/ReceiverBase.java webapps/docs/changelog.xml
Date Wed, 06 Jul 2011 12:31:51 GMT
Author: markt
Date: Wed Jul  6 12:31:50 2011
New Revision: 1143379

URL: http://svn.apache.org/viewvc?rev=1143379&view=rev
Log:
Add sync to fix test failures on Linux.
Should have minimal impact in normal Tomcat usage since each instance/JVM only opens a single
socket.

Modified:
    tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java?rev=1143379&r1=1143378&r2=1143379&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java Wed Jul  6 12:31:50
2011
@@ -50,6 +50,8 @@ public abstract class ReceiverBase imple
 
     private static final Log log = LogFactory.getLog(ReceiverBase.class);
 
+    private static final Object bindLock = new Object();
+
     private MessageListener listener;
     private String host = "auto";
     private InetAddress bind;
@@ -220,23 +222,25 @@ public abstract class ReceiverBase imple
      * @throws IOException
      */
     protected void bind(ServerSocket socket, int portstart, int retries) throws IOException
{
-        InetSocketAddress addr = null;
-        int port = portstart;
-        while (retries > 0) {
-            try {
-                addr = new InetSocketAddress(getBind(), port);
-                socket.bind(addr);
-                setPort(port);
-                log.info("Receiver Server Socket bound to:"+addr);
-                retries = 0;
-            } catch ( IOException x) {
-                retries--;
-                if ( retries <= 0 ) {
-                    log.info("Unable to bind server socket to:" + addr +
-                            " throwing error.");
-                    throw x;
+        synchronized (bindLock) {
+            InetSocketAddress addr = null;
+            int port = portstart;
+            while (retries > 0) {
+                try {
+                    addr = new InetSocketAddress(getBind(), port);
+                    socket.bind(addr);
+                    setPort(port);
+                    log.info("Receiver Server Socket bound to:"+addr);
+                    retries = 0;
+                } catch ( IOException x) {
+                    retries--;
+                    if ( retries <= 0 ) {
+                        log.info("Unable to bind server socket to:" + addr +
+                                " throwing error.");
+                        throw x;
+                    }
+                    port++;
                 }
-                port++;
             }
         }
     }

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1143379&r1=1143378&r2=1143379&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Jul  6 12:31:50 2011
@@ -95,6 +95,10 @@
         Start to convert non-JUnit tests to JUnit. Remove unnecessary code.
         (markt) 
       </update>
+      <fix>
+        Add synchronization to receiver socket binding to prevent test failures
+        on Linuz. (markt) 
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Other">



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


Mime
View raw message