From: Wilfredo Sanchez Date: Thu, 7 Apr 2005 00:22:29 +0000 (+0000) Subject: In emulate_sendfile(), handle APR_EAGAIN from apr_socket_send(). X-Git-Tag: 2.1.5~236 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d2733dd5193f664f707d9857d02f9435f9cae03;p=thirdparty%2Fapache%2Fhttpd.git In emulate_sendfile(), handle APR_EAGAIN from apr_socket_send(). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@160348 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/core_filters.c b/server/core_filters.c index e9505d64bb0..df35563d537 100644 --- a/server/core_filters.c +++ b/server/core_filters.c @@ -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 */ + } } } }