Bug/Performance: sendfile() loop treats EAGAIN / EINTR as fatal errors #168

Closed
opened 2026-07-29 18:36:33 +02:00 by TapTap · 0 comments
Owner

Description

file_send_sendfile() in src/shared/file.c:456-463 calls sendfile() in a loop. If sendfile() returns -1 with errno == EAGAIN or EINTR, the function treats it as a fatal error and returns false. On a non-blocking or busy socket, this can cause unnecessary transfer failures. The function also does not use errno correctly to distinguish recoverable errors from true failures.

Location

  • src/shared/file.c:458-463sendfile() loop.

Suggested fix

  1. Check errno after sendfile() returns -1.
  2. Retry on EAGAIN (after poll()/select() for write readiness) and EINTR.
  3. Use sendfile() only for regular files; fall back to read()/write() for non-regular files.

Severity

Low

Category

bug, performance


This issue was automatically generated by the issue-creator agent.

## Description `file_send_sendfile()` in `src/shared/file.c:456-463` calls `sendfile()` in a loop. If `sendfile()` returns `-1` with `errno == EAGAIN` or `EINTR`, the function treats it as a fatal error and returns false. On a non-blocking or busy socket, this can cause unnecessary transfer failures. The function also does not use `errno` correctly to distinguish recoverable errors from true failures. ## Location - `src/shared/file.c:458-463` — `sendfile()` loop. ## Suggested fix 1. Check `errno` after `sendfile()` returns `-1`. 2. Retry on `EAGAIN` (after `poll()`/select() for write readiness) and `EINTR`. 3. Use `sendfile()` only for regular files; fall back to `read()`/`write()` for non-regular files. ## Severity Low ## Category bug, performance --- _This issue was automatically generated by the issue-creator agent._
TapTap added the bugneeds-triageperformance labels 2026-07-29 18:36:33 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#168