Return-Path: Delivered-To: apmail-apache-cvs-archive@apache.org Received: (qmail 48279 invoked by uid 500); 11 Nov 2000 00:09:47 -0000 Mailing-List: contact apache-cvs-help@apache.org; run by ezmlm Precedence: bulk Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list apache-cvs@apache.org Received: (qmail 48268 invoked by uid 500); 11 Nov 2000 00:09:46 -0000 Delivered-To: apmail-apache-2.0-cvs@apache.org Date: 11 Nov 2000 00:09:46 -0000 Message-ID: <20001111000946.48264.qmail@locus.apache.org> From: rbb@locus.apache.org To: apache-2.0-cvs@apache.org Subject: cvs commit: apache-2.0/src/lib/apr/network_io/unix sendrecv.c rbb 00/11/10 16:09:46 Modified: src/lib/apr configure.in src/lib/apr/network_io/unix sendrecv.c Log: Tru64's sendfile implementation is completely broken, so we can't use it. The problem is that autoconf finds it in libc, so we have to hack our configuration. If sendfile is used, then the machine hangs, and that's really bad, so we should remove that code as well. Submitted by: David Hill Revision Changes Path 1.169 +5 -1 apache-2.0/src/lib/apr/configure.in Index: configure.in =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/configure.in,v retrieving revision 1.168 retrieving revision 1.169 diff -u -r1.168 -r1.169 --- configure.in 2000/11/10 22:11:36 1.168 +++ configure.in 2000/11/11 00:09:46 1.169 @@ -213,7 +213,11 @@ AC_CHECK_FUNCS(setrlimit, [ have_setrlimit="1" ], [ have_setrlimit="0" ]) AC_CHECK_FUNCS(getrlimit, [ have_getrlimit="1" ], [ have_getrlimit="0" ]) AC_CHECK_FUNCS(writev) -AC_CHECK_FUNCS(sendfile send_file, [ sendfile="1" ], [ sendfile="0" ]) +sendfile="0" +AC_CHECK_FUNCS(sendfile send_file, [ sendfile="1" ]) +#if test "$OS" = "*osf" -o "$OS" = "*alpha*" ; then +# sendfile="0" +#fi AC_CHECK_FUNCS(fork, [ fork="1" ], [ fork="0" ]) AC_CHECK_FUNCS(getpass) APR_CHECK_INET_ADDR 1.47 +3 -114 apache-2.0/src/lib/apr/network_io/unix/sendrecv.c Index: sendrecv.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sendrecv.c,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- sendrecv.c 2000/11/09 07:13:42 1.46 +++ sendrecv.c 2000/11/11 00:09:46 1.47 @@ -699,121 +699,10 @@ return APR_SUCCESS; } #elif defined(__osf__) && defined (__alpha) -/* - * apr_sendfile for Tru64 Unix. - * - * Note: while the sendfile implementation on Tru64 can send - * a one header/trailer with the file, it will send only one - * each and not an array as is passed into this function. In - * addition, there is a limitation on the size of the header/trailer - * that can be referenced ( > 4096 seems to cause an ENOMEM) - * Rather than code these special cases in, using apr_sendv for - * all cases of the headers and trailers seems to be a good idea. +/* Tru64's sendfile implementation doesn't work, and we need to make sure that + * we don't use it until it is fixed. If it is used as it is now, it will + * hang the machine and the only way to fix it is a reboot. */ -apr_status_t apr_sendfile(apr_socket_t * sock, apr_file_t * file, - apr_hdtr_t * hdtr, apr_off_t * offset, apr_size_t * len, - apr_int32_t flags) -{ - off_t nbytes = 0; - int rv, i; - apr_status_t arv; - struct iovec headerstruct[2] = {(0, 0), (0, 0)}; - size_t bytes_to_send = *len; - - if (!hdtr) { - hdtr = &no_hdtr; - } - - /* Ignore flags for now. */ - flags = 0; - - if (hdtr->numheaders > 0) { - apr_size_t hdrbytes = 0; - - arv = apr_sendv(sock, hdtr->headers, hdtr->numheaders, &hdrbytes); - if (arv != APR_SUCCESS) { - *len = 0; - 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) { - apr_size_t 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; - } - } - } - - if (bytes_to_send) { - /* We won't dare call sendfile() if we don't have - * header or file bytes to send because bytes_to_send == 0 - * means send the whole file. - */ - do { - rv = sendfile(sock->socketdes, /* socket */ - file->filedes, /* file to be sent */ - *offset, /* where in the file to start */ - bytes_to_send, /* number of bytes to send */ - headerstruct, /* Headers/footers */ - flags); /* currently unused */ - } while (rv == -1 && errno == EINTR); - } - else - rv = 0; - - if (rv == -1 && - (errno == EAGAIN || errno == EWOULDBLOCK) && - sock->timeout > 0) { - apr_status_t arv = wait_for_io_or_timeout(sock, 0); - - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } - else { - do { - rv = sendfile(sock->socketdes, /* socket */ - file->filedes, /* file to be sent */ - *offset, /* where in the file to start */ - bytes_to_send, /* number of bytes to send */ - headerstruct, /* Headers/footers */ - flags); /* undefined, set to 0 */ - } while (rv == -1 && errno == EINTR); - } - } - - if (rv != -1) { - nbytes += rv; - - if (hdtr->numtrailers > 0) { - apr_size_t trlbytes = 0; - - /* send the trailers now */ - arv = apr_sendv(sock, hdtr->trailers, hdtr->numtrailers, &trlbytes); - if (arv != APR_SUCCESS) { - *len = 0; - return errno; - } - - nbytes += trlbytes; - } - } - - (*len) = nbytes; - - return (rv < 0) ? errno : APR_SUCCESS; -} - #else #error APR has detected sendfile on your system, but nobody has written a #error version of it for APR yet. To get past this, either write apr_sendfile