Mike Kaplinskiy : ws2_32: Fix up iovecs after transmission in WS2_send instead of WS2_sendto.

Alexandre Julliard julliard at winehq.org
Mon Jan 24 11:07:38 CST 2011


Module: wine
Branch: master
Commit: 388398bd057c6292414f5b875c58b59d765a2562
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=388398bd057c6292414f5b875c58b59d765a2562

Author: Mike Kaplinskiy <mike.kaplinskiy at gmail.com>
Date:   Mon Jan 24 00:19:12 2011 -0500

ws2_32: Fix up iovecs after transmission in WS2_send instead of WS2_sendto.

---

 dlls/ws2_32/socket.c |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 43d4598..6b3925b 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -1725,6 +1725,7 @@ static int WS2_send( int fd, struct ws2_async *wsa )
 {
     struct msghdr hdr;
     union generic_unix_sockaddr unix_addr;
+    int n, ret;
 
     hdr.msg_name = NULL;
     hdr.msg_namelen = 0;
@@ -1768,7 +1769,19 @@ static int WS2_send( int fd, struct ws2_async *wsa )
     hdr.msg_flags = 0;
 #endif
 
-    return sendmsg(fd, &hdr, wsa->flags);
+    ret = sendmsg(fd, &hdr, wsa->flags);
+    if (ret >= 0)
+    {
+        n = ret;
+        while (wsa->first_iovec < wsa->n_iovecs && wsa->iovec[wsa->first_iovec].iov_len <= n)
+            n -= wsa->iovec[wsa->first_iovec++].iov_len;
+        if (wsa->first_iovec < wsa->n_iovecs)
+        {
+            wsa->iovec[wsa->first_iovec].iov_base = (char*)wsa->iovec[wsa->first_iovec].iov_base + n;
+            wsa->iovec[wsa->first_iovec].iov_len -= n;
+        }
+    }
+    return ret;
 }
 
 /***********************************************************************
@@ -3942,23 +3955,13 @@ static int WS2_sendto( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
          * sending blocks until the entire buffer is sent. */
         DWORD timeout_start = GetTickCount();
 
-        *lpNumberOfBytesSent = 0;
+        *lpNumberOfBytesSent = n == -1 ? 0 : n;
 
-        while (wsa->first_iovec < dwBufferCount)
+        while (wsa->first_iovec < wsa->n_iovecs)
         {
             struct pollfd pfd;
             int timeout = GET_SNDTIMEO(fd);
 
-            if (n >= 0)
-            {
-                *lpNumberOfBytesSent += n;
-                while (wsa->first_iovec < dwBufferCount && wsa->iovec[wsa->first_iovec].iov_len <= n)
-                    n -= wsa->iovec[wsa->first_iovec++].iov_len;
-                if (wsa->first_iovec >= dwBufferCount) break;
-                wsa->iovec[wsa->first_iovec].iov_base = (char*)wsa->iovec[wsa->first_iovec].iov_base + n;
-                wsa->iovec[wsa->first_iovec].iov_len -= n;
-            }
-
             if (timeout != -1)
             {
                 timeout -= GetTickCount() - timeout_start;
@@ -3980,6 +3983,9 @@ static int WS2_sendto( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
                 err = wsaErrno();
                 goto error;
             }
+
+            if (n >= 0)
+                *lpNumberOfBytesSent += n;
         }
     }
     else  /* non-blocking */




More information about the wine-cvs mailing list