brianp 02/04/10 20:15:47
Modified: network_io/unix sendrecv.c
Log:
Solaris version of the code that inserts a select before the
next sendfilev call if the last one returned EAGAIN, plus a
fix for a bug in the apr_send() and apr_sendv() logic (I was
never unsetting the APR_INCOMPLETE_WRITE flag)
Revision Changes Path
1.80 +21 -0 apr/network_io/unix/sendrecv.c
Index: sendrecv.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sendrecv.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- sendrecv.c 11 Apr 2002 01:05:39 -0000 1.79
+++ sendrecv.c 11 Apr 2002 03:15:47 -0000 1.80
@@ -98,6 +98,7 @@
ssize_t rv;
if (sock->netmask & APR_INCOMPLETE_WRITE) {
+ sock->netmask &= ~APR_INCOMPLETE_WRITE;
goto do_select;
}
@@ -255,6 +256,7 @@
}
if (sock->netmask & APR_INCOMPLETE_WRITE) {
+ sock->netmask &= ~APR_INCOMPLETE_WRITE;
goto do_select;
}
@@ -799,6 +801,7 @@
size_t nbytes;
sendfilevec_t *sfv;
int vecs, curvec, i, repeat;
+ apr_size_t requested_len = 0;
if (!hdtr) {
hdtr = &no_hdtr;
@@ -819,6 +822,7 @@
sfv[curvec].sfv_flag = 0;
sfv[curvec].sfv_off = (off_t)hdtr->headers[i].iov_base;
sfv[curvec].sfv_len = hdtr->headers[i].iov_len;
+ requested_len += sfv[curvec].sfv_len;
}
/* If the len is 0, we skip the file. */
@@ -828,6 +832,7 @@
sfv[curvec].sfv_flag = 0;
sfv[curvec].sfv_off = *offset;
sfv[curvec].sfv_len = *len;
+ requested_len += sfv[curvec].sfv_len;
curvec++;
}
@@ -840,6 +845,19 @@
sfv[curvec].sfv_flag = 0;
sfv[curvec].sfv_off = (off_t)hdtr->trailers[i].iov_base;
sfv[curvec].sfv_len = hdtr->trailers[i].iov_len;
+ requested_len += sfv[curvec].sfv_len;
+ }
+
+ /* If the last write couldn't send all the requested data,
+ * wait for the socket to become writable before proceeding
+ */
+ if (sock->netmask & APR_INCOMPLETE_WRITE) {
+ sock->netmask &= ~APR_INCOMPLETE_WRITE;
+ arv = apr_wait_for_io_or_timeout(sock, 0);
+ if (arv != APR_SUCCESS) {
+ *len = 0;
+ return arv;
+ }
}
/* Actually do the sendfilev
@@ -889,6 +907,9 @@
/* Update how much we sent */
*len = nbytes;
+ if (sock->timeout && (*len < requested_len)) {
+ sock->netmask |= APR_INCOMPLETE_WRITE;
+ }
return APR_SUCCESS;
}
#else