clear remaining retries after a final delivery failure

This commit is contained in:
Ted Unangst 2020-07-18 15:01:00 -04:00
parent c600581c90
commit 0e1ec60422
1 changed files with 13 additions and 0 deletions

View File

@ -16,6 +16,7 @@
package main package main
import ( import (
"fmt"
"log" "log"
notrand "math/rand" notrand "math/rand"
"time" "time"
@ -43,6 +44,7 @@ func sayitagain(goarounds int64, userid int64, rcpt string, msg []byte) {
drift = 24 * time.Hour drift = 24 * time.Hour
default: default:
log.Printf("he's dead jim: %s", rcpt) log.Printf("he's dead jim: %s", rcpt)
clearoutbound(rcpt)
return return
} }
drift += time.Duration(notrand.Int63n(int64(drift / 10))) drift += time.Duration(notrand.Int63n(int64(drift / 10)))
@ -57,6 +59,17 @@ func sayitagain(goarounds int64, userid int64, rcpt string, msg []byte) {
} }
} }
func clearoutbound(rcpt string) {
hostname := originate(rcpt)
if hostname == "" {
return
}
xid := fmt.Sprintf("%%https://%s/%%", hostname)
log.Printf("clearing outbound for %s", xid)
db := opendatabase()
db.Exec("delete from doovers where rcpt like ?", xid)
}
var garage = gate.NewLimiter(40) var garage = gate.NewLimiter(40)
func deliverate(goarounds int64, userid int64, rcpt string, msg []byte) { func deliverate(goarounds int64, userid int64, rcpt string, msg []byte) {