veb: handle sendfile errors, when the connection is canceled, before the file is completely transferred (#23891)

This commit is contained in:
sSAR 2025-03-09 15:33:11 +01:00 committed by GitHub
parent 81afd8f502
commit 6cda3b0ab3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -254,7 +254,11 @@ fn handle_write_file(mut pv picoev.Picoev, mut params RequestParams, fd int) {
$if linux || freebsd {
bytes_written := sendfile(fd, params.file_responses[fd].file.fd, bytes_to_write)
params.file_responses[fd].pos += bytes_written
if bytes_written < 0 {
params.file_responses[fd].pos += bytes_to_write
} else {
params.file_responses[fd].pos += bytes_written
}
} $else {
if bytes_to_write > max_write {
bytes_to_write = max_write