Skip to content

Commit 3bb4e5d

Browse files
committed
os: fix sendfile for macos
In python, `count` in `sendfile` doesn't include nbytes in headers or trailers. But in `nix::sys::sendfile::sendfile` does. From nix doc, ``` If any headers are specified and `count` is non-zero, the length of the headers will be counted in the limit of total bytes sent. ```
1 parent 8f47192 commit 3bb4e5d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

vm/src/stdlib/os.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,11 @@ mod _os {
579579
#[pyfunction]
580580
fn sendfile(args: SendFileArgs, vm: &VirtualMachine) -> PyResult {
581581
let headers = _extract_vec_bytes(args.headers, vm)?;
582+
let count = headers
583+
.as_ref()
584+
.map(|v| v.iter().map(|s| s.len()).sum())
585+
.unwrap_or(0) as i64
586+
+ args.count;
582587

583588
let headers = headers
584589
.as_ref()
@@ -602,7 +607,7 @@ mod _os {
602607
args.in_fd,
603608
args.out_fd,
604609
args.offset,
605-
Some(args.count),
610+
Some(count),
606611
headers,
607612
trailers,
608613
);

0 commit comments

Comments
 (0)