From: Wilfried Goesgens Date: Sun, 26 Dec 2010 10:56:41 +0000 (+0100) Subject: libevent Migration: X-Git-Tag: v8.11~1140 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=3de7cf767571d26d4f4852577b080f9264d34f91 libevent Migration: - hook in libevent into shutdown mechanism, so we can cleanly shutdown citserver again. --- diff --git a/citadel/event_client.c b/citadel/event_client.c index bd28d10ef..ba18107d7 100644 --- a/citadel/event_client.c +++ b/citadel/event_client.c @@ -77,6 +77,11 @@ extern EventContextAttach EventContextAttachPtr; int QueueEventContext(void *Ctx, AsyncIO *IO, EventContextAttach CB) { citthread_mutex_lock(&EventQueueMutex); + if (event_add_pipe[1] == -1) { + citthread_mutex_unlock(&EventQueueMutex); + + return -1; + } QueueEventAddPtr = Ctx; EventContextAttachPtr = CB; @@ -90,8 +95,16 @@ int QueueEventContext(void *Ctx, AsyncIO *IO, EventContextAttach CB) int ShutDownEventQueue(void) { + citthread_mutex_lock(&EventQueueMutex); + if (event_add_pipe[1] == -1) { + citthread_mutex_unlock(&EventQueueMutex); + + return -1; + } write(event_add_pipe[1], "x_", 1); close(event_add_pipe[1]); + event_add_pipe[1] = -1; + citthread_mutex_unlock(&EventQueueMutex); return 0; } diff --git a/citadel/event_client.h b/citadel/event_client.h index e9c1a9d73..f20152f8d 100644 --- a/citadel/event_client.h +++ b/citadel/event_client.h @@ -29,6 +29,7 @@ struct AsyncIO { void FreeAsyncIOContents(AsyncIO *IO); int QueueEventContext(void *Ctx, AsyncIO *IO, EventContextAttach CB); +int ShutDownEventQueue(void); void InitEventIO(AsyncIO *IO, void *pData, diff --git a/citadel/modules/eventclient/serv_evventclient.c b/citadel/modules/eventclient/serv_evventclient.c index 4de6fff6a..bb13c9dee 100644 --- a/citadel/modules/eventclient/serv_evventclient.c +++ b/citadel/modules/eventclient/serv_evventclient.c @@ -1,25 +1,4 @@ /* - * This module is an SMTP and ESMTP implementation for the Citadel system. - * It is compliant with all of the following: - * - * RFC 821 - Simple Mail Transfer Protocol - * RFC 876 - Survey of SMTP Implementations - * RFC 1047 - Duplicate messages and SMTP - * RFC 1652 - 8 bit MIME - * RFC 1869 - Extended Simple Mail Transfer Protocol - * RFC 1870 - SMTP Service Extension for Message Size Declaration - * RFC 2033 - Local Mail Transfer Protocol - * RFC 2197 - SMTP Service Extension for Command Pipelining - * RFC 2476 - Message Submission - * RFC 2487 - SMTP Service Extension for Secure SMTP over TLS - * RFC 2554 - SMTP Service Extension for Authentication - * RFC 2821 - Simple Mail Transfer Protocol - * RFC 2822 - Internet Message Format - * RFC 2920 - SMTP Service Extension for Command Pipelining - * - * The VRFY and EXPN commands have been removed from this implementation - * because nobody uses these commands anymore, except for spammers. - * * Copyright (c) 1998-2009 by the citadel.org team * * This program is free software; you can redistribute it and/or modify diff --git a/citadel/threads.c b/citadel/threads.c index 1afad1cfc..f1be5a39a 100644 --- a/citadel/threads.c +++ b/citadel/threads.c @@ -58,6 +58,7 @@ #include "citserver.h" #include "sysdep_decls.h" #include "context.h" +#include "event_client.h" /* * define this to use the new worker_thread method of handling connections @@ -358,6 +359,8 @@ void CtdlThreadStopAll(void) //FIXME: The signalling of the condition should not be in the critical_section // We need to build a list of threads we are going to signal and then signal them afterwards + ShutDownEventQueue(); + CtdlThreadNode *this_thread; begin_critical_section(S_THREAD_LIST);