Revert "SMTP-Client: move the client-shutdown procedure into the DB-Thread; we musn...
authorArt Cancro <ajc@uncensored.citadel.org>
Fri, 13 Apr 2012 16:06:49 +0000 (12:06 -0400)
committerArt Cancro <ajc@uncensored.citadel.org>
Fri, 13 Apr 2012 16:06:49 +0000 (12:06 -0400)
This reverts commit 4fdc7029ccef0500fd8f968413c2b82db8fe2f29.

citadel/event_client.c
citadel/event_client.h
citadel/modules/extnotify/funambol65.c
citadel/modules/network/serv_networkclient.c
citadel/modules/pop3client/serv_pop3client.c
citadel/modules/rssclient/serv_rssclient.c
citadel/modules/smtp/serv_smtpeventclient.c
citadel/modules/smtp/smtp_clienthandlers.h
citadel/modules/urldeshortener/serv_expand_shorter_urls.c

index e2b3ba69a84d2f7597aa05f3f80fc329aff5e5bb..5087dd9ebda758bfe9285480be52aad464bf06aa 100644 (file)
@@ -127,8 +127,8 @@ void ShutDownDBCLient(AsyncIO *IO)
        EVM_syslog(LOG_DEBUG, "DBEVENT Terminating.\n");
        ev_cleanup_stop(event_db, &IO->db_abort_by_shutdown);
 
-       assert(IO->DBTerminate);
-       IO->DBTerminate(IO);
+       assert(IO->Terminate);
+       IO->Terminate(IO);
 }
 
 void
@@ -906,7 +906,6 @@ void InitIOStruct(AsyncIO *IO,
                  IO_CallBack SendDone,
                  IO_CallBack ReadDone,
                  IO_CallBack Terminate,
-                 IO_CallBack DBTerminate,
                  IO_CallBack ConnFail,
                  IO_CallBack Timeout,
                  IO_CallBack ShutdownAbort)
