Portability fixes. Mostly for Android.
Now uses SIGUSR2 to terminate threads since sigwaitinfo() is not as
common (Android) as sigtimedwait() and also pthread_cancel() is not
available on Android. SIGCHLD is used in the main thread to wait for
all other clients to disconnect before exiting.
The drawback of using sigtimedwait() (because mostly of the lack of
pthread_cancel()) is that some threads cannot block while waiting for
an operation. The (tcp_)accept_thread(), for example, needs to set the
file descriptor to O_NONBLOCK to be able to check whether it recieved
SIGUSR2 from the main thread (shutdown/reload). Its less fast since
there needs to be a wait interval between accept() calls to prevent
CPU spikes. It's about twice as slow as sigwaitinfo() with the current
wait interval, at least in accept_thread(), but still should be fast
enough for most folks.
13 files changed: