[jboss-cvs] JBossAS SVN: r71007 - branches/JBPAPP_4_2_0_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 Mar 19 11:18:26 EDT 2008


Author: darran.lofthouse at jboss.com
Date: 2008-03-19 11:18:26 -0400 (Wed, 19 Mar 2008)
New Revision: 71007

Modified:
   branches/JBPAPP_4_2_0_GA_CP/messaging/src/main/org/jboss/mq/il/uil2/SocketManager.java
Log:
[JBPAPP-685] JBossMQ WriteTask in UIL2 could block forever.

Modified: branches/JBPAPP_4_2_0_GA_CP/messaging/src/main/org/jboss/mq/il/uil2/SocketManager.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/messaging/src/main/org/jboss/mq/il/uil2/SocketManager.java	2008-03-19 15:09:11 UTC (rev 71006)
+++ branches/JBPAPP_4_2_0_GA_CP/messaging/src/main/org/jboss/mq/il/uil2/SocketManager.java	2008-03-19 15:18:26 UTC (rev 71007)
@@ -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