Bug 4754

Summary: httpd with sendfile fails to send large file
Product: Busybox Reporter: green
Component: NetworkingAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.19.x   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:

Description green 2012-02-04 16:15:37 UTC
When built with "sendfile" support, httpd is unable to send large files (> 2 GB) in one single connection, terminating it before the full file has been sent. Some programs are smart and try to complete the download, which works (e.g. wget), but some other programs are not smart or do not try to be smart and end up with a truncated file.

I *think* the bug resides in httpd.c, line 1626. It reads:

			IF_FEATURE_HTTPD_RANGES(range_len -= sz;)

and I believe it should be:

			IF_FEATURE_HTTPD_RANGES(range_len -= count;)

Because sendfile() returns after 2 GB, which is reflected in "count", and it has to be called more times until the file has been completely sent.
Comment 1 Denys Vlasenko 2012-02-04 20:39:16 UTC
You are absolutely right!

Fixed in git, will go into 1.20.x. Thanks!