diff options
author | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2000-07-07 03:00:44 +0000 |
---|---|---|
committer | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2000-07-07 03:00:44 +0000 |
commit | be95ef38abbf6a2c1e2ad59bd426445dcfb631ef (patch) | |
tree | 689d6256f51e191ccc80076ddfafe541e8414f29 /network_io | |
parent | 2a8ef05436b45a994eb41c27f5ae54139d816320 (diff) | |
download | libapr-be95ef38abbf6a2c1e2ad59bd426445dcfb631ef.tar.gz |
ap_sendfile() fixes:
Linux flavor: get it working with non-blocking sockets which
don't have a timeout
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@60311 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r-- | network_io/unix/sendrecv.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/network_io/unix/sendrecv.c b/network_io/unix/sendrecv.c index 3d749e0fe..159359591 100644 --- a/network_io/unix/sendrecv.c +++ b/network_io/unix/sendrecv.c @@ -218,7 +218,7 @@ ap_status_t ap_sendfile(ap_socket_t *sock, ap_file_t *file, { off_t off = *offset; int corkflag = 1; - int rv, nbytes = 0; + int rv, nbytes = 0, total_hdrbytes, i; ap_status_t arv; /* Ignore flags for now. */ @@ -241,6 +241,21 @@ ap_status_t ap_sendfile(ap_socket_t *sock, ap_file_t *file, return errno; } nbytes += hdrbytes; + + /* If this was a partial write and we aren't doing timeouts, + * return now with the partial byte count; this is a non-blocking + * socket. + */ + if (sock->timeout <= 0) { + total_hdrbytes = 0; + for (i = 0; i < hdtr->numheaders; i++) { + total_hdrbytes += hdtr->headers[i].iov_len; + } + if (hdrbytes < total_hdrbytes) { + *len = hdrbytes; + return APR_SUCCESS; + } + } } do { @@ -276,6 +291,15 @@ ap_status_t ap_sendfile(ap_socket_t *sock, ap_file_t *file, nbytes += rv; + /* If this was a partial write, return now with the partial byte count; + * this is a non-blocking socket. + */ + + if (rv < *len) { + *len = nbytes; + return APR_SUCCESS; + } + /* Now write the footers */ if (hdtr->numtrailers > 0) { ap_int32_t trbytes; |