]> git.scottworley.com Git - tl-append/commit - tl-append-test.c
Also take flock locks
authorScott Worley <scottworley@scottworley.com>
Wed, 13 Sep 2023 21:56:30 +0000 (14:56 -0700)
committerScott Worley <scottworley@scottworley.com>
Wed, 13 Sep 2023 22:11:59 +0000 (15:11 -0700)
commitd212cd99e7ef72e0add4ef772e328835a972ae6b
tree5af89168d42cadc66d7365888cf10c222198d8b9
parenta1160bb5b12b273f44860ccd4f028cb22c4f5e4d
Also take flock locks

There are two kinds of locks, so for interoperability, everyone has to
always take both kinds, to avoid the possibility of one client using one
kind and another client using another kind & missing each other.  :(

I wonder what order we're supposed to take them in?  If we don't all
agree, we get deadlocks!  Here, I take them in alphabetical order
(fcntl then flock), in the hope of this being a legible Schelling point.

The test harness does exercise the "take locks in the 'wrong' order" case.
It probably deadlocks with some tiny probability on heavily-loaded
systems.  Sorry.  If this hurts you, feel free to remove it.
tl-append-test.c
tl-append.c