Details
-
Bug
-
Resolution: Done
-
Major
-
JBossAS-3.2.8.SP1, JBossAS-4.0.5.GA, JBossAS-5.0.0.Beta1
-
None
Description
There is a race condition between the JBossMQ ping thread and connection.close()
that can cause the ping thread to become deadlocked.
Besides meaning that the ping stops working so broken connections are not detected,
this can also evenutally lead to a memory leak.
The problem occurs when the connection.close()
requests to cancel the ping for that connection, and then aquires the semaphore
to make sure the ping has stopped working.
Just at that moment, the ping was scheduled to run and tries to aquire the semaphore
(with no timeout), but it never can because the connection.close() has permenantly
aquired it.
The obvious fix is to include a timeout in the ping task such that when it fails
to acquire the semaphore it can assume that the connection was closed and return
immediately.
Additionally, checking the "closing" flag should also avoid even trying to acquire
the semaphore when the connection is being closed (in most cases).