]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
In emulate_sendfile(), handle APR_EAGAIN from apr_socket_send().
authorWilfredo Sanchez <wsanchez@apache.org>
Thu, 7 Apr 2005 00:22:29 +0000 (00:22 +0000)
committerWilfredo Sanchez <wsanchez@apache.org>
Thu, 7 Apr 2005 00:22:29 +0000 (00:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@160348 13f79535-47bb-0310-9956-ffa450edef68

server/core_filters.c

index e9505d64bb08daf43e8deac8662a6f7f61e3add1..df35563d53700d8a9791faa44e19dcfe3e5cd192 100644 (file)
@@ -520,14 +520,16 @@ static apr_status_t emulate_sendfile(core_net_rec *c, apr_file_t *fd,
         sendlen = togo > sizeof(buffer) ? sizeof(buffer) : togo;
         o = 0;
         rv = apr_file_read(fd, buffer, &sendlen);
-        while (rv == APR_SUCCESS && sendlen) {
-            bytes_sent = sendlen;
-            rv = apr_socket_send(c->client_socket, &buffer[o], &bytes_sent);
-            *nbytes += bytes_sent;
-            if (rv == APR_SUCCESS) {
-                sendlen -= bytes_sent; /* sendlen != bytes_sent ==> partial write */
-                o += bytes_sent;       /* o is where we are in the buffer */
-                togo -= bytes_sent;    /* track how much of the file we've sent */
+        if (rv == APR_SUCCESS && sendlen) {
+            while ((rv == APR_SUCCESS || rv == APR_EAGAIN) && sendlen) {
+                bytes_sent = sendlen;
+                rv = apr_socket_send(c->client_socket, &buffer[o], &bytes_sent);
+                *nbytes += bytes_sent;
+                if (rv == APR_SUCCESS) {
+                    sendlen -= bytes_sent; /* sendlen != bytes_sent ==> partial write */
+                    o += bytes_sent;       /* o is where we are in the buffer */
+                    togo -= bytes_sent;    /* track how much of the file we've sent */
+                }
             }
         }
     }