1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

queue: Send DSN for messages that time out in the queue

The queue currently only considers failed recipients when deciding
whether to send a DSN or not. This is a bug, as recipients that time out
are not taken into account.

This patch fixes that issue by including both failed and pending
recipients in the DSN.

It also adds more comprehensive tests for this case, both in the queue
and in the dsn generation code.
This commit is contained in:
Alberto Bertogli
2016-10-17 20:59:57 +01:00
parent 6f048027a7
commit d660f88f67
5 changed files with 186 additions and 27 deletions

View File

@@ -334,7 +334,7 @@ func (item *Item) SendLoop(q *Queue) {
}
// Completed to all recipients (some may not have succeeded).
if item.countRcpt(Recipient_FAILED) > 0 && item.From != "<>" {
if item.countRcpt(Recipient_FAILED, Recipient_PENDING) > 0 && item.From != "<>" {
sendDSN(tr, q, item)
}
@@ -420,11 +420,14 @@ func (item *Item) deliver(q *Queue, rcpt *Recipient) (err error, permanent bool)
}
// countRcpt counts how many recipients are in the given status.
func (item *Item) countRcpt(status Recipient_Status) int {
func (item *Item) countRcpt(statuses ...Recipient_Status) int {
c := 0
for _, rcpt := range item.Rcpt {
if rcpt.Status == status {
c++
for _, status := range statuses {
if rcpt.Status == status {
c++
break
}
}
}
return c