rearrange channel closing defers
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
13fe4ec91b
commit
2d87085cbc
|
@ -222,22 +222,22 @@ func (h *Headscale) pollNetMapStream(
|
||||||
|
|
||||||
keepAliveTicker := time.NewTicker(keepAliveInterval)
|
keepAliveTicker := time.NewTicker(keepAliveInterval)
|
||||||
|
|
||||||
const chanSize = 8
|
|
||||||
updateChan := make(chan types.StateUpdate, chanSize)
|
|
||||||
|
|
||||||
h.pollNetMapStreamWG.Add(1)
|
h.pollNetMapStreamWG.Add(1)
|
||||||
defer h.pollNetMapStreamWG.Done()
|
defer h.pollNetMapStreamWG.Done()
|
||||||
|
|
||||||
|
const chanSize = 8
|
||||||
|
updateChan := make(chan types.StateUpdate, chanSize)
|
||||||
|
defer closeChanWithLog(updateChan, machine.Hostname, "updateChan")
|
||||||
|
|
||||||
|
// Register the node's update channel
|
||||||
|
h.nodeNotifier.AddNode(machine.MachineKey, updateChan)
|
||||||
|
defer h.nodeNotifier.RemoveNode(machine.MachineKey)
|
||||||
|
|
||||||
ctx := context.WithValue(ctxReq, machineNameContextKey, machine.Hostname)
|
ctx := context.WithValue(ctxReq, machineNameContextKey, machine.Hostname)
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Register the node's update channel
|
|
||||||
h.nodeNotifier.AddNode(machine.MachineKey, updateChan)
|
|
||||||
defer h.nodeNotifier.RemoveNode(machine.MachineKey)
|
|
||||||
defer closeChanWithLog(updateChan, machine.Hostname, "updateChan")
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-keepAliveTicker.C:
|
case <-keepAliveTicker.C:
|
||||||
|
|
Loading…
Reference in New Issue