activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1430960 - /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/InactivityMonitor.cs
Date Wed, 09 Jan 2013 17:08:03 GMT
Author: tabish
Date: Wed Jan  9 17:08:03 2013
New Revision: 1430960

URL: http://svn.apache.org/viewvc?rev=1430960&view=rev
Log:
Fix for: https://issues.apache.org/jira/browse/AMQNET-402

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/InactivityMonitor.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/InactivityMonitor.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/InactivityMonitor.cs?rev=1430960&r1=1430959&r2=1430960&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/InactivityMonitor.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/InactivityMonitor.cs
Wed Jan  9 17:08:03 2013
@@ -141,6 +141,8 @@ namespace Apache.NMS.ActiveMQ.Transport
 				return;
 			}
 
+			CompositeTaskRunner taskRunner = this.asyncTasks;
+
 			if(!commandSent.Value)
 			{
 				Tracer.DebugFormat("InactivityMonitor[{0}]: No Message sent since last write check. Sending
a KeepAliveInfo.", instanceId);
@@ -148,8 +150,11 @@ namespace Apache.NMS.ActiveMQ.Transport
 				{
 					this.asyncWriteTask.IsPending = true;
 				}
-				
-				this.asyncTasks.Wakeup();
+
+				if (this.monitorStarted.Value && taskRunner != null) 
+				{
+					taskRunner.Wakeup();
+				}
 			}
 			else
 			{
@@ -165,6 +170,7 @@ namespace Apache.NMS.ActiveMQ.Transport
 		{
 			DateTime now = DateTime.Now;
 			TimeSpan elapsed = now - this.lastReadCheckTime;
+			CompositeTaskRunner taskRunner = this.asyncTasks;
 
 			if(!AllowReadCheck(elapsed))
 			{
@@ -188,7 +194,10 @@ namespace Apache.NMS.ActiveMQ.Transport
 					this.asyncErrorTask.IsPending = true;
 				}
 
-				this.asyncTasks.Wakeup();
+				if (this.monitorStarted.Value && taskRunner != null) 
+				{
+					taskRunner.Wakeup();
+				}
 			}
 			else
 			{
@@ -360,8 +369,7 @@ namespace Apache.NMS.ActiveMQ.Transport
 						new TimerCallback(CheckConnection),
 						null,
 						initialDelayTime,
-						writeCheckTime
-						);
+						writeCheckTime);
 				}
 			}
 		}
@@ -377,9 +385,9 @@ namespace Apache.NMS.ActiveMQ.Transport
 					if(null != connectionCheckTimer)
 					{
 						// Attempt to wait for the Timer to shutdown, but don't wait
-						// forever, if they don't shutdown after two seconds, just quit.
+						// forever, if they don't shutdown after a few seconds, just quit.
 						this.connectionCheckTimer.Dispose(shutdownEvent);
-						if(!shutdownEvent.WaitOne(TimeSpan.FromMilliseconds(3000), false))
+						if(!shutdownEvent.WaitOne(TimeSpan.FromMilliseconds(5000), false))
 						{
 							Tracer.WarnFormat("InactivityMonitor[{0}]: Timer Task didn't shutdown properly.",
instanceId);
 						}
@@ -391,7 +399,6 @@ namespace Apache.NMS.ActiveMQ.Transport
 					{
 						this.asyncTasks.RemoveTask(this.asyncWriteTask);
 						this.asyncTasks.RemoveTask(this.asyncErrorTask);
-
 						this.asyncTasks.Shutdown();
 						this.asyncTasks = null;
 					}



Mime
View raw message