Use request context to close when client disconnects

This commit is contained in:
Juan Font Alonso 2022-06-20 21:47:02 +02:00
parent 5e9004c407
commit d404ba102d

View file

@ -279,7 +279,7 @@ func (h *Headscale) PollNetMapStream(
keepAliveChan chan []byte, keepAliveChan chan []byte,
updateChan chan struct{}, updateChan chan struct{},
) { ) {
ctx := context.WithValue(context.Background(), machineNameContextKey, machine.Hostname) ctx := context.WithValue(r.Context(), machineNameContextKey, machine.Hostname)
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
defer cancel() defer cancel()