mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
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. ```
This commit is contained in:
@@ -579,6 +579,11 @@ mod _os {
|
||||
#[pyfunction]
|
||||
fn sendfile(args: SendFileArgs, vm: &VirtualMachine) -> PyResult {
|
||||
let headers = _extract_vec_bytes(args.headers, vm)?;
|
||||
let count = headers
|
||||
.as_ref()
|
||||
.map(|v| v.iter().map(|s| s.len()).sum())
|
||||
.unwrap_or(0) as i64
|
||||
+ args.count;
|
||||
|
||||
let headers = headers
|
||||
.as_ref()
|
||||
@@ -602,7 +607,7 @@ mod _os {
|
||||
args.in_fd,
|
||||
args.out_fd,
|
||||
args.offset,
|
||||
Some(args.count),
|
||||
Some(count),
|
||||
headers,
|
||||
trailers,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user