From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3579 invoked from network); 18 Dec 2022 18:39:16 -0000 Received: from lists.zx2c4.com (165.227.139.114) by inbox.vuxu.org with ESMTPUTF8; 18 Dec 2022 18:39:16 -0000 Received: by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTP id f71f5cae; Sun, 18 Dec 2022 18:38:59 +0000 (UTC) Return-Path: Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTPS id ddac3ffb (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Sun, 18 Dec 2022 18:38:58 +0000 (UTC) Received: by mail-ej1-f52.google.com with SMTP id qk9so17003527ejc.3 for ; Sun, 18 Dec 2022 10:38:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:user-agent:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=b0IaUVbXg0hww4CHrFTwp12kv5qNwzFN3oOsAV1W8eE=; b=lhFh4D3YE3jZnw49PN0Q0Mv5S6MUcshT4h90tRqZMGC/FuAx1MD7bMRE/ABpKAAjW4 wer80vvoGeXlI8Vf7gcirQ3NoJvtey2tlSdz6w1+JP2U2wpYPRudfd1t+GCu5y32KhxC Z3vCB93bQ5ELjtIQyfy9hqUHd+15SWWz9up/7A1j1qrtCfDL206nKieh20ZNGR3S6Z4q yrZzTZGFHqT+EwPWkPOwsbXamklEfANAv1NnKv6k9Nl1XYzp7wzLhe7B1saZ1/IjlbHJ 1euugP+cg9slVitD/NLWSMebmMRKYvI8vyopfLwtfMaI9dvW4g59xL97wKOnFz9ct4ff 5zcQ== X-Gm-Message-State: ANoB5pmGLbfOInQhZfaEUBFcelHYEGdObhEQRWXHYs1kxvp24B7reWHx jOdquWgDO9T8VhylTeSjFUc= X-Google-Smtp-Source: AA0mqf7Un+3urQJ2zCcYqQVgyZQT+BWvz0Y7eezx8t6ES0bBIliGB1xkwHHDZNBr/yCp0CyKYHHW7w== X-Received: by 2002:a17:907:a70b:b0:7c1:6d65:4718 with SMTP id vw11-20020a170907a70b00b007c16d654718mr25883075ejc.33.1671388737794; Sun, 18 Dec 2022 10:38:57 -0800 (PST) Return-Path: Received: from rhea.home.vuxu.org ([2001:a61:3a3a:f701:1e1b:b5ff:fe8a:9003]) by smtp.gmail.com with ESMTPSA id gh10-20020a170906e08a00b0072a881b21d8sm3410928ejb.119.2022.12.18.10.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Dec 2022 10:38:57 -0800 (PST) Received: from localhost (rhea.home.vuxu.org [local]) by rhea.home.vuxu.org (OpenSMTPD) with ESMTPA id c6e26e2e; Sun, 18 Dec 2022 18:38:56 +0000 (UTC) From: Leah Neukirchen To: Cc: Subject: cache: sendfile(2) usage results in short writes to pipes User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Date: Sun, 18 Dec 2022 19:38:56 +0100 Message-ID: <87v8m8pnen.fsf@vuxu.org> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: cgit@lists.zx2c4.com X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: List for cgit developers and users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: cgit-bounces@lists.zx2c4.com Sender: "CGit" 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 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 <0ef89b1e-6543-e726-2cf0-b68e7167fabe@odo.lv>, 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, -- Leah Neukirchen https://leahneukirchen.org/