On Fri, May 04, 2001 at 01:15:17PM -0400, Jeff Trawick wrote:
> We have one coredump for an assertion (ohmygod) failure on
> apache.org where apr_sendfile() returned APR_SUCCESS/zero-bytes-read
> for a socket with a timeout. After reading the code many times I just
> don't see how, unless the kernel had a slip-up.
>
> I noticed this weird use of sendfile() in FreeBSD's ftpd.c:
>
> while (err != -1 && cnt < filesize) {
> err = sendfile(filefd, netfd, offset, len,
> (struct sf_hdtr *) NULL, &cnt, 0);
> byte_count += cnt;
> offset += cnt;
> len -= cnt;
>
> if (err == -1) {
> if (!cnt)
> goto oldway;
>
> goto data_err;
> }
> }
>
> I don't understand why there is a loop... (I have no idea if there is
> a connection between the unclear need for this loop and BSD's
> sendfile() returning 0/0...)
this is just off the top of my head, but could that socket (in the ftpd code)
be set for non-blocking io? the man page for sendfile() on freebsd indicates
that in such a case, less than the total number of bytes could be sent, and
EAGAIN would be returned. thus the loop.
--
garrett rooney Unix was not designed to stop you from
[EMAIL PROTECTED] doing stupid things, because that would
http://electricjellyfish.net/ stop you from doing clever things.