On Thu, Aug 11, 2011 at 5:16 PM, Michael Herf <h...@pobox.com> wrote: > In addition to my note about 64-bit offsets earlier: > > Solaris sendfile seems to fail when sending moderately large (<1GB) files. > Not a 32/64 problem, but a buffer problem. > Anyone else ever try this? It is definitely broken in http-server.c. > > It seems to be broken in the following way: > When sendfile sends partial data (EAGAIN, would block), "res" is always > -1, rather than the amount sent. > Here's a patch that reads from the "offset" pointer instead to discover > what was sent. This seems to work: > > --- buffer.c 2010-12-16 10:05:27.000000000 -0800 > +++ ../libevent/buffer.c 2011-08-11 14:13:42.288328799 -0700 > @@ -2262,11 +2262,18 @@ > } > return (res); > #elif defined(SENDFILE_IS_SOLARIS) > - res = sendfile(fd, info->fd, &offset, chain->off); > - if (res == -1 && EVUTIL_ERR_RW_RETRIABLE(errno)) { > + > + off_t offset0 = offset; > + res = sendfile(fd, info->fd, &offset, chain->off); > + > + if (res == -1 && EVUTIL_ERR_RW_RETRIABLE(errno)) { > + if (offset - offset0) { > + return offset - offset0; > + } > /* if this is EAGAIN or EINTR return 0; otherwise, -1 */ > return (0); > - } > + } > + > return (res); > #endif > }
Looks good; applying with a small tweak to make it fit the code style. Let me know if the patches-2.0 branch looks good to you now. Also, you said elsewhere that you think this applies to the bsd backends as well. FWICT, it shouldn't: have a look at how the &len variable is set and used there. -- Nick *********************************************************************** To unsubscribe, send an e-mail to majord...@freehaven.net with unsubscribe libevent-users in the body.