nicko 2005/01/23 19:39:59
Modified: src/Appender TelnetAppender.cs
Log:
Added check to only send events if the handler currently has open connections
Revision Changes Path
1.4 +30 -3 logging-log4net/src/Appender/TelnetAppender.cs
Index: TelnetAppender.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Appender/TelnetAppender.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TelnetAppender.cs 17 Jan 2005 20:18:42 -0000 1.3
+++ TelnetAppender.cs 24 Jan 2005 03:39:59 -0000 1.4
@@ -186,7 +186,7 @@
/// </remarks>
protected override void Append(LoggingEvent loggingEvent)
{
- if (m_handler != null)
+ if (m_handler != null && m_handler.HasConnections)
{
m_handler.Send(RenderLoggingEvent(loggingEvent));
}
@@ -381,6 +381,29 @@
m_clients = clientsCopy;
}
}
+
+ /// <summary>
+ /// Test if this handler has active connections
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this handler has active connections
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This property will be <c>true</c> while this
handler has
+ /// active connections, that is at least one connection
that
+ /// the handler will attempt to send a message to.
+ /// </para>
+ /// </remarks>
+ public bool HasConnections
+ {
+ get
+ {
+ ArrayList localClients = m_clients;
+
+ return (localClients != null &&
localClients.Count > 0);
+ }
+ }
/// <summary>
/// Callback used to accept a connection on the server
socket
@@ -459,13 +482,17 @@
{
localSocket.Shutdown(SocketShutdown.Both);
}
- catch { }
+ catch
+ {
+ }
try
{
localSocket.Close();
}
- catch { }
+ catch
+ {
+ }
}
#endregion