List for cgit developers and users
 help / color / mirror / Atom feed
* cgit 1.2.3: lighttpd 1.4.57, AlpineLinux [edge]: using cache breaks delivery
@ 2020-12-21 16:26 Steffen Nurpmeso
  2020-12-21 17:57 ` John Keeping
  2021-01-02 18:38 ` Jon DeVree
  0 siblings, 2 replies; 14+ messages in thread
From: Steffen Nurpmeso @ 2020-12-21 16:26 UTC (permalink / raw)
  To: cgit

Hello.

My first post here, so first a "Thank you!", i am using cgit on
lighttpd on Linux for half a decade, and it just works (after
finally having a usable configuration).

I discovered today that cgit no longer delivers pages, and it must
have been like that for some time.  The server looks show
successful delivery, the cgit cache is populated and rotated just
correctly, but all cgit delivers is that final error of main() as

  <div class='error'>Error processing page: Invalid argument (22)</div>

(surely a misconfiguration that this is not a real HTML page,
i recall it took some time to figure out about about-filter, just
"doing it" (<pre>cat(1)</pre>)).

If i set "cache-size=0" then the desired page is delivered.
Note the cache itself is managed as usual with the default
cache-size=1999.

The files in the cache are 0600, i thought maybe that was it, but
the setting is actively reverted to this mask (i never looked at
cgit code except grepping the error).  It has always been so, the
oldest cache entry was

  -rw-------    1 lighttpd lighttpd      3023 Mar 18  2018 d2200000

I am pretty sure cgit delivered some weeks ago, the most notable
difference is that AlpineLinux switched to Lighttpd 1.4.56 then
.57, which seems to have brought tremendous changes under the
hood, like HTTP/2 support and OCSP as well as support for all the
different TLS libraries, whereas before it only was OpenSSL and
compatibles, i think.  We have HTTP/2 not enabled yet.

Anything i can do about this?

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: cgit 1.2.3: lighttpd 1.4.57, AlpineLinux [edge]: using cache breaks delivery
@ 2020-12-22  6:12 gs-cgit-lists.zx2c4.com
  2020-12-22 13:55 ` Steffen Nurpmeso
  0 siblings, 1 reply; 14+ messages in thread
From: gs-cgit-lists.zx2c4.com @ 2020-12-22  6:12 UTC (permalink / raw)
  To: cgit

>Steffen Nurpmeso wrote in
> <20201221193127.zbZeP%steffen at sdaoden.eu>:
> |John Keeping wrote in
> | <X+DiDgGaPaynnocI at john.keeping.me.uk>:
> ||On Mon, Dec 21, 2020 at 05:26:19PM +0100, Steffen Nurpmeso wrote:
> ||> I discovered today that cgit no longer delivers pages, and it must
> ||> have been like that for some time.  The server looks show
> ||> successful delivery, the cgit cache is populated and rotated just
> ||> correctly, but all cgit delivers is that final error of main() as
> ||> 
> ||>   <div class='error'>Error processing page: Invalid argument (22)</div>
> ...
> ||> I am pretty sure cgit delivered some weeks ago, the most notable
> ||> difference is that AlpineLinux switched to Lighttpd 1.4.56 then
> ||> .57, which seems to have brought tremendous changes under the
> ...
> |But the file was generated normally:
> |
> |  # ll /var/lib/lighttpd/cgit/b1000000
> |  -rw-------    1 lighttpd lighttpd     23417 Dec 21 20:22 /var/lib/lighttpd/cgit/b1000000
> ...
>
>Slightly resorted:
>
> ...
> ||Have you looked at the log output?
> |  [cgit] error printing cache /var/lib/lighttpd/cgit/b1000000: Invalid argument (22)
> ...
> ||and this may be caused by sendfile(2) failing due to some difference in
> ||how the web server is setting up the output file descriptor.  You may
> ||want to rebuild CGit without HAVE_LINUX_SENDFILE and see if that works.
>
>So i build it with
>
>  #alp-2020:$ diff cgit.mk.orig cgit.mk
>  --- cgit.mk.orig
>  +++ cgit.mk
>  @@ -64,7 +64,7 @@
>   endif
>
>   ifdef HAVE_LINUX_SENDFILE
>  -       CGIT_CFLAGS += -DHAVE_LINUX_SENDFILE
>  +       #CGIT_CFLAGS += -DHAVE_LINUX_SENDFILE
>   endif
>
>   CGIT_OBJ_NAMES += cgit.o
>
>and
>
>  make NO_LUA=y NO_ICONV=y NO_GETTEXT=y NO_TCLTK=y NO_PERL=1 \
>    NO_PYTHON=1 NO_SVN_TESTS=y NO_REGEX=NeedsStartEnd prefix=/usr
>
>and .. it works.
>
>Thank you, i will open an AlpineLinux bug report.  And lighttpd.
>
>--steffen

I would like to propose an alternative and more portable solution:

cgit cache should fallback to lseek, xread, xwrite if sendfile fails.

Even if the kernel supports sendfile() and cgit is built with
HAVE_LINUX_SENDFILE defined, certain filesystem types might not support
sendfile() operations.

The following patch falls back to lseek, xread, xwrite if the *initial*
call to sendfile() fails.

diff --git a/cache.c b/cache.c
index 2c70be7..7fbab66 100644
--- a/cache.c
+++ b/cache.c
@@ -85,6 +85,7 @@ static int close_slot(struct cache_slot *slot)
 /* Print the content of the active cache slot (but skip the key). */
 static int print_slot(struct cache_slot *slot)
 {
+       ssize_t i, j;
 #ifdef HAVE_LINUX_SENDFILE
        off_t start_off;
        int ret;
@@ -97,12 +98,13 @@ static int print_slot(struct cache_slot *slot)
                if (ret < 0) {
                        if (errno == EAGAIN || errno == EINTR)
                                continue;
+                       if (start_off == slot->keylen + 1)
+                               break;
                        return errno;
                }
                return 0;
        } while (1);
-#else
-       ssize_t i, j;
+#endif
 
        i = lseek(slot->cache_fd, slot->keylen + 1, SEEK_SET);
        if (i != slot->keylen + 1)
@@ -118,7 +120,6 @@ static int print_slot(struct cache_slot *slot)
                return errno;
        else
                return 0;
-#endif
 }
 
 /* Check if the slot has expired */

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

end of thread, other threads:[~2021-01-15 22:41 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-21 16:26 cgit 1.2.3: lighttpd 1.4.57, AlpineLinux [edge]: using cache breaks delivery Steffen Nurpmeso
2020-12-21 17:57 ` John Keeping
2020-12-21 19:31   ` Steffen Nurpmeso
2020-12-21 22:23     ` Steffen Nurpmeso
2020-12-21 23:24       ` Steffen Nurpmeso
2021-01-02 18:38 ` Jon DeVree
2021-01-15 18:01   ` Jon DeVree
2021-01-15 21:51     ` Konstantin Ryabitsev
2021-01-15 22:41       ` Jon DeVree
2020-12-22  6:12 gs-cgit-lists.zx2c4.com
2020-12-22 13:55 ` Steffen Nurpmeso
2020-12-22 15:09   ` Steffen Nurpmeso
2020-12-22 21:22     ` Steffen Nurpmeso
2020-12-29 17:04       ` Steffen Nurpmeso

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).