[jboss-cvs] JBossAS SVN: r70903 - branches/JBPAPP_4_2_0_GA_CP02_JBPAPP-684/messaging/src/main/org/jboss/mq/il/uil2.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 17 07:19:18 EDT 2008
Author: darran.lofthouse at jboss.com
Date: 2008-03-17 07:19:18 -0400 (Mon, 17 Mar 2008)
New Revision: 70903
Modified:
branches/JBPAPP_4_2_0_GA_CP02_JBPAPP-684/messaging/src/main/org/jboss/mq/il/uil2/SocketManager.java
Log:
[JBPAPP-684] JBossMQ WriteTask in UIL2 could block forever.
Modified: branches/JBPAPP_4_2_0_GA_CP02_JBPAPP-684/messaging/src/main/org/jboss/mq/il/uil2/SocketManager.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP02_JBPAPP-684/messaging/src/main/org/jboss/mq/il/uil2/SocketManager.java 2008-03-17 11:13:11 UTC (rev 70902)
+++ branches/JBPAPP_4_2_0_GA_CP02_JBPAPP-684/messaging/src/main/org/jboss/mq/il/uil2/SocketManager.java 2008-03-17 11:19:18 UTC (rev 70903)
@@ -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