]> Sergey Matveev's repositories - public-inbox.git/commit
lei: avoid racing on unlink + bind + listen
authorEric Wong <e@80x24.org>
Mon, 8 Feb 2021 09:05:16 +0000 (23:05 -1000)
committerEric Wong <e@80x24.org>
Mon, 8 Feb 2021 22:07:46 +0000 (22:07 +0000)
commit6214e8fabf5739ba5d2857321f082f8fac03136e
tree1317ac568d2d76eeac6da459feeea278c1e81b1b
parent918d34ec89259200e69cbdfff5dc2141d93bf0ec
lei: avoid racing on unlink + bind + listen

When multiple lei(1) processes are starting in parallel without
lei-daemon already running, it's possible for them to trample
each others' socket path trying to start lei-daemon.  Lock
errors.log before unlink/bind/listen.  We'll add an extra
connect(2) attempt to check if the starter lost the race.

Without this change, a stress script like the following could
easily cause problems:

lei q -o ~/tmp/a foo ... &
lei q -o ~/tmp/b bar ... &
lei q -o ~/tmp/c quux ... &
lei q -o ~/tmp/d baz ... &
lib/PublicInbox/LEI.pm