X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Ffatal-signal.c;h=81f8f284424099e6c4bac28f0e195556dc73f920;hb=7f009380f61edda538c4c4d6333a14014258ca8f;hp=f6f913ebc0b1d2aa19923240344f40c88df37384;hpb=c874f17fc743b38295f6059ab6554561b7555724;p=sliver-openvswitch.git diff --git a/lib/fatal-signal.c b/lib/fatal-signal.c index f6f913ebc..81f8f2844 100644 --- a/lib/fatal-signal.c +++ b/lib/fatal-signal.c @@ -28,10 +28,10 @@ #include "shash.h" #include "socket-util.h" #include "util.h" - -#define THIS_MODULE VLM_fatal_signal #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(fatal_signal); + /* Signals to catch. */ static const int fatal_signals[] = { SIGTERM, SIGINT, SIGHUP, SIGALRM }; @@ -134,6 +134,17 @@ fatal_signal_handler(int sig_nr) stored_sig_nr = sig_nr; } +/* Check whether a fatal signal has occurred and, if so, call the fatal signal + * hooks and exit. + * + * This function is called automatically by poll_block(), but specialized + * programs that may not always call poll_block() on a regular basis should + * also call it periodically. (Therefore, any function with "block" in its + * name should call fatal_signal_run() each time it is called, either directly + * or through poll_block(), because such functions can only used by specialized + * programs that can afford to block outside their main loop around + * poll_block().) + */ void fatal_signal_run(void) { @@ -204,9 +215,7 @@ fatal_signal_add_file_to_unlink(const char *file) fatal_signal_add_hook(unlink_files, cancel_files, NULL, true); } - if (!shash_find(&files, file)) { - shash_add(&files, file, NULL); - } + shash_add_once(&files, file, NULL); } /* Unregisters 'file' from being unlinked when the program terminates via @@ -240,7 +249,7 @@ fatal_signal_unlink_file_now(const char *file) static void unlink_files(void *aux OVS_UNUSED) { - do_unlink_files(); + do_unlink_files(); } static void