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 2011/09/29 20:47:54 UTC

svn commit: r1177396 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk: ./ src/main/csharp/MessageConsumer.cs src/main/csharp/Session.cs

Author: jgomes
Date: Thu Sep 29 18:47:53 2011
New Revision: 1177396

URL: http://svn.apache.org/viewvc?rev=1177396&view=rev
Log:
Merged revision(s) 1177395 from activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x:
Add lock of SyncRoot when iterating over the consumers list.
Fixes [AMQNET-342]. (See https://issues.apache.org/jira/browse/AMQNET-342)

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/   (props changed)
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs

Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 29 18:47:53 2011
@@ -1,3 +1,3 @@
-/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x:1082291,1135831,1137081,1171843,1171874,1177390
+/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.5.x:1082291,1135831,1137081,1171843,1171874,1177390,1177395
 /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/tags/1.0.0:692591,693525
 /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/tags/1.1.0:788230,788233,790183

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs?rev=1177396&r1=1177395&r2=1177396&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs Thu Sep 29 18:47:53 2011
@@ -228,7 +228,7 @@ namespace Apache.NMS.ActiveMQ
 
 				bool wasStarted = this.session.Started;
 
-				if(wasStarted == true)
+				if(wasStarted)
 				{
 					this.session.Stop();
 				}
@@ -236,7 +236,7 @@ namespace Apache.NMS.ActiveMQ
 				listener += value;
 				this.session.Redispatch(this.unconsumedMessages);
 
-				if(wasStarted == true)
+				if(wasStarted)
 				{
 					this.session.Start();
 				}

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs?rev=1177396&r1=1177395&r2=1177396&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Session.cs Thu Sep 29 18:47:53 2011
@@ -815,10 +815,13 @@ namespace Apache.NMS.ActiveMQ
 
         public void Start()
         {
-            foreach(MessageConsumer consumer in this.consumers.Values)
-            {
-                consumer.Start();
-            }
+			lock(this.consumers.SyncRoot)
+			{
+				foreach(MessageConsumer consumer in this.consumers.Values)
+				{
+					consumer.Start();
+				}
+			}
 
             if(this.executor != null)
             {
@@ -968,13 +971,16 @@ namespace Apache.NMS.ActiveMQ
 
         internal bool IsInUse(ActiveMQTempDestination dest)
         {
-            foreach(MessageConsumer consumer in this.consumers.Values)
-            {
-                if(consumer.IsInUse(dest))
-                {
-                    return true;
-                }
-            }
+			lock(this.consumers.SyncRoot)
+			{
+				foreach(MessageConsumer consumer in this.consumers.Values)
+				{
+					if(consumer.IsInUse(dest))
+					{
+						return true;
+					}
+				}
+			}
 
             return false;
         }