@@ -921,7 +920,6 @@ void InitIOStruct(AsyncIO *IO,
        IO->SendDone      = SendDone;
        IO->ReadDone      = ReadDone;
        IO->Terminate     = Terminate;
-       IO->DBTerminate   = DBTerminate;
        IO->LineReader    = LineReader;
        IO->ConnFail      = ConnFail;
        IO->Timeout       = Timeout;
@@ -945,7 +943,6 @@ int InitcURLIOStruct(AsyncIO *IO,
                     const char* Desc,
                     IO_CallBack SendDone,
                     IO_CallBack Terminate,
-                    IO_CallBack DBTerminate,
                     IO_CallBack ShutdownAbort)
 {
        IO->Data          = Data;
@@ -953,9 +950,8 @@ int InitcURLIOStruct(AsyncIO *IO,
        IO->CitContext    = CloneContext(CC);
        ((CitContext *)IO->CitContext)->session_specific_data = (char*) Data;
 
-       IO->SendDone      = SendDone;
-       IO->Terminate     = Terminate;
-       IO->DBTerminate   = DBTerminate;
+       IO->SendDone = SendDone;
+       IO->Terminate = Terminate;
        IO->ShutdownAbort = ShutdownAbort;
 
        strcpy(IO->HttpReq.errdesc, Desc);
index 6ae8b27d3b740aa5d06e7556ccda0a87f4e550ec..217ffc26e372ef3d57b303caf57763cff23e8e07 100644 (file)
@@ -146,7 +146,6 @@ struct AsyncIO {
        IO_CallBack ReadDone, /* Theres new data to read... */
                SendDone,     /* we may send more data */
                Terminate,    /* shutting down... */
-               DBTerminate,  /* shutting down... */
                Timeout,      /* Timeout handler;may also be conn. timeout */
                ConnFail,     /* What to do when one connection failed? */
                ShutdownAbort,/* we're going down. make your piece. */
@@ -275,7 +274,6 @@ void InitIOStruct(AsyncIO *IO,
                  IO_CallBack SendDone,
                  IO_CallBack ReadDone,
                  IO_CallBack Terminate,
-                 IO_CallBack DBTerminate,
                  IO_CallBack ConnFail,
                  IO_CallBack Timeout,
                  IO_CallBack ShutdownAbort);
@@ -285,7 +283,6 @@ int InitcURLIOStruct(AsyncIO *IO,
                     const char* Desc,
                     IO_CallBack SendDone,
                     IO_CallBack Terminate,
-                    IO_CallBack DBTerminate,
                     IO_CallBack ShutdownAbort);
 
 eNextState ReAttachIO(AsyncIO *IO,
index f4b0d8d38fc9b8943de839e903e1d08e9773c2bf..03f478ca6ab6ae2cb3a1aac7c79de6577c65d9f5 100644 (file)
@@ -49,7 +49,6 @@
 
 eNextState EvaluateResult(AsyncIO *IO);
 eNextState ExtNotifyTerminate(AsyncIO *IO);
-eNextState ExtNotifyTerminateDB(AsyncIO *IO);
 eNextState ExtNotifyShutdownAbort(AsyncIO *IO);
 
 /*
@@ -82,7 +81,6 @@ int notify_http_server(char *remoteurl,
                               "Citadel ExtNotify",
                               EvaluateResult,
                               ExtNotifyTerminate,
-                              ExtNotifyTerminateDB,
                               ExtNotifyShutdownAbort))
        {
                syslog(LOG_ALERT, "Unable to initialize libcurl.\n");
@@ -297,11 +295,6 @@ eNextState EvaluateResult(AsyncIO *IO)
        return 0;
 }
 
-eNextState ExtNotifyTerminateDB(AsyncIO *IO)
-{
-       free(IO);
-       return eAbort;
-}
 eNextState ExtNotifyTerminate(AsyncIO *IO)
 {
        free(IO);
index 51db451989d96192576a3a7aad7998fdb11687c1..0023d83631904b0dfa1eb5dbe2d359e3c2fa84a8 100644 (file)
@@ -157,7 +157,6 @@ void DeleteNetworker(void *vptr)
        FreeStrBuf(&NW->port);
        FreeStrBuf(&NW->secret);
        FreeStrBuf(&NW->Url);
-       FreeStrBuf(&NW->IO.ErrMsg);
        FreeAsyncIOContents(&NW->IO);
        free(NW);
 }
@@ -809,13 +808,6 @@ eNextState NWC_Terminate(AsyncIO *IO)
        return eAbort;
 }
 
-eNextState NWC_TerminateDB(AsyncIO *IO)
-{
-       EVN_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);
-       FinalizeNetworker(IO);
-       return eAbort;
-}
-
 eNextState NWC_Timeout(AsyncIO *IO)
 {
        AsyncNetworker *NW = IO->Data;
@@ -889,7 +881,6 @@ void RunNetworker(AsyncNetworker *NW)
                     NWC_DispatchWriteDone,
                     NWC_DispatchReadDone,
                     NWC_Terminate,
-                    NWC_TerminateDB,
                     NWC_ConnFail,
                     NWC_Timeout,
                     NWC_Shutdown);
index fa151f6694707e9fbae3c8f9ca883ba957be8c04..0a97df2cc971b402c431c4b6daf5a54dbe9ae3c6 100644 (file)
@@ -706,14 +706,6 @@ eNextState POP3_C_Terminate(AsyncIO *IO)
        FinalizePOP3AggrRun(IO);
        return eAbort;
 }
-eNextState POP3_C_TerminateDB(AsyncIO *IO)
-{
-///    pop3aggr *pMsg = (pop3aggr *)IO->Data;
-
-       syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__);
-       FinalizePOP3AggrRun(IO);
-       return eAbort;
-}
 eNextState POP3_C_Timeout(AsyncIO *IO)
 {
        pop3aggr *pMsg = IO->Data;
@@ -891,7 +883,6 @@ int pop3_do_fetching(pop3aggr *cpptr)
                     POP3_C_DispatchWriteDone,
                     POP3_C_DispatchReadDone,
                     POP3_C_Terminate,
-                    POP3_C_TerminateDB,
                     POP3_C_ConnFail,
                     POP3_C_Timeout,
                     POP3_C_Shutdown);
index 6d4392393610785433efc3caad7f91067519afa5..8a3ba63549a5aadacfa2bfd88d0cc25138541a01 100644 (file)
@@ -69,7 +69,6 @@ HashList *RSSQueueRooms = NULL; /* rss_room_counter */
 HashList *RSSFetchUrls = NULL; /*->rss_aggregator;->RefCount access locked*/
 
 eNextState RSSAggregator_Terminate(AsyncIO *IO);
-eNextState RSSAggregator_TerminateDB(AsyncIO *IO);
 eNextState RSSAggregator_ShutdownAbort(AsyncIO *IO);
 struct CitContext rss_CC;
 
@@ -181,17 +180,6 @@ eNextState RSSAggregator_Terminate(AsyncIO *IO)
        return eAbort;
 }
 
-eNextState RSSAggregator_TerminateDB(AsyncIO *IO)
-{
-       rss_aggregator *RSSAggr = (rss_aggregator *)IO->Data;
-
-       EVM_syslog(LOG_DEBUG, "RSS: Terminating.\n");
-
-
-       UnlinkRSSAggregator(RSSAggr);
-       return eAbort;
-}
-
 eNextState RSSAggregator_ShutdownAbort(AsyncIO *IO)
 {
        const char *pUrl;
@@ -306,7 +294,6 @@ int rss_do_fetching(rss_aggregator *Cfg)
                               "Citadel RSS Client",
                               RSSAggregator_ParseReply,
                               RSSAggregator_Terminate,
-                              RSSAggregator_TerminateDB,
                               RSSAggregator_ShutdownAbort))
        {
                syslog(LOG_ALERT, "Unable to initialize libcurl.\n");
index e5c1cee00931f84c887addfcbdb51002b8eab444..90a36b23539f6582b823bd1ec4ce023b834b9562 100644 (file)
@@ -117,15 +117,10 @@ eNextState SMTP_C_DispatchReadDone(AsyncIO *IO);
 eNextState SMTP_C_DispatchWriteDone(AsyncIO *IO);
 eNextState SMTP_C_DNSFail(AsyncIO *IO);
 eNextState SMTP_C_Terminate(AsyncIO *IO);
-eNextState SMTP_C_TerminateDB(AsyncIO *IO);
 eReadState SMTP_C_ReadServerStatus(AsyncIO *IO);
 
 eNextState mx_connect_ip(AsyncIO *IO);
 eNextState get_one_mx_host_ip(AsyncIO *IO);
-eNextState FinalizeMessageSendDB(AsyncIO *IO);
-eNextState FinalizeMessageSend_DB1(AsyncIO *IO);
-eNextState FinalizeMessageSend_DB2(AsyncIO *IO);
-eNextState FinalizeMessageSend_DB3(AsyncIO *IO);
 
 /******************************************************************************
  * So, we're finished with sending (regardless of success or failure)         *
@@ -133,12 +128,16 @@ eNextState FinalizeMessageSend_DB3(AsyncIO *IO);
  * we need to free the memory and send bounce messages (on terminal failure)  *
  * else we just free our SMTP-Message struct.                                 *
  ******************************************************************************/
-inline void FinalizeMessageSend_1(AsyncIO *IO)
+void FinalizeMessageSend(SmtpOutMsg *Msg)
 {
-       SmtpOutMsg *Msg = IO->Data;
-       Msg->IDestructQueItem = DecreaseQReference(Msg->MyQItem);
+       int IDestructQueItem;
+       int nRemain;
+       StrBuf *MsgData;
+       AsyncIO *IO = &Msg->IO;
+
+       IDestructQueItem = DecreaseQReference(Msg->MyQItem);
 
-       Msg->nRemain = CountActiveQueueEntries(Msg->MyQItem);
+       nRemain = CountActiveQueueEntries(Msg->MyQItem);
 
        if (Msg->MyQEntry->Active && 
            CheckQEntryIsBounce(Msg->MyQEntry))
@@ -147,19 +146,10 @@ inline void FinalizeMessageSend_1(AsyncIO *IO)
                Msg->MyQItem->SendBounceMail |= (1<<Msg->MyQEntry->Status);
        }
 
-       if ((Msg->nRemain > 0) || Msg->IDestructQueItem)
-               Msg->QMsgData = SerializeQueueItem(Msg->MyQItem);
+       if ((nRemain > 0) || IDestructQueItem)
+               MsgData = SerializeQueueItem(Msg->MyQItem);
        else
-               Msg->QMsgData = NULL;
-}
-eNextState FinalizeMessageSend(SmtpOutMsg *Msg)
-{
-       return QueueDBOperation(&Msg->IO, FinalizeMessageSend_DB1);
-}
-
-inline void FinalizeMessageSend_DB_1(AsyncIO *IO)
-{
-       SmtpOutMsg *Msg = IO->Data;
+               MsgData = NULL;
 
        /*
         * Uncompleted delivery instructions remain, so delete the old
@@ -167,35 +157,11 @@ inline void FinalizeMessageSend_DB_1(AsyncIO *IO)
         */
        EVS_syslog(LOG_DEBUG, "SMTPQD: %ld", Msg->MyQItem->QueMsgID);
        CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, &Msg->MyQItem->QueMsgID, 1, "");
-}
-eNextState FinalizeMessageSend_DB1(AsyncIO *IO)
-{
-       FinalizeMessageSend_1(IO);
-       FinalizeMessageSend_DB_1(IO);
-       return NextDBOperation(IO, FinalizeMessageSend_DB2);
-}
-
 
-inline void FinalizeMessageSend_DB_2(AsyncIO *IO)
-{
-       SmtpOutMsg *Msg = IO->Data;
-
-       if (Msg->IDestructQueItem)
+       if (IDestructQueItem)
                smtpq_do_bounce(Msg->MyQItem, Msg->msgtext);
-}
-eNextState FinalizeMessageSend_DB2(AsyncIO *IO)
-{
-       FinalizeMessageSend_DB_2(IO);
-
-       return NextDBOperation(IO, FinalizeMessageSend_DB3);
-}
-
-
-inline void FinalizeMessageSend_DB_3(AsyncIO *IO)
-{
-       SmtpOutMsg *Msg = IO->Data;
 
-       if (Msg->nRemain > 0)
+       if (nRemain > 0)
        {
                struct CtdlMessage *msg;
                msg = malloc(sizeof(struct CtdlMessage));
@@ -203,7 +169,7 @@ inline void FinalizeMessageSend_DB_3(AsyncIO *IO)
                msg->cm_magic = CTDLMESSAGE_MAGIC;
                msg->cm_anon_type = MES_NORMAL;
                msg->cm_format_type = FMT_RFC822;
-               msg->cm_fields['M'] = SmashStrBuf(&Msg->QMsgData);
+               msg->cm_fields['M'] = SmashStrBuf(&MsgData);
                msg->cm_fields['U'] = strdup("QMSG");
                Msg->MyQItem->QueMsgID =
                        CtdlSubmitMsg(msg, NULL, SMTP_SPOOLOUT_ROOM, QP_EADDR);
@@ -215,24 +181,12 @@ inline void FinalizeMessageSend_DB_3(AsyncIO *IO)
                                   &Msg->MyQItem->MessageID,
                                   1,
                                   "");
-               FreeStrBuf(&Msg->QMsgData);
+               FreeStrBuf(&MsgData);
        }
-}
-eNextState FinalizeMessageSend_DB3(AsyncIO *IO)
-{
-       FinalizeMessageSend_DB_3(IO);
-       return eAbort;
-}
-
-eNextState FinalizeMessageSend_DB(AsyncIO *IO)
-{
-       SmtpOutMsg *Msg = IO->Data;
-
        RemoveContext(Msg->IO.CitContext);
-       if (Msg->IDestructQueItem)
+       if (IDestructQueItem)
                RemoveQItem(Msg->MyQItem);
        DeleteSmtpOutMsg(Msg);
-       return eAbort;
 }
 
 eNextState FailOneAttempt(AsyncIO *IO)
@@ -548,7 +502,6 @@ SmtpOutMsg *new_smtp_outmsg(OneQueItem *MyQItem,
                     SMTP_C_DispatchWriteDone,
                     SMTP_C_DispatchReadDone,
                     SMTP_C_Terminate,
-                    SMTP_C_TerminateDB,
                     SMTP_C_ConnFail,
                     SMTP_C_Timeout,
                     SMTP_C_Shutdown);
@@ -609,11 +562,7 @@ void smtp_try_one_queue_entry(OneQueItem *MyQItem,
                        StrBufPlain(Msg->MyQEntry->StatusMessage,
                                    HKEY("Invalid Recipient!"));
                }
-               FinalizeMessageSend_1(&Msg->IO);
-               FinalizeMessageSend_DB_1(&Msg->IO);
-               FinalizeMessageSend_DB_2(&Msg->IO);
-               FinalizeMessageSend_DB_3(&Msg->IO);
-               FinalizeMessageSend_DB(&Msg->IO);
+               FinalizeMessageSend(Msg);
        }
 }
 
