mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-22 07:57:34 +00:00
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)
|
||||
|
||||
const chanSize = 8
|
||||
updateChan := make(chan types.StateUpdate, chanSize)
|
||||
|
||||
h.pollNetMapStreamWG.Add(1)
|
||||
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, cancel := context.WithCancel(ctx)
|
||||
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 {
|
||||
select {
|
||||
case <-keepAliveTicker.C:
|
||||
|
Loading…
x
Reference in New Issue
Block a user