author | Alberto Bertogli
<albertito@blitiri.com.ar> 2019-07-13 12:44:25 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2019-07-13 12:44:25 UTC |
parent | a92497aef0b9c0a5e4cd770bb5fcdedf712d2a7a |
internal/courier/procmail.go | +1 | -2 |
internal/queue/queue.go | +1 | -2 |
internal/smtpsrv/conn.go | +1 | -2 |
diff --git a/internal/courier/procmail.go b/internal/courier/procmail.go index 9167a84..b357e07 100644 --- a/internal/courier/procmail.go +++ b/internal/courier/procmail.go @@ -58,8 +58,7 @@ func (p *Procmail) Deliver(from string, to string, data []byte) (error, bool) { } tr.Debugf("%s %q", p.Binary, args) - ctx, cancel := context.WithDeadline(context.Background(), - time.Now().Add(p.Timeout)) + ctx, cancel := context.WithTimeout(context.Background(), p.Timeout) defer cancel() cmd := exec.CommandContext(ctx, p.Binary, args...) cmd.Stdin = bytes.NewReader(data) diff --git a/internal/queue/queue.go b/internal/queue/queue.go index ec5818f..802a494 100644 --- a/internal/queue/queue.go +++ b/internal/queue/queue.go @@ -381,8 +381,7 @@ func (item *Item) deliver(q *Queue, rcpt *Recipient) (err error, permanent bool) if len(c) == 0 { return fmt.Errorf("empty pipe"), true } - ctx, cancel := context.WithDeadline(context.Background(), - time.Now().Add(30*time.Second)) + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() cmd := exec.CommandContext(ctx, c[0], c[1:]...) cmd.Stdin = bytes.NewReader(item.Data) diff --git a/internal/smtpsrv/conn.go b/internal/smtpsrv/conn.go index d3fe30a..29ea5a2 100644 --- a/internal/smtpsrv/conn.go +++ b/internal/smtpsrv/conn.go @@ -743,8 +743,7 @@ func (c *Conn) runPostDataHook(data []byte) ([]byte, bool, error) { defer tr.Finish() tr.Debugf("running") - ctx, cancel := context.WithDeadline(context.Background(), - time.Now().Add(1*time.Minute)) + ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) defer cancel() cmd := exec.CommandContext(ctx, c.postDataHook) cmd.Stdin = bytes.NewReader(data)