You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Richard Griswold <rg...@us.ibm.com> on 2001/03/15 18:25:32 UTC
os-aix/7418: Incorrect reporting of bytes sent by send_file()
>Number: 7418
>Category: os-aix
>Synopsis: Incorrect reporting of bytes sent by send_file()
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: apache
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: apache
>Arrival-Date: Thu Mar 15 09:30:02 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: rgriswol@us.ibm.com
>Release: 2.0.14 Alpha
>Organization:
apache
>Environment:
uname -a output: AIX engraver 3 4 000669914C00
Compiler: xlc
>Description:
The apr_sendfile() function in the srclib/apr/network_io/unix/sendrecv.c only
reports the number of bytes sent by the last call to send_file. The code also
only checks for a return code of -1, and not a return code of 1 which indicates
that send_file() was able to send part of the data, but not all of it.
On AIX this results in a minor performance degradation since Apache has to make
multiple calls to the apr_sendfile() function to send large files. However, on
a version of one of our operating systems currently under developement (I could
tell you which one, but then I'd have to kill you :)) it causes Apache to fail
to send files larger than twice the send buffer size.
>How-To-Repeat:
>Fix:
Here is the patch for httpd-2_0_14. It also applies cleanly on apache-2.0a9.
Use "patch p1 < patchfile" to apply it.
diff -bcr httpd-2_0_14.orig/srclib/apr/network_io/unix/sendrecv.c httpd-2_0_14/srclib/apr/network_io/unix/sendrecv.c
*** httpd-2_0_14.orig/srclib/apr/network_io/unix/sendrecv.c Mon Feb 26 06:41:51 2001
--- httpd-2_0_14/srclib/apr/network_io/unix/sendrecv.c Thu Mar 15 10:52:59 2001
***************
*** 700,710 ****
rv = send_file(&(sock->socketdes), /* socket */
&(parms), /* all data */
flags); /* flags */
} while (rv == -1 && errno == EINTR);
! if (rv == -1 &&
(errno == EAGAIN || errno == EWOULDBLOCK) &&
sock->timeout > 0) {
arv = wait_for_io_or_timeout(sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
--- 700,713 ----
rv = send_file(&(sock->socketdes), /* socket */
&(parms), /* all data */
flags); /* flags */
+ (*len) = parms.bytes_sent;
} while (rv == -1 && errno == EINTR);
! if (rv != 0 &&
(errno == EAGAIN || errno == EWOULDBLOCK) &&
sock->timeout > 0) {
+
+ do {
arv = wait_for_io_or_timeout(sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
***************
*** 715,725 ****
rv = send_file(&(sock->socketdes), /* socket */
&(parms), /* all data */
flags); /* flags */
} while (rv == -1 && errno == EINTR);
}
}
-
- (*len) = parms.bytes_sent;
#if 0
/* Clean up after ourselves */
--- 718,728 ----
rv = send_file(&(sock->socketdes), /* socket */
&(parms), /* all data */
flags); /* flags */
+ (*len) += parms.bytes_sent;
} while (rv == -1 && errno == EINTR);
}
+ } while ( rv != 0 && (errno == EAGAIN || errno == EWOULDBLOCK) );
}
#if 0
/* Clean up after ourselves */
>Release-Note:
>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, you need]
[to include <ap...@Apache.Org> in the Cc line and make sure the]
[subject line starts with the report component and number, with ]
[or without any 'Re:' prefixes (such as "general/1098:" or ]
["Re: general/1098:"). If the subject doesn't match this ]
[pattern, your message will be misfiled and ignored. The ]
["apbugs" address is not added to the Cc line of messages from ]
[the database automatically because of the potential for mail ]
[loops. If you do not include this Cc, your reply may be ig- ]
[nored unless you are responding to an explicit request from a ]
[developer. Reply only with text; DO NOT SEND ATTACHMENTS! ]