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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 14 15:27:31 EST 2007


Author: jhowell at redhat.com
Date: 2007-11-14 15:27:31 -0500 (Wed, 14 Nov 2007)
New Revision: 67095

Modified:
   branches/JBoss_4_0_5_GA_CP/messaging/src/main/org/jboss/mq/il/uil2/SocketManager.java
Log:
[ASPATCH-321] - Port JBAS-4225 to 4.0.5 CP - JBossMQ WriteTask in UIL2 could block forever

Modified: branches/JBoss_4_0_5_GA_CP/messaging/src/main/org/jboss/mq/il/uil2/SocketManager.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/messaging/src/main/org/jboss/mq/il/uil2/SocketManager.java	2007-11-14 20:26:35 UTC (rev 67094)
+++ branches/JBoss_4_0_5_GA_CP/messaging/src/main/org/jboss/mq/il/uil2/SocketManager.java	2007-11-14 20:27:31 UTC (rev 67095)
@@ -142,8 +142,30 @@
          running.set(true);
       }
 
-      readThread.start();
-      writeThread.start();
+      try
+      {
+         readThread.start();
+         writeThread.start();
+      }
+      catch (Throwable t)
+      {
+         try
+         {
+            stop();
+         }
+         catch (Throwable ignored)
+         {
+         }
+         
+         try
+         {
+            socket.close();
+         }
+         catch (Throwable ignored)
+         {
+         }
+         log.warn("Error starting socket manager threads", t);
+      }
    }
 
    /** Stop the read and write threads by interrupting them.
@@ -513,9 +535,17 @@
          while (true)
          {
             BaseMsg msg = null;
+            
+            synchronized (running)
+            {
+               if (writeState != STARTED)
+                  break;
+            }
             try
             {
-               msg = (BaseMsg) sendQueue.take();
+               msg = (BaseMsg) sendQueue.poll(10000l);
+               if (msg == null)
+                  continue; // Check for stop if no message for 10 seconds
                if (trace)
                   log.trace("Write msg: " + msg);
                msg.write(out);




More information about the jboss-cvs-commits mailing list