Author: alanmc
Date: 2007-12-22 20:14:29 -0500 (Sat, 22 Dec 2007)
New Revision: 91818

Modified:
   trunk/bitsharp/src/MonoTorrent/Client/Managers/ConnectionManager.cs
Log:
if a socket returns 0 bytes it is an error condition.

Modified: trunk/bitsharp/src/MonoTorrent/Client/Managers/ConnectionManager.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent/Client/Managers/ConnectionManager.cs 
2007-12-22 23:42:02 UTC (rev 91817)
+++ trunk/bitsharp/src/MonoTorrent/Client/Managers/ConnectionManager.cs 
2007-12-23 01:14:29 UTC (rev 91818)
@@ -359,7 +359,7 @@
 
                         // If we receive 0 bytes, the connection has been 
closed, so exit
                         int bytesReceived = 
id.Peer.Connection.EndReceive(result, out id.ErrorCode);
-                        if (id.ErrorCode != SocketError.Success)
+                        if (id.ErrorCode != SocketError.Success || 
bytesReceived == 0)
                         {
                             reason = "EndReceiveMessage: " + 
id.ErrorCode.ToString();
                             Logger.Log(id, "Couldn't receive message");
@@ -426,7 +426,7 @@
 
                         // If we have sent zero bytes, that is a sign the 
connection has been closed
                         int bytesSent = id.Peer.Connection.EndSend(result, out 
id.ErrorCode);
-                        if (id.ErrorCode != SocketError.Success)
+                        if (id.ErrorCode != SocketError.Success || bytesSent 
== 0)
                         {
                             reason = "Sending error: " + 
id.ErrorCode.ToString();
                             Logger.Log(id, "Couldn't send message");

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to