logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1166569 - /logging/log4net/trunk/src/Appender/MemoryAppender.cs
Date Thu, 08 Sep 2011 08:27:31 GMT
Author: bodewig
Date: Thu Sep  8 08:27:31 2011
New Revision: 1166569

URL: http://svn.apache.org/viewvc?rev=1166569&view=rev
Log:
Make MemoryAppender thread-safe - at least as safe as we can without breaking BWC.  Patch
by Steve Glendinning.  LOG4NET-167

Modified:
    logging/log4net/trunk/src/Appender/MemoryAppender.cs

Modified: logging/log4net/trunk/src/Appender/MemoryAppender.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/Appender/MemoryAppender.cs?rev=1166569&r1=1166568&r2=1166569&view=diff
==============================================================================
--- logging/log4net/trunk/src/Appender/MemoryAppender.cs (original)
+++ logging/log4net/trunk/src/Appender/MemoryAppender.cs Thu Sep  8 08:27:31 2011
@@ -76,7 +76,10 @@ namespace log4net.Appender
 		/// </remarks>
 		virtual public LoggingEvent[] GetEvents()
 		{
-			return (LoggingEvent[])m_eventsList.ToArray(typeof(LoggingEvent));
+            lock (m_eventsList.SyncRoot)
+            {
+                return (LoggingEvent[]) m_eventsList.ToArray(typeof(LoggingEvent));
+            }
 		}
 
 		/// <summary>
@@ -147,7 +150,10 @@ namespace log4net.Appender
 			// volatile data in the event.
 			loggingEvent.Fix = this.Fix;
 
-			m_eventsList.Add(loggingEvent);
+            lock (m_eventsList.SyncRoot)
+            {
+                m_eventsList.Add(loggingEvent);
+            }
 		} 
 
 		#endregion Override implementation of AppenderSkeleton
@@ -162,7 +168,10 @@ namespace log4net.Appender
 		/// </remarks>
 		virtual public void Clear()
 		{
-			m_eventsList.Clear();
+            lock (m_eventsList.SyncRoot)
+            {
+                m_eventsList.Clear();
+            }
 		}
 
 		#endregion Public Instance Methods



Mime
View raw message