* add function to cleanly shutdown server threads
authorWilfried Göesgens <willi@citadel.org>
Thu, 3 Jun 2010 22:46:40 +0000 (22:46 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 3 Jun 2010 22:46:40 +0000 (22:46 +0000)
citadel/context.c
citadel/include/ctdl_module.h
citadel/modules/smtp/serv_smtp.c

index 32287e16d3e4fed7bf9f1c1add0ceb109b60ef2c..5f964be4a0e443dc378c0593fc5c7e6699eadde5 100644 (file)
@@ -459,6 +459,18 @@ void CtdlFillSystemContext(CitContext *context, char *name)
        }
 }
 
+/*
+ * flush it again...
+ */
+void CtdlClearSystemContext(void)
+{
+       CitContext *CCC = CC;
+
+       FreeStrBuf(&CCC->lBuf);
+       memset(CCC, 0, sizeof(CitContext));
+       citthread_setspecific(MyConKey, NULL);
+}
+
 /*
  * Cleanup any contexts that are left lying around
  */
index 290c9054306e7a89290b1bdb8086cd2b4e13cfc4..0db356a6ff458356849d397f99929e0e7081265d 100644 (file)
@@ -195,7 +195,7 @@ void CtdlThreadAllocTSD(void);
  */
 struct CitContext *CtdlGetContextArray (int *count);
 void CtdlFillSystemContext(struct CitContext *context, char *name);
-
+void CtdlClearSystemContext(void);
 int CtdlTrySingleUser(void);
 void CtdlEndSingleUser(void);
 int CtdlWantSingleUser(void);
index f212256711b8b67f566ba3cadd8befbc4f05a0e0..6bbe6471889c84e42f71f78d084602f0f8f049da 100644 (file)
@@ -1742,9 +1742,9 @@ void *smtp_do_queue(void *arg) {
        int num_processed = 0;
        struct CitContext smtp_queue_CC;
 
+       CtdlFillSystemContext(&smtp_queue_CC, "SMTP Send");
        CtdlLogPrintf(CTDL_INFO, "SMTP client: processing outbound queue\n");
 
-       CtdlFillSystemContext(&smtp_queue_CC, "SMTP Send");
        citthread_setspecific(MyConKey, (void *)&smtp_queue_CC );
 
        if (CtdlGetRoom(&CC->room, SMTP_SPOOLOUT_ROOM) != 0) {
@@ -1756,6 +1756,8 @@ void *smtp_do_queue(void *arg) {
 
        citthread_mutex_unlock (&smtp_send_lock);
        CtdlLogPrintf(CTDL_INFO, "SMTP client: queue run completed; %d messages processed\n", num_processed);
+
+       CtdlClearSystemContext();
        return(NULL);
 }