From 5db7716be229ac5ff47a24fc0ff03e39589eed3f Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Wed, 9 Jun 2021 20:55:25 +0200 Subject: [PATCH] Reduce the mutex size when the client closes the connection --- api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api.go b/api.go index 1c87ed80..344878ce 100644 --- a/api.go +++ b/api.go @@ -320,11 +320,11 @@ func (h *Headscale) PollNetMapHandler(c *gin.Context) { return true case <-c.Request.Context().Done(): - h.pollMu.Lock() log.Printf("[%s] The client has closed the connection", m.Name) now := time.Now().UTC() m.LastSeen = &now db.Save(&m) + h.pollMu.Lock() cancelKeepAlive <- []byte{} delete(h.clientsPolling, m.ID) close(update)