[PATCH] - httpd: support for kernel sendfile() call

Denys Vlasenko vda.linux at googlemail.com
Mon Aug 13 10:54:36 UTC 2007


On Monday 13 August 2007 00:42, Eric Lammerts wrote:
> Denys Vlasenko wrote:
> > +               off_t offset = 0;
> > +               sendfile(fd, f, &offset, f_stat.st_size);
> >
> > What will happen if f_stat.st_size > INT_MAX (2 gb) ?
>
> If busybox was compiled with large file support, both off_t and
> f_stat.st_size should be 64-bit, no? And if busybox was compiled without
> large file support, the open() would have failed already with EFBIG.

manpage disagrees with you. While offset is indeed a ptr to off_t,
byte count is not:

ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
^^^^^^^                                                ^^^^^^^^^^^^

> I noticed the return status of sendfile isn't checked at all, and that is
> bad. Sendfile fails with EINVAL on filesystems without mmap() support
> (for example unionfs), and in that case busybox should fall back to the
> old method.

Implemented in current svn, but not tested.

> And I think sendfile() is also allowed to return with a value 
> less than f_stat.st_size, but I'm not sure if that ever happens in
> practice.

Yes it happens. I saw it yesterday.
Current svn loops until sendfile returns <= 0.
--
vda




More information about the busybox mailing list