You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ms...@apache.org on 2007/03/16 17:49:44 UTC

svn commit: r519056 - /incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/ProcessMutex.java

Author: mszefler
Date: Fri Mar 16 09:49:43 2007
New Revision: 519056

URL: http://svn.apache.org/viewvc?view=rev&rev=519056
Log:
ODE-100. Add patch suggested by Dan Kearns to speed up release of socket.

Modified:
    incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/ProcessMutex.java

Modified: incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/ProcessMutex.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/ProcessMutex.java?view=diff&rev=519056&r1=519055&r2=519056
==============================================================================
--- incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/ProcessMutex.java (original)
+++ incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/ProcessMutex.java Fri Mar 16 09:49:43 2007
@@ -19,6 +19,7 @@
 package org.apache.ode.utils;
 
 import java.io.IOException;
+import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 
 
@@ -27,6 +28,8 @@
  * TCP port to synchronize multiple processes. The method of operation is
  * simple: by opening a port, a process prevents other processes on the local
  * machine from opening the same port.
+ * 
+ * @author Maciej Szefler  ( m s z e f l e r @ g m a i l . c o m)
  */
 public class ProcessMutex {
   private int port;
@@ -59,7 +62,10 @@
 
       while ((startTime + 15000) > System.currentTimeMillis()) {
         try {
-          ss = new ServerSocket(port);
+          ss = new ServerSocket();
+          // Per Dan Kearns suggestion (jira ODE-100), prevents excessive hanging on to socket.
+          ss.setReuseAddress(true);
+          ss.bind(new InetSocketAddress(port));
 
           break;
         } catch (IOException ioe) {