List for cgit developers and users
 help / color / mirror / Atom feed
From: "Valdis Vītoliņš" <>
Cc: Leah Neukirchen <>
Subject: Re: cache: sendfile(2) usage results in short writes to pipes
Date: Thu, 22 Dec 2022 10:58:00 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

Hi, Leah!

Do I understand you correctly that, when compiling and deploying cgit
according to

before compilation I should add in Makefile:


> Hi,
> in cache.c:print_slot, sendfile is called only once, but not checked
> for short writes.  These happen for example when serving cgit via
> fcgiwrap, which uses a pipe, so the write only writes 65k:
> [pid 31211] openat(AT_FDCWD, "/var/cache/cgit/b9200000", O_RDONLY) = 4
> [pid 31211] fstat(4, {st_mode=S_IFREG|0600, st_size=19824215, ...}) = 0
> [pid 31211] read(4, "mirror/glibc/snapshot/glibc-3aae"..., 4096) = 4096
> [pid 31211] sendfile(1, 4, [77] => [65536], 19824138) = 65459
> [pid 31211] close(4 <unfinished ...>
> This results in truncated cache responses, and therefore broken
> downloads from snapshots (larger than 65k).
> I assume this is also the cause for the bug reported in
> <>, I added the author to Cc:.
> I recommend running sendfile in a loop until the whole file is sent.
> I also recommend detecting sendfile errors and falling back to the
> default read/write implementation, as there are some Linux filesystems
> where sendfile fails permanently.
> Disabling HAVE_LINUX_SENDFILE on build serves as a workaround.
> cu,

       reply	other threads:[~2022-12-22  8:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <>
2022-12-22  8:58 ` Valdis Vītoliņš [this message]
2022-12-18 18:38 Leah Neukirchen
2022-12-19 15:17 ` Jason A. Donenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).