Jeff Trawick <[EMAIL PROTECTED]> writes:
> With this patch
>
> 1) we don't call wait_for_io_or_timeout() after successfully sending
> data
>
> 2) we try again to send data after wait_for_io_or_timeout() finds that
> the socket is now writable
>
> 3) the code looks more like the other APR network write operations
here is the patch (thanks, OtherBill :) )
Index: srclib/apr/network_io/unix/sendrecv.c
===================================================================
RCS file: /home/cvspublic/apr/network_io/unix/sendrecv.c,v
retrieving revision 1.72
diff -u -r1.72 sendrecv.c
--- srclib/apr/network_io/unix/sendrecv.c 2001/07/25 20:59:29 1.72
+++ srclib/apr/network_io/unix/sendrecv.c 2001/07/25 21:28:16
@@ -839,36 +839,37 @@
rv = sendfilev(sock->socketdes, sfv, vecs, &nbytes);
} while (rv == -1 && errno == EINTR);
- /* Solaris returns EAGAIN even though it sent bytes on a non-block sock.
- * However, if we are on a TIMEOUT socket, we want to block until the
- * other side has read the data.
+ /* Solaris' sendfilev() can return -1/EAGAIN even if it sent bytes.
+ * Sanitize the result so we get normal EAGAIN semantics w.r.t.
+ * bytes sent.
*/
- if (rv == -1)
- {
- if (errno == EAGAIN) {
- if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT) == 1)
- {
- /* If the wait fails for some reason, we're going to lie to our
- * caller and say that we didn't write any bytes. That's
- * untrue.
- */
- rv = apr_wait_for_io_or_timeout(sock, 0);
+ if (rv == -1 && errno == EAGAIN && nbytes) {
+ rv = 0;
+ }
- /* Indicate that we sent zero bytes. */
- if (rv != APR_SUCCESS)
- {
- *len = 0;
- return rv;
- }
- }
- }
- else
- {
- /* Indicate that we sent zero bytes. */
- rv = errno;
+ if (rv == -1 &&
+ errno == EAGAIN &&
+ sock->timeout > 0) {
+ rv = apr_wait_for_io_or_timeout(sock, 0);
+ /* Indicate that we sent zero bytes. */
+ if (rv != APR_SUCCESS) {
*len = 0;
return rv;
}
+ else {
+ do {
+ /* socket, vecs, number of vecs, bytes written */
+ rv = sendfilev(sock->socketdes, sfv, vecs, &nbytes);
+ } while (rv == -1 && errno == EINTR);
+
+ /* Solaris' sendfilev() can return -1/EAGAIN even if it sent bytes.
+ * Sanitize the result so we get normal EAGAIN semantics w.r.t.
+ * bytes sent.
+ */
+ if (rv == -1 && errno == EAGAIN && nbytes) {
+ rv = 0;
+ }
+ }
}
/* Update how much we sent */
--
Jeff Trawick | [EMAIL PROTECTED] | PGP public key at web site:
http://www.geocities.com/SiliconValley/Park/9289/
Born in Roswell... married an alien...