From: Art Cancro Date: Fri, 13 Apr 2012 16:06:49 +0000 (-0400) Subject: Revert "SMTP-Client: move the client-shutdown procedure into the DB-Thread; we musn... X-Git-Tag: v8.11~98 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=f74fed30f3d655d3f229628b6b998240fa6494be Revert "SMTP-Client: move the client-shutdown procedure into the DB-Thread; we musn't block the network thread for db IO." This reverts commit 4fdc7029ccef0500fd8f968413c2b82db8fe2f29. --- diff --git a/citadel/event_client.c b/citadel/event_client.c index e2b3ba69a..5087dd9eb 100644 --- a/citadel/event_client.c +++ b/citadel/event_client.c @@ -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); diff --git a/citadel/event_client.h b/citadel/event_client.h index 6ae8b27d3..217ffc26e 100644 --- a/citadel/event_client.h +++ b/citadel/event_client.h @@ -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, diff --git a/citadel/modules/extnotify/funambol65.c b/citadel/modules/extnotify/funambol65.c index f4b0d8d38..03f478ca6 100644 --- a/citadel/modules/extnotify/funambol65.c +++ b/citadel/modules/extnotify/funambol65.c @@ -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); diff --git a/citadel/modules/network/serv_networkclient.c b/citadel/modules/network/serv_networkclient.c index 51db45198..0023d8363 100644 --- a/citadel/modules/network/serv_networkclient.c +++ b/citadel/modules/network/serv_networkclient.c @@ -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); diff --git a/citadel/modules/pop3client/serv_pop3client.c b/citadel/modules/pop3client/serv_pop3client.c index fa151f669..0a97df2cc 100644 --- a/citadel/modules/pop3client/serv_pop3client.c +++ b/citadel/modules/pop3client/serv_pop3client.c @@ -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); diff --git a/citadel/modules/rssclient/serv_rssclient.c b/citadel/modules/rssclient/serv_rssclient.c index 6d4392393..8a3ba6354 100644 --- a/citadel/modules/rssclient/serv_rssclient.c +++ b/citadel/modules/rssclient/serv_rssclient.c @@ -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"); diff --git a/citadel/modules/smtp/serv_smtpeventclient.c b/citadel/modules/smtp/serv_smtpeventclient.c index e5c1cee00..90a36b235 100644 --- a/citadel/modules/smtp/serv_smtpeventclient.c +++ b/citadel/modules/smtp/serv_smtpeventclient.c @@ -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<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; } diff --git a/citadel/modules/smtp/smtp_clienthandlers.h b/citadel/modules/smtp/smtp_clienthandlers.h index 38a7f58f4..02b84e75f 100644 --- a/citadel/modules/smtp/smtp_clienthandlers.h +++ b/citadel/modules/smtp/smtp_clienthandlers.h @@ -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; diff --git a/citadel/modules/urldeshortener/serv_expand_shorter_urls.c b/citadel/modules/urldeshortener/serv_expand_shorter_urls.c index ef08b6775..bb6d1734a 100644 --- a/citadel/modules/urldeshortener/serv_expand_shorter_urls.c +++ b/citadel/modules/urldeshortener/serv_expand_shorter_urls.c @@ -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");