[jboss-remoting-commits] JBoss Remoting SVN: r5163 - remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Fri May 8 14:10:57 EDT 2009


Author: ron.sigal at jboss.com
Date: 2009-05-08 14:10:57 -0400 (Fri, 08 May 2009)
New Revision: 5163

Modified:
   remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Client.java
Log:
JBREM-1128: Changed synchronization, renamed notifyAndDisconnect() to notifyListeners(), and removed client invoker destruction from notifyListeners, all to fix a deadlock.

Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Client.java
===================================================================
--- remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Client.java	2009-05-08 08:10:00 UTC (rev 5162)
+++ remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Client.java	2009-05-08 18:10:57 UTC (rev 5163)
@@ -285,6 +285,18 @@
          {
             log.warn("value of " + Remoting.USE_CLIENT_CONNECTION_IDENTITY + " must be a String: " + o); 
          }
+         else
+         {
+            if (locator.getParameters() != null)
+            {
+               o = locator.getParameters().get(Remoting.USE_CLIENT_CONNECTION_IDENTITY);
+               if (o != null)
+               {
+                  useClientConnectionIdentity = Boolean.valueOf((String) o).booleanValue();
+                  this.configuration.put(Remoting.USE_CLIENT_CONNECTION_IDENTITY, o);
+               }
+            }
+         }
       }
       this.sessionId = new GUID().toString();
    }
@@ -389,7 +401,7 @@
     * 
     * @see org.jboss.remoting.ConnectionValidator
     */
-   public synchronized void addConnectionListener(ConnectionListener listener, Map metadata)
+   public void addConnectionListener(ConnectionListener listener, Map metadata)
    {
       if (invoker == null)
       {
@@ -405,8 +417,8 @@
          }
       }
 
-//      synchronized (connectionValidatorLock)
-//      {
+      synchronized (connectionValidatorLock)
+      {
       log.debug(this + " in addConnectionListener()");
          if (connectionValidator == null)
          {
@@ -455,18 +467,18 @@
          }
          
          connectionListeners.add(listener);
-//      }
+      }
    }
 
    /**
     * Removes specified connection listener.  Will return true if it has already been registered,
     * false otherwise.
     */
-   public synchronized boolean removeConnectionListener(ConnectionListener listener)
+   public  boolean removeConnectionListener(ConnectionListener listener)
    {
       log.debug(this + ".removeConnectionListener(" + listener + ")");
       boolean isRemoved = false;
-//      synchronized (connectionValidatorLock)
+      synchronized (connectionValidatorLock)
       {
          if (connectionValidator == null)
          {
@@ -570,7 +582,7 @@
     * ConnectionListeners of the broken connection.  At that point, the LeasePinger will be
     * destroyed, and all of the associated Clients will be disconnected. 
     */
-   public synchronized void connect(ConnectionListener listener, Map metadata) throws Exception
+   public void connect(ConnectionListener listener, Map metadata) throws Exception
    {
       log.debug(this + ".connect(" + listener + ")");
       log.debug(this + ": metadata = " + metadata);
@@ -604,45 +616,46 @@
     * remoting client.  Otherwise resource will not be cleaned up and if the target server requires
     * a lease, it will be maintained in the background.
     */
-   public synchronized void disconnect()
+   public void disconnect()
    {
       log.debug(this + " entering disconnect()");
+      
+      connected = false;
+      
       if (invoker != null)
       {
          // this is a noop if no lease is active
          invoker.terminateLease(sessionId, disconnectTimeout);
+         
+         // Need to remove myself from registry so will not keep reference to me since I am of no
+         // use now. Will have to create a new one.
+         InvokerRegistry.destroyClientInvoker(invoker.getLocator(), configuration);
+         invoker = null;
+      }
 
-//         synchronized (connectionValidatorLock)
+      synchronized (connectionValidatorLock)
+      {
+         if (connectionValidator != null)
          {
-            if (connectionValidator != null)
+            Iterator it = connectionListeners.iterator();
+            while (it.hasNext())
             {
-               Iterator it = connectionListeners.iterator();
-               while (it.hasNext())
+               ConnectionListener listener = (ConnectionListener) it.next();
+               connectionValidator.removeConnectionListener(this, listener);
+            }
+            if (connectionValidator.isStopped())
+            {
+               if (connectionValidators.remove(connectionValidatorKey) != null)
                {
-                  ConnectionListener listener = (ConnectionListener) it.next();
-                  connectionValidator.removeConnectionListener(this, listener);
+                  log.debug(this + ".disconnect() removed from static map: " + connectionValidator);
                }
-               if (connectionValidator.isStopped())
-               {
-                  if (connectionValidators.remove(connectionValidatorKey) != null)
-                  {
-                     log.debug(this + ".disconnect() removed from static map: " + connectionValidator);
-                  }
-               }
             }
-            //            connectionValidator.stop();
+            
             connectionValidator = null;
             connectionValidatorKey = null;
          }
-
-         // Need to remove myself from registry so will not keep reference to me since I am of no
-         // use now. Will have to create a new one.
-
-         InvokerRegistry.destroyClientInvoker(invoker.getLocator(), configuration);
-         invoker = null;
       }
 
-      connected = false;
    }
 
    /**
@@ -1663,12 +1676,12 @@
 
    // Package protected ----------------------------------------------------------------------------
 
-   synchronized void notifyAndDisconnect()
+   void notifyListeners()
    {
-//      synchronized (connectionValidatorLock)
+      synchronized (connectionValidatorLock)
       {
 //         disconnect();
-         log.debug(this + " entering notifyAndDisconnect(): " + connectionValidator);
+         log.debug(this + " entering notifyListeners(): " + connectionValidator);
          if (connectionValidator != null)
          {
             synchronized (connectionValidator)
@@ -1698,17 +1711,17 @@
             connectionValidatorKey = null;
          }
          
-         if (invoker != null)
-         {
-            // Need to remove myself from registry so will not keep reference to me since I am of no
-            // use now. Will have to create a new one.
+//         if (invoker != null)
+//         {
+//            // Need to remove myself from registry so will not keep reference to me since I am of no
+//            // use now. Will have to create a new one.
+//
+//            InvokerRegistry.destroyClientInvoker(invoker.getLocator(), configuration);
+//            invoker = null;
+//         }
 
-            InvokerRegistry.destroyClientInvoker(invoker.getLocator(), configuration);
-            invoker = null;
-         }
-
-         connected = false;
-         log.debug(this + " leaving notifyAndDisconnect()");
+//         connected = false;
+         log.debug(this + " leaving notifyListeners()");
       }
    }
    




More information about the jboss-remoting-commits mailing list