You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jg...@apache.org on 2014/04/23 02:03:25 UTC
svn commit: r1589320 - in
/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x: ./
src/main/csharp/Transport/Tcp/TcpTransport.cs
Author: jgomes
Date: Wed Apr 23 00:03:25 2014
New Revision: 1589320
URL: http://svn.apache.org/r1589320
Log:
Merged revision(s) 1550241 from activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk:
Move the blocking code outside of the lock section to avoid race condition when shutting down.
Fixes [AMQNET-338]. (See https://issues.apache.org/jira/browse/AMQNET-338)
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/ (props changed)
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/src/main/csharp/Transport/Tcp/TcpTransport.cs
Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/
------------------------------------------------------------------------------
Merged /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk:r1550241
Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/src/main/csharp/Transport/Tcp/TcpTransport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/src/main/csharp/Transport/Tcp/TcpTransport.cs?rev=1589320&r1=1589319&r2=1589320&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/src/main/csharp/Transport/Tcp/TcpTransport.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.6.x/src/main/csharp/Transport/Tcp/TcpTransport.cs Wed Apr 23 00:03:25 2014
@@ -188,6 +188,8 @@ namespace Apache.NMS.ActiveMQ.Transport.
public void Close()
{
+ Thread theReadThread = null;
+
lock(myLock)
{
if(closed.CompareAndSet(false, true))
@@ -238,20 +240,27 @@ namespace Apache.NMS.ActiveMQ.Transport.
{
}
- if(null != readThread)
+ theReadThread = this.readThread;
+ this.readThread = null;
+ this.started = false;
+ }
+ }
+
+ // Don't block on closing the read thread within the lock scope.
+ if(null != theReadThread)
+ {
+ try
+ {
+ if(Thread.CurrentThread != theReadThread && theReadThread.IsAlive)
{
- if(Thread.CurrentThread != readThread && readThread.IsAlive)
+ if(!theReadThread.Join((int) MAX_THREAD_WAIT.TotalMilliseconds))
{
- if(!readThread.Join((int) MAX_THREAD_WAIT.TotalMilliseconds))
- {
- readThread.Abort();
- }
+ theReadThread.Abort();
}
-
- readThread = null;
}
-
- started = false;
+ }
+ catch
+ {
}
}
}