While studying the vdc client handling logic, I found a couple of locking operations that I do not understand. As far as I can see, they should be changed as in this merge request. Otherwise, deadlocks may arise.
First, after an automatic connection is removed, the per-client mutexes of other clients before the removed one in the list will remain locked (twice), so access to them outside of the avahi loop thread will wait forever.
Second, the top level rwlock for the client list is left as "read-locked" after the removal of an auto-connection client. This will lead to deadlocks the next time a "write-lock" attempt is performed, for example, if a new persistent connection is attempted.
Finally, note that the list rwlock was "read-locked" when adding a new automatic connection, but the list is then modified (LL_PREPEND). This avoided a deadlock when adding a new auto-connection after one has been removed (due to the second point above), but leaves room for race conditions if a different thread attempts a simultaneous "read-lock" access.
Marked as WIP because I have not tested this in depth. If the change looks clear to you, or you are able to test it, let me know and I will remove the WIP tag.