about summary refs log tree commit diff
path: root/ui-atom.h
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2015-03-03 19:22:31 +0000
committerJason A. Donenfeld <Jason@zx2c4.com>2015-03-03 23:55:27 +0100
commitdb9a70b159a107da29f88865d63ba14dd127556f (patch)
tree8dd6c73a41bb49206c6bd2c4f1bbee08f295a6bf /ui-atom.h
parentMake root handling sane again. (diff)
downloadcgit-pink-db9a70b159a107da29f88865d63ba14dd127556f.tar.gz
cgit-pink-db9a70b159a107da29f88865d63ba14dd127556f.zip
cache: use F_SETLK to avoid stale lock files
If CGit is killed while it holds a lock on a cache slot (for example
because it is taking too long to generate a page), the lock file will be
left in place.  This prevents any future attempt to use the same slot
since it will fail to exclusively create the lock file.

Since CGit is the only program that should be manipulating lock files,
we can use advisory locking to detect whether another process is
actually using the lock file or if it is now stale.

I have confirmed that this works on Linux by setting a short TTL in a
custom cgitrc and running the following with CGit patched to print a
message to stderr if the fcntl(2) fails:

	$ export CGIT_CONFIG=$PWD/cgitrc
	$ export QUERY_STRING=url=cgit/tree/ui-shared.c
	$ ./cgit |
		grep -v -e '^<div class=.footer.>' \
			-e '^Last-Modified: ' \
			-e ^'Expires: ' >expect
	$ seq 50000 | dd bs=8192 |
		parallel -j200 "diff -u expect <(./cgit |
			grep -v -e '^<div class=.footer.>' \
				-e '^Last-Modified: ' \
				-e ^'Expires: ') || echo BAD"

This printed the fail message several times without ever printing "BAD".

Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'ui-atom.h')
0 files changed, 0 insertions, 0 deletions
Makefile?id=ae5823a4cda93b6def9ae017ba3d93daa2eceeb9&follow=1'>Publish "git-comment"June McEnroe 2021-09-10Add git comment --pretty optionJune McEnroe 2021-09-08Defer printing comment if line is blank or closing braceJune McEnroe 2021-09-08Up default min-repeat to 30 linesJune McEnroe 2021-09-08Handle dirty lines in git-commentJune McEnroe 2021-09-08Document and install git-commentJune McEnroe 2021-09-08Add repeat and all options to git-commentJune McEnroe 2021-09-08Add group threshold to git-commentJune McEnroe