Commit Graph
16 Commits
Author SHA1 Message Date
Mike Brady 532c77eb23 clang-format only 2017-11-12 14:25:09 +01:00
Belbo b98e6a9ac0 Fixed race condition when stopping other threads with SIGUSR1
Many threads have a main loop that checks some exit variable in the loop condition. To stop a thread, another thread sets that exit variable, sends a SIGUSR1 to that thread to get it out of blocking calls like read(), write() or select(), and finally joins it.

There was a race condition though: if the signal arrived after the loop condition was checked but before the blocking system function was entered, the target thread essentially ignored the signal, made the blocking call anyway, and could get stuck forever there.

The only way around this race condition is to block SIGUSR1 in the destination thread during the critical time interval. This requires that the blocking system call and the call to unblock SIGUSR1 be an atomic unit. There is only one system call that makes this possible: pselect(), which takes a signal mask to replace the current signal mask with, but only while pselect() runs. Other functions like read(), recv(), write() and sendto() may only be called if we can be sure that they don't block. For this purpose, the file descriptors must be set to non-blocking mode and we must prepend the call to them with a call to pselect() to block until the socket becomes readable/writable.
2017-11-01 20:46:05 +01:00
Mike Brady 5fba88cd60 Add an exit diagnostic, clean up a dbus flag 2017-10-30 10:37:34 +01:00
Mike Brady 139c18bf3e Add avahi code to look for the rmeote control information for the client and get the port number from it. 2017-10-05 17:39:32 +01:00
Mike Brady 825b418b94 Make PID directory path creation recursive and tidy up some code formatting. 2017-09-24 15:52:26 +01:00
Mike Brady 064bd293c5 Tidy up with a clang-format 2016-09-11 10:35:53 +01:00
Mike Brady bfadbf3801 Add ability to change regtype; clean up some diagnostic messages. 2016-04-01 16:30:36 +01:00
Mke Brady 87a0475c16 Reformat using clang-format. 2015-06-01 23:16:50 +01:00
Mike Brady 99df6fe537 Use config.metadata_enabled in place of config.meta-dir. 2015-05-04 17:20:50 +01:00
Mke Brady 75f3f912c7 Make metadata support a compile-time option. Clean up a few definitions. 2015-04-03 13:47:58 +01:00
Mke Brady 46412eb148 Reinistate after bugfix: Change bonjour advertisement if metadata sought, add sender name metadata, use own base64 encoder 2015-02-26 10:56:49 +00:00
Mke Brady bcca3a6f88 Revert "Change bonjour advertisement if metadata sought, add sender name metadata, use own base64 encoder"
This reverts commit 7d339b1b37.

UNstable partial updates.
2015-02-25 20:55:29 +00:00
Mike Brady 7d339b1b37 Change bonjour advertisement if metadata sought, add sender name metadata, use own base64 encoder 2015-02-25 18:25:29 +00:00
Mike Brady ac59141848 Stop incorrect warning about malloc/free and add an ignore int to stop another warning 2014-08-24 16:18:46 +01:00
Paul LietarandJames Laird 958fceb60a Add a command-line option to force the mDNS backend
Add this option to the system-v init script.
2013-10-22 10:33:41 +11:00
Paul LietarandJames Laird 3896909080 Reorganize mDNS advertisement
mDNS is now handled more or less in the same way audio is.
Multiple mDNS backends are available, shairport tries them all until one
works.

This makes it, IMHO, cleaner, and easier to add other mDNS backends in
the future, such as using tinysvcmdns or dns-sd library.
Also it will also allow to define mDNS backends as plugins, in a similar
way it is done in PR #230.
2013-10-22 10:33:41 +11:00