[jboss-jira] [JBoss JIRA] Updated: (JBAS-4525) JBossMQ WriteTask in UIL2 could block forever
Adrian Brock (JIRA)
jira-events at lists.jboss.org
Mon Jul 9 12:32:31 EDT 2007
[ http://jira.jboss.com/jira/browse/JBAS-4525?page=all ]
Adrian Brock updated JBAS-4525:
-------------------------------
Description:
The JBossMQ UIL2 WriteTask shutdowns when it is signaled by the ReadTask using an Thread.interrupt().
If however, something "eats" that interrupt status of the thread then the WriteTask will block forever and never stop.
This leads to thread leaks.
The solution is not to wait forever for an interrupt. Instead the thread should periodically wake up
and check the "started" flag. e.g. Here is the suggest patch in outline
while (true)
{
+ synchronized (running)
+ {
+ if (WriteState != Started)
+ break;
+ }
BaseMsg msg = null;
try
{
- msg = (BaseMsg) sendQueue.take();
+ // Only wait for 10 seconds
+ msg = (BaseMsg) sendQueue.poll(10000l);
+ if (msg == null)
+ continue; // re-start the loop when no message after 10 seconds
was:
The JBossMQ UIL2 WriteTask shutdowns when it is signaled by the ReadTask using an Thread.interrupt().
If however, something "eats" that interrupt status of the thread then the WriteTask will block forever and never stop.
This leads to thread leaks.
The solution is not wait forever or an interrupt. Instead the thread should periodically wake up
and check the "started" flag. e.g. Here is the suggest patch in outline
while (true)
{
+ synchronized (running)
+ {
+ if (WriteState != Started)
+ break;
+ }
BaseMsg msg = null;
try
{
- msg = (BaseMsg) sendQueue.take();
+ // Only wait for 10 seconds
+ msg = (BaseMsg) sendQueue.poll(10000l);
+ if (msg == null)
+ continue; // re-start the loop when no message after 10 seconds
> JBossMQ WriteTask in UIL2 could block forever
> ---------------------------------------------
>
> Key: JBAS-4525
> URL: http://jira.jboss.com/jira/browse/JBAS-4525
> Project: JBoss Application Server
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: JMS service
> Affects Versions: JBossAS-4.2.1.GA
> Reporter: Adrian Brock
> Assigned To: Adrian Brock
> Fix For: JBossAS-5.0.0.GA, JBossAS-4.2.2.CR1
>
>
> The JBossMQ UIL2 WriteTask shutdowns when it is signaled by the ReadTask using an Thread.interrupt().
> If however, something "eats" that interrupt status of the thread then the WriteTask will block forever and never stop.
> This leads to thread leaks.
> The solution is not to wait forever for an interrupt. Instead the thread should periodically wake up
> and check the "started" flag. e.g. Here is the suggest patch in outline
> while (true)
> {
> + synchronized (running)
> + {
> + if (WriteState != Started)
> + break;
> + }
> BaseMsg msg = null;
> try
> {
> - msg = (BaseMsg) sendQueue.take();
> + // Only wait for 10 seconds
> + msg = (BaseMsg) sendQueue.poll(10000l);
> + if (msg == null)
> + continue; // re-start the loop when no message after 10 seconds
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list