Reduce the mutex size when the client closes the connection

This commit is contained in:
Juan Font Alonso 2021-06-09 20:55:25 +02:00
parent cb1a81fe4c
commit 5db7716be2

2
api.go
View File

@ -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)