The only real highlight of this release is that
SIGINT (the signal sent
when you press Ctrl-C) is now handled using
Mono.Unix.UnixSignal from the
Mono.Posix assembly. This is significant because it means SDB will no longer
potentially crash when interrupted this way.
SIGINT handler was a managed method. This was problematic
because managed/native trampolines contain all sorts of signal-unsafe code that
can make the I/O layer in Mono blow up in various interesting ways. There’s no
real workaround for this. Managed signal handlers just aren’t practical.
UnixSignal solves it is by having signal handlers in a helper library
written in C. Those are then registered from managed land. This way, there’s no
interference from Mono in the process. When a signal is delivered, the helper
library increments a counter and returns. Managed land can then call
UnixSignal which observes any change in the counter and returns. It is
then clear that a signal has been delivered, and managed land can do whatever
it needs to do.
In effect, signal handling happens synchronously, rather than asynchronously,
which is how signals are normally delivered. This does mean that managed land
has to have a separate thread that waits on the
UnixSignal, or at least poll
it with a timeout every so often. On the other hand, this mechanism is much,
much safer than attempting to write signal-safe code in a signal handler.
In the case of SDB, a separate thread is started when the Ctrl-C handler is
set. This thread just waits indefinitely on the
thread is simply aborted when the handler is unset.