diff options
author | Simon Rettberg | 2019-08-28 13:07:13 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-08-28 13:07:13 +0200 |
commit | ac1bf45ebdd630fbc9ad2c1fa3c0ea99f5206799 (patch) | |
tree | 951388f8267c0194a142bf13d99b947ee7f820e6 /src/server/globals.h | |
parent | [SERVER] Remove old comments (diff) | |
download | dnbd3-ac1bf45ebdd630fbc9ad2c1fa3c0ea99f5206799.tar.gz dnbd3-ac1bf45ebdd630fbc9ad2c1fa3c0ea99f5206799.tar.xz dnbd3-ac1bf45ebdd630fbc9ad2c1fa3c0ea99f5206799.zip |
[SERVER] Make signal handling more POSIX
According to POSIX, a signal sent to a PID can be delivered to an
arbitrary thread of that process that hasn't the signal blocked. This
seens to never happen on Linux, but would mess things up since the code
expected the main signal handler to only be executed by the main thread.
This should now be fixed by examining the destination PID of the signal
as well as the ID of the thread currently running the signal handler. If
we notice the signal wasn't sent by our own PID and the handler is not
currently run by the main thread, we re-send the signal to the main
thread. Otherwise, if the signal was sent by our own PID but the handler
is not run in the main thread, do nothing. This way we can use
pthread_kill() to wake up threads that might be stuck in a blocking
syscall when it's time to shut down.
Diffstat (limited to 'src/server/globals.h')
-rw-r--r-- | src/server/globals.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/server/globals.h b/src/server/globals.h index 5dd205a..f940666 100644 --- a/src/server/globals.h +++ b/src/server/globals.h @@ -138,6 +138,7 @@ struct _dnbd3_client char hostName[HOSTNAMELEN]; // inet_ntop version of host pthread_mutex_t sendMutex; // Held while writing to sock if image is incomplete (since uplink uses socket too) pthread_mutex_t lock; + pthread_t thread; }; // ####################################################### |