From 5bc5c5dc1bc55e5e2d6ceff4bc289884ab01e7bb Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Fri, 6 Aug 2021 20:02:47 +0100 Subject: [PATCH 1/4] Remove forgotten lock --- routes.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/routes.go b/routes.go index e188b91c..4838cda6 100644 --- a/routes.go +++ b/routes.go @@ -50,13 +50,11 @@ func (h *Headscale) EnableNodeRoute(namespace string, nodeName string, routeStr // Definetely not accessible from the CLI tool. // We need RPC to the server - or some kind of 'needsUpdate' field in the DB peers, _ := h.getPeers(*m) - h.pollMu.Lock() for _, p := range *peers { if pUp, ok := h.clientsPolling.Load(uint64(p.ID)); ok { pUp.(chan []byte) <- []byte{} } } - h.pollMu.Unlock() return &rIP, nil } } From 4243885246d1ac475ed46437d0729ff276f57344 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Fri, 6 Aug 2021 20:03:25 +0100 Subject: [PATCH 2/4] Rewrite old lock error msg --- api.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/api.go b/api.go index 0d2b15cb..b17f3eb3 100644 --- a/api.go +++ b/api.go @@ -298,13 +298,8 @@ func (h *Headscale) PollNetMapHandler(c *gin.Context) { Str("handler", "PollNetMap"). Str("id", c.Param("id")). Str("machine", m.Name). - Msg("Locking poll mutex") + Msg("Storing update channel") h.clientsPolling.Store(m.ID, update) - log.Trace(). - Str("handler", "PollNetMap"). - Str("id", c.Param("id")). - Str("machine", m.Name). - Msg("Unlocking poll mutex") data, err := h.getMapResponse(mKey, req, m) if err != nil { From 15b8c8f4c5b43a21a8ae46171a0a05241d96f9c8 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Fri, 6 Aug 2021 20:08:51 +0100 Subject: [PATCH 3/4] Remove lock from keepAlive --- api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api.go b/api.go index b17f3eb3..820e3f48 100644 --- a/api.go +++ b/api.go @@ -455,7 +455,6 @@ func (h *Headscale) keepAlive(cancel chan []byte, pollData chan []byte, mKey wgk return default: - h.pollMu.Lock() data, err := h.getMapKeepAliveResponse(mKey, req, m) if err != nil { log.Error(). @@ -464,12 +463,13 @@ func (h *Headscale) keepAlive(cancel chan []byte, pollData chan []byte, mKey wgk Msg("Error generating the keep alive msg") return } + log.Debug(). Str("func", "keepAlive"). Str("machine", m.Name). Msg("Sending keepalive") pollData <- *data - h.pollMu.Unlock() + time.Sleep(60 * time.Second) } } From 99fd126219c1d2a0528cc08449470c07d5f68ff9 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Fri, 6 Aug 2021 21:11:38 +0100 Subject: [PATCH 4/4] Remove unused mutex --- app.go | 1 - 1 file changed, 1 deletion(-) diff --git a/app.go b/app.go index 668e23b9..363b38bc 100644 --- a/app.go +++ b/app.go @@ -58,7 +58,6 @@ type Headscale struct { aclPolicy *ACLPolicy aclRules *[]tailcfg.FilterRule - pollMu sync.Mutex clientsPolling sync.Map }