{
SmtpOutMsg *pMsg = IO->Data;
+ pMsg->MyQEntry->Status = 4;
EVS_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[pMsg->State]));
return FailOneAttempt(IO);
{
SmtpOutMsg *pMsg = IO->Data;
+ pMsg->MyQEntry->Status = 4;
EVS_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[pMsg->State]));
return FailOneAttempt(IO);
}
eNextState SMTP_C_DNSFail(AsyncIO *IO)
{
+ SmtpOutMsg *pMsg = IO->Data;
+ pMsg->MyQEntry->Status = 4;
EVS_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
return FailOneAttempt(IO);
}
HashList *ActiveQItems = NULL;
HashList *QItemHandlers = NULL;
+static const long MaxRetry = SMTP_RETRY_INTERVAL * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2;
int MsgCount = 0;
int run_queue_now = 0; /* Set to 1 to ignore SMTP send retry times */
Item = (OneQueItem*)malloc(sizeof(OneQueItem));
memset(Item, 0, sizeof(OneQueItem));
- Item->LastAttempt.retry = SMTP_RETRY_INTERVAL;
+ Item->Retry = SMTP_RETRY_INTERVAL;
Item->MessageID = -1;
Item->QueMsgID = QueMsgID;
FreeStrBuf(&Line);
FreeStrBuf(&Token);
+ if (Item->Retry >= MaxRetry)
+ Item->FailNow = 1;
+
pthread_mutex_lock(&ActiveQItemsLock);
if (GetHash(ActiveQItems,
LKEY(Item->MessageID),
StrBufAppendBuf(QMessage, MyQItem->EnvelopeFrom, 0);
}
+ StrBufAppendBufPlain(QMessage, HKEY("\nretry|"), 0);
+ StrBufAppendPrintf(QMessage, "%ld",
+ MyQItem->Retry);
+
+ StrBufAppendBufPlain(QMessage, HKEY("\nattempted|"), 0);
+ StrBufAppendPrintf(QMessage, "%ld",
+ MyQItem->ReattemptWhen);
+
It = GetNewHashPos(MyQItem->MailQEntries, 0);
while (GetNextHashPos(MyQItem->MailQEntries, It, &len, &Key, &vQE))
{
MailQEntry *ThisItem = vQE;
- int i;
if (!ThisItem->Active)
{
/* skip already sent ones from the spoolfile. */
continue;
}
-
- for (i=0; i < ThisItem->nAttempts; i++) {
- /* TODO: most probably
- * there is just one retry/attempted per message!
- */
- StrBufAppendBufPlain(QMessage, HKEY("\nretry|"), 0);
- StrBufAppendPrintf(QMessage, "%ld",
- ThisItem->Attempts[i].retry);
-
- StrBufAppendBufPlain(QMessage, HKEY("\nattempted|"), 0);
- StrBufAppendPrintf(QMessage, "%ld",
- ThisItem->Attempts[i].when);
- }
StrBufAppendBufPlain(QMessage, HKEY("\nremote|"), 0);
StrBufAppendBuf(QMessage, ThisItem->Recipient, 0);
StrBufAppendBufPlain(QMessage, HKEY("|"), 0);
void QItem_Handle_retry(OneQueItem *Item, StrBuf *Line, const char **Pos)
{
- if (Item->Current == NULL)
- NewMailQEntry(Item);
- if (Item->Current->Attempts[Item->Current->nAttempts].retry != 0)
- Item->Current->nAttempts++;
- if (Item->Current->nAttempts > MaxAttempts) {
- Item->FailNow = 1;
- return;
- }
- Item->Current->Attempts[Item->Current->nAttempts].retry =
+ Item->Retry =
StrBufExtractNext_int(Line, Pos, '|');
+ Item->Retry *= 2;
}
void QItem_Handle_Attempted(OneQueItem *Item, StrBuf *Line, const char **Pos)
{
- if (Item->Current == NULL)
- NewMailQEntry(Item);
- if (Item->Current->Attempts[Item->Current->nAttempts].when != 0)
- Item->Current->nAttempts++;
- if (Item->Current->nAttempts > MaxAttempts) {
- Item->FailNow = 1;
- return;
- }
-
- Item->Current->Attempts[Item->Current->nAttempts].when =
- StrBufExtractNext_int(Line, Pos, '|');
- if (Item->Current->Attempts[Item->Current->nAttempts].when >
- Item->LastAttempt.when)
- {
- Item->LastAttempt.when =
- Item->Current->Attempts[Item->Current->nAttempts].when;
-
- Item->LastAttempt.retry =
- Item->Current->Attempts[
- Item->Current->nAttempts
- ].retry * 2;
-
- if (Item->LastAttempt.retry > SMTP_RETRY_MAX)
- Item->LastAttempt.retry = SMTP_RETRY_MAX;
- }
+ Item->ReattemptWhen = StrBufExtractNext_int(Line, Pos, '|');
}
/*
* Postpone delivery if we've already tried recently.
*/
- if (((time(NULL) - MyQItem->LastAttempt.when) <
- MyQItem->LastAttempt.retry) &&
+ if (((time(NULL) - MyQItem->ReattemptWhen) > 0) &&
(run_queue_now == 0))
{
syslog(LOG_DEBUG, "SMTP client: Retry time not yet reached.\n");