libevent Migration:
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 26 Dec 2010 10:56:41 +0000 (11:56 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 26 Dec 2010 10:56:41 +0000 (11:56 +0100)
 - hook in libevent into shutdown mechanism, so we can cleanly shutdown citserver again.

citadel/event_client.c
citadel/event_client.h
citadel/modules/eventclient/serv_evventclient.c
citadel/threads.c

index bd28d10ef0e40ecf388775bdb84a9eddb3482191..ba18107d76c1307c46ab7754c4c39796eb28dc02 100644 (file)
@@ -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;
 }
 
index e9c1a9d73b777110d7c23a9c5021bd1f13a5c88c..f20152f8d933319477d08bd571e1163ece28efc0 100644 (file)
@@ -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, 
index 4de6fff6add53efc2d4c938bc0fb1d8a639c4449..bb13c9dee26e8b70f4e8f2b9463ccb57d79ff4e5 100644 (file)
@@ -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
index 1afad1cfcac72aa64d8a699c58cf070b821d1b42..f1be5a39ac1737806ec93c5a68212dd1b7f8347d 100644 (file)
@@ -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);