Bugzilla bug #64471: need to use the value of the 'xferred' argument when
authorwtc%netscape.com
Thu, 11 Jan 2001 05:17:52 +0000
changeset 1664 8438fdd496443c808b52578c1d96d06e3a56fea6
parent 1662 14d8685c7f644a24c69531d53cecc9f70f8a15e7
child 1667 172a06dedf4136efabfab57197bb9d7424107d3c
push idunknown
push userunknown
push dateunknown
bugs64471
Bugzilla bug #64471: need to use the value of the 'xferred' argument when sendfilev fails with EAGAIN/EWOULDBLOCK.
pr/src/pthreads/ptio.c
--- a/pr/src/pthreads/ptio.c
+++ b/pr/src/pthreads/ptio.c
@@ -1003,27 +1003,30 @@ static PRBool pt_hpux_sendfile_cont(pt_C
 #ifdef SOLARIS  
 static PRBool pt_solaris_sendfile_cont(pt_Continuation *op, PRInt16 revents)
 {
     struct sendfilevec *vec = (struct sendfilevec *) op->arg2.buffer;
     size_t xferred;
     ssize_t count;
 
     count = SOLARIS_SENDFILEV(op->arg1.osfd, vec, op->arg3.amount, &xferred);
-    PR_ASSERT(count <= op->nbytes_to_send);
+    PR_ASSERT((count == -1) || (count == xferred));
+    PR_ASSERT(xferred <= op->nbytes_to_send);
     op->syserrno = errno;
 
-    if (count != -1) {
-        op->result.code += count;
-    } else if (op->syserrno != EWOULDBLOCK && op->syserrno != EAGAIN) {
-        op->result.code = -1;
-    } else {
-        return PR_FALSE;
+    if (count == -1) {
+        if (op->syserrno != EWOULDBLOCK && op->syserrno != EAGAIN) {
+            op->result.code = -1;
+            return PR_TRUE;
+        }
+        count = xferred;
     }
-    if (count != -1 && count < op->nbytes_to_send) {
+    
+    op->result.code += count;
+    if (count < op->nbytes_to_send) {
         op->nbytes_to_send -= count;
 
         while (count >= vec->sfv_len) {
             count -= vec->sfv_len;
             vec++;
             op->arg3.amount--;
         }
         PR_ASSERT(op->arg3.amount > 0);
@@ -2247,20 +2250,19 @@ static PRInt32 pt_SolarisSendFile(PRFile
      */
     count = SOLARIS_SENDFILEV(sd->secret->md.osfd, sfv_struct,
             sfvcnt, &xferred);
 
     PR_ASSERT((count == -1) || (count == xferred));
 
     if (count == -1) {
         syserrno = errno;
-        if (syserrno == EINTR) {
+        if (syserrno == EINTR
+                || syserrno == EAGAIN || syserrno == EWOULDBLOCK) {
             count = xferred;
-        } else if (syserrno == EAGAIN || syserrno == EWOULDBLOCK) {
-            count = 0;
         }
     }
 
     if (count != -1 && count < nbytes_to_send) {
         pt_Continuation op;
         struct sendfilevec *vec = sfv_struct;
         PRInt32 rem = count;