@@ -702,12 +651,8 @@ eNextState SMTP_C_Terminate(AsyncIO *IO)
        SmtpOutMsg *Msg = IO->Data;
 
        EVS_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
-       return FinalizeMessageSend(Msg);
-}
-eNextState SMTP_C_TerminateDB(AsyncIO *IO)
-{
-       EVS_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
-       return FinalizeMessageSend_DB(IO);
+       FinalizeMessageSend(Msg);
+       return eAbort;
 }
 eNextState SMTP_C_Timeout(AsyncIO *IO)
 {
@@ -745,7 +690,8 @@ eNextState SMTP_C_Shutdown(AsyncIO *IO)
        Msg->MyQEntry->Status = 3;
        StrBufPlain(Msg->MyQEntry->StatusMessage,
                    HKEY("server shutdown during message submit."));
-       return FinalizeMessageSend(Msg);
+       FinalizeMessageSend(Msg);
+       return eAbort;
 }
 
 
index 38a7f58f4490795fc987ee98b8baeeb0b59e31b7..02b84e75fb213fa8e864885c2f457205e2f39fc8 100644 (file)
@@ -38,8 +38,6 @@ typedef struct _stmp_out_msg {
        long n;
        AsyncIO IO;
        long CXFlags;
-       int IDestructQueItem;
-       int nRemain;
 
        eSMTP_C_States State;
 
@@ -59,14 +57,11 @@ typedef struct _stmp_out_msg {
        ParsedURL *Relay;
        ParsedURL *pCurrRelay;
        StrBuf *msgtext;
-       StrBuf *QMsgData;
        const char *envelope_from;
-
        char user[1024];
        char node[1024];
        char name[1024];
        char mailfrom[1024];
-
        long Flags;
 } SmtpOutMsg;
 
index ef08b677506d0cf4b16ab7b51be6aa03a996e922..bb6d1734a5170bde6f5f740480d56e86cac53264 100644 (file)
@@ -103,11 +103,6 @@ eNextState TerminateLookupUrl(AsyncIO *IO)
 //TOOD
        return eAbort;
 }
-eNextState TerminateLookupUrlDB(AsyncIO *IO)
-{
-//TOOD
-       return eAbort;
-}
 eNextState LookupUrlResult(AsyncIO *IO)
 {
        return eTerminateConnection; /// /TODO
@@ -133,7 +128,6 @@ int LookupUrl(StrBuf *ShorterUrlStr)
                          "Citadel RSS ShorterURL Expander",
                          LookupUrlResult, 
                          TerminateLookupUrl, 
-                         TerminateLookupUrlDB, 
                          ShutdownLookuUrl))
        {
                syslog(LOG_ALERT, "Unable to initialize libcurl.\n");