Minor logging improvement

This commit is contained in:
Tal Aloni 2017-03-29 12:32:20 +03:00
parent cd07f7cbe7
commit 210f522b29

View file

@ -160,19 +160,28 @@ namespace SMBLibrary.Server
} }
catch (ObjectDisposedException) catch (ObjectDisposedException)
{ {
state.LogToServer(Severity.Debug, "The connection was terminated");
m_connectionManager.ReleaseConnection(state); m_connectionManager.ReleaseConnection(state);
return; return;
} }
catch (SocketException) catch (SocketException ex)
{ {
const int WSAECONNRESET = 10054;
if (ex.ErrorCode == WSAECONNRESET)
{
state.LogToServer(Severity.Debug, "The connection was forcibly closed by the remote host");
}
else
{
state.LogToServer(Severity.Debug, "The connection was terminated, Socket error code: {0}", ex.ErrorCode);
}
m_connectionManager.ReleaseConnection(state); m_connectionManager.ReleaseConnection(state);
return; return;
} }
if (numberOfBytesReceived == 0) if (numberOfBytesReceived == 0)
{ {
// The other side has closed the connection state.LogToServer(Severity.Debug, "The client closed the connection");
state.LogToServer(Severity.Debug, "The other side closed the connection");
m_connectionManager.ReleaseConnection(state); m_connectionManager.ReleaseConnection(state);
return; return;
} }