1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-25 01:34:38 +03:00

libdaemon: ensure threads are reaped before checking shutdown

Since we are checking _shutdown_requested - we expect all threads
are finished - that is currently checked only by checking ->next ptr
being NULL - so this can be NULL only when _reap() function clears
out all already finished threads.

I'm finding this design quite problematic in its core - but as a
'trivial hotfix' - lets _reap() linked list before check for signal.

There is likely a large potentical for few races - but the windows is
very very small - since lvmetad has been already purged from upstream,
lets go with this hotfix.
This commit is contained in:
Zdenek Kabelac 2019-04-29 13:43:36 +02:00
parent 559cf0cd1e
commit b41b112a4b

View File

@ -655,6 +655,7 @@ void daemon_start(daemon_state s)
FD_ZERO(&in);
FD_SET(s.socket_fd, &in);
_reap(s, 0);
sigprocmask(SIG_SETMASK, &new_set, NULL);
if (_shutdown_requested && !s.threads->next) {
sigprocmask(SIG_SETMASK, &old_set, NULL);