]> git.ipfire.org Git - thirdparty/cups.git/commit
dnssd.c: Fix deadlock in `cups_enum_dests()` 857/head
authorZdenek Dohnal <zdohnal@redhat.com>
Thu, 4 Jan 2024 12:58:42 +0000 (13:58 +0100)
committerZdenek Dohnal <zdohnal@redhat.com>
Fri, 5 Jan 2024 05:27:08 +0000 (06:27 +0100)
commit78a051b419f05291714ff2913c19f6cf2aace32c
tree64aa5ba535cc43756c3eb01cccd369668bceb75a
parentadd9975420368b7c89591b06b3d2081a5418fdb5
dnssd.c: Fix deadlock in `cups_enum_dests()`

Deadlock happens when we are about to destroy DNSSD struct by the end
of `cups_enum_dests()`. The main thread locks the mutex when the other
thread is in avahi poll callback at function `poll()` and unlocked the
mutex before - the other thread tries to lock the mutex once poll
timeout expires, but it cannot because it was locked by the main thread
and wait there. Meanwhile the main thread tries to cancel the other
thread, but the function where the other thread is not a cancellation
point, thus the cancel event is ignored and the main thread thread waits
indefinitely for the end of the other thread.

We can make the other thread asynchronous (which would cancel the thread
immediately) or release the mutex earlier in `cupsDNSSDDelete()`. The
commit does the latter.

Fixes CI for Linux
cups/dnssd.c