]> mj.ucw.cz Git - libucw.git/commit
Fixed thread safety of signal handling.
authorMartin Mares <mj@ucw.cz>
Sat, 9 Dec 2006 22:24:44 +0000 (23:24 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 9 Dec 2006 22:24:44 +0000 (23:24 +0100)
commit36689e3146ae5c7aca4112b9da88112c7bc85755
tree53a42aa9228fd514e0a4d1943ea306abb2fd2c72
parenta7fc20538dc1a483eb77aa94d182f3e1f27f1ce8
Fixed thread safety of signal handling.

Signals delivery is generally not deterministic in multi-threaded programs,
but SIGSEGV is always sent by the kernel to the thread which caused the fault.

Replaced the global signal handler array by a pointer in the per-thread
context and replaced saving of original handles (which was wrong even in
some non-threaded cases) by locked use counters.

Also moved logging of the SIGSEGV error message out of the signal handler
to be sure there are no clashes.

When libucw is compiled without threading, everything is nearly as simple
as before, because the thread context struct is static and all locks
disappear.
lib/THREADS
lib/lib.h
lib/lizard-safe.c
lib/sighandler.c
lib/threads.h