[jboss-cvs] JBossAS SVN: r63945 - trunk/jbossmq/src/main/org/jboss/mq/il/uil2.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 10 11:59:50 EDT 2007


Author: adrian at jboss.org
Date: 2007-07-10 11:59:50 -0400 (Tue, 10 Jul 2007)
New Revision: 63945

Modified:
   trunk/jbossmq/src/main/org/jboss/mq/il/uil2/SocketManager.java
Log:
Port JBAS-4525 and JBAS-4526 from jboss-4.2

Modified: trunk/jbossmq/src/main/org/jboss/mq/il/uil2/SocketManager.java
===================================================================
--- trunk/jbossmq/src/main/org/jboss/mq/il/uil2/SocketManager.java	2007-07-10 15:58:24 UTC (rev 63944)
+++ trunk/jbossmq/src/main/org/jboss/mq/il/uil2/SocketManager.java	2007-07-10 15:59:50 UTC (rev 63945)
@@ -1,24 +1,24 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.mq.il.uil2;
 
 import java.io.IOException;
@@ -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