mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 21:35:10 +00:00
[FIX] Kill Parsee on unexcepted stream closure
This commit is contained in:
parent
ff5f085b7f
commit
02a89270c0
6 changed files with 49 additions and 15 deletions
21
src/Signal.c
21
src/Signal.c
|
|
@ -6,39 +6,40 @@
|
|||
|
||||
#include <XMPP.h>
|
||||
|
||||
static HttpServer *server = NULL;
|
||||
static ParseeData *data;
|
||||
static pthread_t xmpp_thr;
|
||||
static XMPPComponent *jabber = NULL;
|
||||
|
||||
static void
|
||||
SignalHandler(int signal)
|
||||
{
|
||||
if (server && (signal == SIGTERM || signal == SIGINT))
|
||||
if (data->server && (signal == SIGTERM || signal == SIGINT))
|
||||
{
|
||||
Log(LOG_INFO, "Killing thread...");
|
||||
XMPPFinishCompStream(jabber);
|
||||
|
||||
pthread_mutex_lock(&data->halt_lock);
|
||||
data->halted = true;
|
||||
pthread_mutex_unlock(&data->halt_lock);
|
||||
|
||||
XMPPFinishCompStream(data->jabber);
|
||||
pthread_join(xmpp_thr, NULL);
|
||||
Log(LOG_INFO, "Stopping server...");
|
||||
HttpServerStop(server);
|
||||
HttpServerStop(data->server);
|
||||
return;
|
||||
}
|
||||
if (signal == SIGPIPE)
|
||||
{
|
||||
Log(LOG_DEBUG, "Caught a SIGPIPE...");
|
||||
XMPPFinishCompStream(jabber);
|
||||
pthread_join(xmpp_thr, NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ParseeInitialiseSignals(HttpServer *s, pthread_t xmpp, XMPPComponent *j)
|
||||
ParseeInitialiseSignals(ParseeData *d, pthread_t xmpp)
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
server = s;
|
||||
data = d;
|
||||
xmpp_thr = xmpp;
|
||||
jabber = j;
|
||||
|
||||
sigfillset(&sa.sa_mask);
|
||||
sa.sa_handler = SignalHandler;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue