Possibly unsafe handling of signals with pthreads
Created by: dhke
Just a heads up, I'm not sure if this is much of a problem in practice: signals and pthreads don't really mix well.
In particular:
-
std::cout
and friends are not async-safe and thus not safe to be called from a signal handler. The same probably holds for resetting and re-reading the mapfile during signal handling. - Since signals maybe delivered to any thread, it is unclear, which thread (main or milter) is executing the signal handler. Since now,
mapfile::Map
isn't thread safe (and probably cannot be used safely from a signal handler, too). this might also be a potential concurrency issue.
Given the fact that you cannot really to anything pthread-related while a signal handler is active (none of the pthread*()
functions are async-safe), to be on the safe side, one needs a special signal handler thread that continuously loops over sigsuspend()
and does the appropriate actions, while all other threads run with blocked signals.
I'll see if I can fix this via some patches.