diff --git a/COPYING.TELO b/COPYING.CYTO similarity index 100% rename from COPYING.TELO rename to COPYING.CYTO diff --git a/LICENSE b/LICENSE index 56fdd03..5d9765c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,8 +1,8 @@ -For the files src/XML/*, tools/*, src/include/XML.h, and Makefile, see COPYING.CC0 -For the file src/Signal.c, it is based on Telodendria, which requires COPYING.TELO +For the files src/XML/*, tools/*, src/include/XML.h, etc/*, and Makefile, see COPYING.CC0 to be present. For any other file in src/, see COPYING.AGPL as the primary license. +As Parsee depends on Cytoplasm, its license is left here in COPYING.CYTO + COPYING.CC0 and COPYING.TELO are NOT the primary licenses. COPYING.TELO is present -because of the terms of the Telodendria license, which some of its code is derived -in src/Signal.c, and COPYING.CC0 ONLY applies to the XML parser code. +because of the terms of the Telodendria licence, used by Cytoplasm, and COPYING.CC0 ONLY applies to the XML parser code. diff --git a/src/Signal.c b/src/Signal.c index 179d84c..2d86b34 100644 --- a/src/Signal.c +++ b/src/Signal.c @@ -8,69 +8,46 @@ static HttpServer *server = NULL; static pthread_t xmpp_thr; -static bool valid = true; static XMPPComponent *jabber = NULL; static void SignalHandler(int signal) { - switch (signal) + if (server && (signal == SIGTERM || signal == SIGINT)) { - case SIGPIPE: + if (!server) + { return; - case SIGUSR1: - /* TODO: Soft-restart everything */ - return; - case SIGTERM: - case SIGINT: - if (!server) - { - return; - } + } - /* TODO: Better way to break out. */ - Log(LOG_INFO, "Killing thread..."); - XMPPFinishCompStream(jabber); - pthread_join(xmpp_thr, NULL); - valid = false; - Log(LOG_INFO, "Stopping server..."); - HttpServerStop(server); - break; + /* TODO: Better way to break out. */ + Log(LOG_INFO, "Killing thread..."); + XMPPFinishCompStream(jabber); + pthread_join(xmpp_thr, NULL); + Log(LOG_INFO, "Stopping server..."); + HttpServerStop(server); + return; } } bool ParseeInitialiseSignals(HttpServer *s, pthread_t xmpp, XMPPComponent *j) { - struct sigaction sigAction; - bool ret = true; + struct sigaction sa; server = s; xmpp_thr = xmpp; jabber = j; - valid = true; + sigfillset(&sa.sa_mask); + sa.sa_handler = SignalHandler; + sa.sa_flags = SA_RESTART; - sigAction.sa_handler = SignalHandler; - sigfillset(&sigAction.sa_mask); - sigAction.sa_flags = SA_RESTART; - -#define SIGACTION(sig, act, oact) \ - if (sigaction(sig, act, oact) < 0) \ - { \ - Log(LOG_ERR, "Unable to install signal handler: %s", #sig); \ - ret = false; \ - } \ - else \ - { \ - Log(LOG_DEBUG, "Installed signal handler: %s", #sig); \ +#define Register(act) (sigaction(act, &sa, NULL) >= 0) + if (!Register(SIGTERM) || !Register(SIGINT)) + { + return false; } - - SIGACTION(SIGINT, &sigAction, NULL); - SIGACTION(SIGTERM, &sigAction, NULL); - SIGACTION(SIGPIPE, &sigAction, NULL); - SIGACTION(SIGUSR1, &sigAction, NULL); /* Make USR1 do a softrestart */ -#undef SIGACTION - - return ret; +#undef Register + return true; }