List for cgit developers and users
 help / color / mirror / Atom feed
* Truncated output when writing to a pipe using sendfile
@ 2022-05-07 12:49 Filips R
  2022-05-07 13:03 ` Gianni Ceccarelli
  0 siblings, 1 reply; 4+ messages in thread
From: Filips R @ 2022-05-07 12:49 UTC (permalink / raw)
  To: cgit

Hello!

I've been investigating an issue on my Alpine linux server running
cgit 1.2.3-r2.
When I call the CGI program and redirect to a regular file (or just
output to tty), the output is correct, however if the standard output
is a pipe, the output is truncated at 65523 bytes.

Here is the end of the diff between strace outputs:

 open("/var/cache/cgit/a1000000", O_RDONLY|O_LARGEFILE) = 3
 fstat(3, {st_mode=S_IFREG|0600, st_size=157003, ...}) = 0
 read(3, "st/tree/st.c\0Content-Type: text/"..., 4096) = 4096
-sendfile(1, 3, [13] => [157003], 156990) = 156990
+sendfile(1, 3, [13] => [65536], 156990) = 65523
 close(3)                                = 0
 exit_group(0)                           = ?
 +++ exited with 0 +++

I have managed to work around the issue by wrapping cgit and
redirecting to a temporary file.

Looks like the sendfile call comes from cache.c:95 -
https://git.zx2c4.com/cgit/tree/cache.c?h=v1.2.3&id=55fa25adb097d2681607d8b0f51a0c393cc9af1a#n95

senfile(2) says that a successful call may write fewer bytes than
requested; the caller should be prepared to retry the call if there
were unsent bytes

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-07 17:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-07 12:49 Truncated output when writing to a pipe using sendfile Filips R
2022-05-07 13:03 ` Gianni Ceccarelli
2022-05-07 17:06   ` Hristo Venev
2022-05-07 17:07     ` [PATCH RESEND v2] cache: Tolerate short writes in print_slot Hristo Venev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).