[jboss-cvs] JBossAS SVN: r63223 - branches/JBoss_4_0_5_GA_CP/messaging/src/main/org/jboss/mq.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon May 28 06:07:45 EDT 2007


Author: tkimura at redhat.com
Date: 2007-05-28 06:07:45 -0400 (Mon, 28 May 2007)
New Revision: 63223

Modified:
   branches/JBoss_4_0_5_GA_CP/messaging/src/main/org/jboss/mq/Connection.java
Log:
ASPATCH-218: Race condition in Connection.close() can deadlock the JBossMQ's ping thread.


Modified: branches/JBoss_4_0_5_GA_CP/messaging/src/main/org/jboss/mq/Connection.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/messaging/src/main/org/jboss/mq/Connection.java	2007-05-28 09:36:30 UTC (rev 63222)
+++ branches/JBoss_4_0_5_GA_CP/messaging/src/main/org/jboss/mq/Connection.java	2007-05-28 10:07:45 UTC (rev 63223)
@@ -1282,14 +1282,20 @@
 	 */
    class PingTask implements Runnable
    {
-      /**
-		 * Main processing method for the PingTask object
-		 */
       public void run()
       {
+         // Don't bother if we are closing
+         if (closing.get())
+            return;
+         
          try
          {
-            pingTaskSemaphore.acquire();
+            // If we can't aquire the semaphore then it
+            // almost certainly means the close has got it
+            // Try for 10 seconds to make sure the problem
+            // is not just a long garbage collection that has suspended threads
+            if (pingTaskSemaphore.attempt(1000 * 10) == false)
+               return;
          }
          catch (InterruptedException e)
          {




More information about the jboss-cvs-commits mailing list