[jboss-cvs] JBoss Messaging SVN: r6685 - in trunk: src/main/org/jboss/messaging/core/remoting/impl/invm and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed May 6 05:00:48 EDT 2009


Author: timfox
Date: 2009-05-06 05:00:47 -0400 (Wed, 06 May 2009)
New Revision: 6685

Modified:
   trunk/src/main/org/jboss/messaging/core/management/DayCounterInfo.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
   trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnection.java
   trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java
   trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java
   trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/management/ReplicationAwareJMSServerControlWrapperTest.java
Log:
mainly https://jira.jboss.org/jira/browse/JBMESSAGING-1618

Modified: trunk/src/main/org/jboss/messaging/core/management/DayCounterInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/DayCounterInfo.java	2009-05-06 04:54:50 UTC (rev 6684)
+++ trunk/src/main/org/jboss/messaging/core/management/DayCounterInfo.java	2009-05-06 09:00:47 UTC (rev 6685)
@@ -69,14 +69,12 @@
       
       JSONObject json = new JSONObject(jsonString);
       JSONArray dayCounters = json.getJSONArray("dayCounters");
-      System.out.println(json.toString(2));
       DayCounterInfo[] infos = new DayCounterInfo[dayCounters.length()];
       for (int i = 0; i < dayCounters.length(); i++)
       {
          
          JSONObject counter = (JSONObject)dayCounters.get(i);
          JSONArray hour = (JSONArray)counter.getJSONArray("counters").get(0);
-         System.out.println(hour.toString(3));
          int[] hourCounters = new int[24];
          for (int j = 0; j < 24; j++)
          {

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java	2009-05-06 04:54:50 UTC (rev 6684)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java	2009-05-06 09:00:47 UTC (rev 6685)
@@ -208,7 +208,11 @@
       }
 
       public void connectionDestroyed(final Object connectionID)
-      {
+      { 
+         //Note! MUST call connection destroyed on the same thread, since server side clearup of connection
+         //resources must be synchronous or client could cause a DoS by opening and closing many connections quickly
+         listener.connectionDestroyed(connectionID);
+         
          if (connections.remove(connectionID) != null)
          {            
             //Execute on different thread to avoid deadlocks
@@ -216,7 +220,7 @@
             {
                public void run()
                {
-                  listener.connectionDestroyed(connectionID);
+                 // listener.connectionDestroyed(connectionID);
                   
                   // Remove on the other side too
                   connector.disconnect((String)connectionID);

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java	2009-05-06 04:54:50 UTC (rev 6684)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java	2009-05-06 09:00:47 UTC (rev 6685)
@@ -31,6 +31,7 @@
 import org.jboss.messaging.core.remoting.spi.Connection;
 import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
 import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.utils.Future;
 import org.jboss.messaging.utils.UUIDGenerator;
 
 /**
@@ -82,35 +83,53 @@
       listener.connectionCreated(this);
    }
 
-   public synchronized void close()
-   {
-      if (closed)
+   private volatile boolean closing;
+   
+   public void close()
+   {      
+      if (closing)
       {
          return;
       }
+      
+      closing = true;
 
-      // Must execute this on the executor, to ensure connection destroyed doesn't get fired before the last DISCONNECT
-      // packet is processed
-
-      try
-      {
-         executor.execute(new Runnable()
+      synchronized (this)
+      {         
+         // Must execute this on the executor, to ensure connection destroyed doesn't get fired before the last DISCONNECT
+         // packet is processed   
+         try
          {
-            public void run()
+            executor.execute(new Runnable()
             {
-               if (!closed)
+               public void run()
                {
-                  listener.connectionDestroyed(id);
-
-                  closed = true;
+                  if (!closed)
+                  {
+//                     log.info("calling listener connection destroyed: " + listener);
+                     listener.connectionDestroyed(id);
+   
+                     closed = true;
+                  }
                }
+            });
+            
+            Future future = new Future();
+            
+            executor.execute(future);
+            
+            boolean ok = future.await(10000);
+            
+            if (!ok)
+            {
+               log.warn("Timed out waiting to close");
             }
-         });
+         }
+         catch (RejectedExecutionException e)
+         {
+            // Ignore - this can happen if server/client is shutdown
+         }
       }
-      catch (RejectedExecutionException e)
-      {
-         // Ignore - this can happen if server/client is shutdown
-      }
    }
 
    public MessagingBuffer createBuffer(final int size)

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java	2009-05-06 04:54:50 UTC (rev 6684)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java	2009-05-06 09:00:47 UTC (rev 6685)
@@ -189,6 +189,10 @@
 
       public void connectionDestroyed(final Object connectionID)
       {
+         // Close the corresponding connection on the other side - this MUST be done on the same thread otherwise
+         // closing won't be synchronous!
+         acceptor.disconnect((String)connectionID);
+         
          if (connections.remove(connectionID) != null)
          {
             // Execute on different thread to avoid deadlocks
@@ -196,10 +200,7 @@
             {
                public void run()
                {
-                  listener.connectionDestroyed(connectionID);
-
-                  // Close the corresponding connection on the other side
-                  acceptor.disconnect((String)connectionID);
+                  listener.connectionDestroyed(connectionID);                  
                }
             }.start();
          }

Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnection.java	2009-05-06 04:54:50 UTC (rev 6684)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnection.java	2009-05-06 09:00:47 UTC (rev 6685)
@@ -77,22 +77,30 @@
       {
          return;
       }
-      
+                  
       SslHandler sslHandler = (SslHandler)channel.getPipeline().get("ssl");
       if (sslHandler != null)
       {
          try
          {
-            sslHandler.close(channel).addListener(ChannelFutureListener.CLOSE);
+            ChannelFuture sslCloseFuture = sslHandler.close(channel);
+            
+            if (!sslCloseFuture.awaitUninterruptibly(10000))
+            {
+               log.warn("Timed out waiting for ssl close future to complete");
+            }
          }
          catch (Throwable t)
          {
             // ignore
          }
       }
-      else
+      
+      ChannelFuture closeFuture = channel.close();
+      
+      if (!closeFuture.awaitUninterruptibly(10000))
       {
-         channel.close();
+         log.warn("Timed out waiting for channel to close");
       }
       
       closed = true;

Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java	2009-05-06 04:54:50 UTC (rev 6684)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java	2009-05-06 09:00:47 UTC (rev 6685)
@@ -318,7 +318,7 @@
       }
 
       bootstrap = null;
-      channelGroup.close().awaitUninterruptibly();    
+      channelGroup.close().awaitUninterruptibly();
       channelFactory = null;
 
       for (Connection connection : connections.values())

Modified: trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java	2009-05-06 04:54:50 UTC (rev 6684)
+++ trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java	2009-05-06 09:00:47 UTC (rev 6685)
@@ -433,8 +433,7 @@
             catch (Exception e)
             {
                if (destinationName == null)
-               {
-                  System.out.println("destination is null, rethrowing exception");
+               {                 
                   throw e;
                }
                // If there is no binding on naming, we will just create a new instance

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/management/ReplicationAwareJMSServerControlWrapperTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/management/ReplicationAwareJMSServerControlWrapperTest.java	2009-05-06 04:54:50 UTC (rev 6684)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/management/ReplicationAwareJMSServerControlWrapperTest.java	2009-05-06 09:00:47 UTC (rev 6685)
@@ -127,17 +127,9 @@
 
       assertEquals(1, liveServerControl.listRemoteAddresses().length);
       assertEquals(1, backupServerControl.listRemoteAddresses().length);
-      
+          
       connection.close();
 
-      // FIXME: Closing a connection should be Synchronous
-      //        Remove this loop block when https://jira.jboss.org/jira/browse/JBMESSAGING-1618 is done
-      long timeout = System.currentTimeMillis() + 5000;
-      while (timeout > System.currentTimeMillis() && liveServerControl.listRemoteAddresses().length != 0)
-      {
-         Thread.sleep(10);
-      }
-      
       assertEquals(0, liveServerControl.listRemoteAddresses().length);
       assertEquals(1, backupServerControl.listRemoteAddresses().length);
    }




More information about the jboss-cvs-commits mailing list