1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-19 14:57:04 +00:00

Remove unreachable code, and don't leak contexts

This patch performs some minor cleanups for things detected by "go vet":

 - Remove one line of unreachable code.
 - Don't leak contexts until their deadline expires, cancel them.
This commit is contained in:
Alberto Bertogli
2016-09-25 22:02:08 +01:00
parent 0995eac474
commit 04dd8b9534
3 changed files with 4 additions and 4 deletions

View File

@@ -386,8 +386,9 @@ func (item *Item) deliver(q *Queue, rcpt *Recipient) (err error, permanent bool)
if len(c) == 0 {
return fmt.Errorf("empty pipe"), true
}
ctx, _ := context.WithDeadline(context.Background(),
ctx, cancel := context.WithDeadline(context.Background(),
time.Now().Add(30*time.Second))
defer cancel()
cmd := exec.CommandContext(ctx, c[0], c[1:]...)
cmd.Stdin = bytes.NewReader(item.Data)
return cmd.Run(), true