From fd82beac39513ca4ae1408476f5fc0633db31362 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sat, 15 Jan 2011 11:45:46 +0100 Subject: [PATCH] libev migration - fix queue conditions - handle messages without recipients - remove the the original message when we finished our job. --- citadel/modules/smtp/serv_smtpeventclient.c | 29 ++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/citadel/modules/smtp/serv_smtpeventclient.c b/citadel/modules/smtp/serv_smtpeventclient.c index 8146959bc..676c1812f 100644 --- a/citadel/modules/smtp/serv_smtpeventclient.c +++ b/citadel/modules/smtp/serv_smtpeventclient.c @@ -237,6 +237,8 @@ void FinalizeMessageSend(SmtpOutMsg *Msg) CtdlSubmitMsg(msg, NULL, SMTP_SPOOLOUT_ROOM, QP_EADDR); CtdlFreeMessage(msg); } + else + CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, &Msg->MyQItem->MessageID, 1, ""); RemoveQItem(Msg->MyQItem); } @@ -372,6 +374,12 @@ int smtp_resolve_recipients(SmtpOutMsg *SendMsg) int lp, rp; int i; + if ((SendMsg==NULL) || + (SendMsg->MyQEntry == NULL) || + (StrLength(SendMsg->MyQEntry->Recipient) == 0)) { + return 0; + } + /* Parse out the host portion of the recipient address */ process_rfc822_addr(ChrPtr(SendMsg->MyQEntry->Recipient), SendMsg->user, @@ -433,7 +441,7 @@ int smtp_resolve_recipients(SmtpOutMsg *SendMsg) SendMsg->envelope_from = SendMsg->mailfrom; } - return 0; + return 1; } @@ -458,11 +466,20 @@ void smtp_try(OneQueItem *MyQItem, else SendMsg->msgtext = NewStrBufDup(MsgText); - smtp_resolve_recipients(SendMsg); - - QueueEventContext(SendMsg, - &SendMsg->IO, - resolve_mx_records); + if (smtp_resolve_recipients(SendMsg)) { + QueueEventContext(SendMsg, + &SendMsg->IO, + resolve_mx_records); + } + else { + if ((SendMsg==NULL) || + (SendMsg->MyQEntry == NULL)) { + SendMsg->MyQEntry->Status = 5; + StrBufPlain(SendMsg->MyQEntry->StatusMessage, + HKEY("Invalid Recipient!")); + } + FinalizeMessageSend(SendMsg); + } } -- 2.39.2