]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Cancel writer after request
authorMatt Joiner <anacrolix@gmail.com>
Thu, 24 Jun 2021 03:10:18 +0000 (13:10 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 24 Jun 2021 13:13:35 +0000 (23:13 +1000)
tracker/udp/client.go

index 54099ff61680d45ede1cff83b254815430ce466b..d66348e16928d4bd48a2499cf44340093461154c 100644 (file)
@@ -110,6 +110,8 @@ func (cl *Client) request(ctx context.Context, action Action, body []byte) (resp
                respChan <- dr
        })
        defer t.End()
+       ctx, cancel := context.WithCancel(ctx)
+       defer cancel()
        writeErr := make(chan error, 1)
        go func() {
                writeErr <- cl.requestWriter(ctx, action, body, t.Id())