Author: gonzalo
Date: 2005-04-18 23:14:02 -0400 (Mon, 18 Apr 2005)
New Revision: 43235

Modified:
   trunk/mcs/class/System/System.Net.Sockets/ChangeLog
   trunk/mcs/class/System/System.Net.Sockets/Socket.cs
Log:
2005-04-18 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

        * Socket.cs: Begin/End Send/SendTo guarantee that all bytes are written
        or an exception is thrown. Fixes bug #74475.



Modified: trunk/mcs/class/System/System.Net.Sockets/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net.Sockets/ChangeLog 2005-04-19 01:10:26 UTC 
(rev 43234)
+++ trunk/mcs/class/System/System.Net.Sockets/ChangeLog 2005-04-19 03:14:02 UTC 
(rev 43235)
@@ -1,3 +1,8 @@
+2005-04-18 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+       * Socket.cs: Begin/End Send/SendTo guarantee that all bytes are written
+       or an exception is thrown. Fixes bug #74475.
+
 2005-04-17 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
        * Socket.cs: no need for locking in Worker. The actual read / write for

Modified: trunk/mcs/class/System/System.Net.Sockets/Socket.cs
===================================================================
--- trunk/mcs/class/System/System.Net.Sockets/Socket.cs 2005-04-19 01:10:26 UTC 
(rev 43234)
+++ trunk/mcs/class/System/System.Net.Sockets/Socket.cs 2005-04-19 03:14:02 UTC 
(rev 43235)
@@ -78,7 +78,7 @@
                        bool completed_sync;
                        bool completed;
                        bool blocking;
-                       int error;
+                       internal int error;
                        SocketOperation operation;
                        object ares;
 
@@ -228,9 +228,8 @@
                        }
 
                        public int Total {
-                               get {
-                                       return total;
-                               }
+                               get { return total; }
+                               set { total = value; }
                        }
                }
 
@@ -292,9 +291,29 @@
                                result.Complete (total);
                        }
 
+                       int send_so_far;
+
+                       void UpdateSendValues (int last_sent)
+                       {
+                               if (result.error == 0) {
+                                       send_so_far += last_sent;
+                                       result.Offset += last_sent;
+                                       result.Size -= last_sent;
+                               }
+                       }
+
                        public void Send ()
                        {
                                // Actual send() done in the runtime
+                               if (result.error == 0) {
+                                       UpdateSendValues (result.Total);
+                                       if (result.Size > 0) {
+                                               SocketAsyncCall sac = new 
SocketAsyncCall (this.Send);
+                                               sac.BeginInvoke (null, result);
+                                               return; // Have to finish 
writing everything. See bug #74475.
+                                       }
+                                       result.Total = send_so_far;
+                               }
                                result.Complete ();
                        }
 
@@ -307,12 +326,20 @@
                                                                    result.Size,
                                                                    
result.SockFlags,
                                                                    
result.EndPoint);
+
+                                       UpdateSendValues (total);
+                                       if (result.Size > 0) {
+                                               SocketAsyncCall sac = new 
SocketAsyncCall (this.SendTo);
+                                               sac.BeginInvoke (null, result);
+                                               return; // Have to finish 
writing everything. See bug #74475.
+                                       }
+                                       result.Total = send_so_far;
                                } catch (Exception e) {
                                        result.Complete (e);
                                        return;
                                }
 
-                               result.Complete (total);
+                               result.Complete ();
                        }
                }
                        

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

Reply via email to