mirror of
				https://github.com/juanfont/headscale.git
				synced 2025-10-28 10:51:44 +01:00 
			
		
		
		
	Merge pull request #77 from kradalby/deadlierlocks
Remove more deadlocks
This commit is contained in:
		
						commit
						bb2ccfddd9
					
				
							
								
								
									
										11
									
								
								api.go
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								api.go
									
									
									
									
									
								
							@ -298,13 +298,8 @@ func (h *Headscale) PollNetMapHandler(c *gin.Context) {
 | 
				
			|||||||
		Str("handler", "PollNetMap").
 | 
							Str("handler", "PollNetMap").
 | 
				
			||||||
		Str("id", c.Param("id")).
 | 
							Str("id", c.Param("id")).
 | 
				
			||||||
		Str("machine", m.Name).
 | 
							Str("machine", m.Name).
 | 
				
			||||||
		Msg("Locking poll mutex")
 | 
							Msg("Storing update channel")
 | 
				
			||||||
	h.clientsPolling.Store(m.ID, update)
 | 
						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)
 | 
						data, err := h.getMapResponse(mKey, req, m)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
@ -460,7 +455,6 @@ func (h *Headscale) keepAlive(cancel chan []byte, pollData chan []byte, mKey wgk
 | 
				
			|||||||
			return
 | 
								return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			h.pollMu.Lock()
 | 
					 | 
				
			||||||
			data, err := h.getMapKeepAliveResponse(mKey, req, m)
 | 
								data, err := h.getMapKeepAliveResponse(mKey, req, m)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				log.Error().
 | 
									log.Error().
 | 
				
			||||||
@ -469,12 +463,13 @@ func (h *Headscale) keepAlive(cancel chan []byte, pollData chan []byte, mKey wgk
 | 
				
			|||||||
					Msg("Error generating the keep alive msg")
 | 
										Msg("Error generating the keep alive msg")
 | 
				
			||||||
				return
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			log.Debug().
 | 
								log.Debug().
 | 
				
			||||||
				Str("func", "keepAlive").
 | 
									Str("func", "keepAlive").
 | 
				
			||||||
				Str("machine", m.Name).
 | 
									Str("machine", m.Name).
 | 
				
			||||||
				Msg("Sending keepalive")
 | 
									Msg("Sending keepalive")
 | 
				
			||||||
			pollData <- *data
 | 
								pollData <- *data
 | 
				
			||||||
			h.pollMu.Unlock()
 | 
					
 | 
				
			||||||
			time.Sleep(60 * time.Second)
 | 
								time.Sleep(60 * time.Second)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								app.go
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								app.go
									
									
									
									
									
								
							@ -58,7 +58,6 @@ type Headscale struct {
 | 
				
			|||||||
	aclPolicy *ACLPolicy
 | 
						aclPolicy *ACLPolicy
 | 
				
			||||||
	aclRules  *[]tailcfg.FilterRule
 | 
						aclRules  *[]tailcfg.FilterRule
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pollMu         sync.Mutex
 | 
					 | 
				
			||||||
	clientsPolling sync.Map
 | 
						clientsPolling sync.Map
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -50,13 +50,11 @@ func (h *Headscale) EnableNodeRoute(namespace string, nodeName string, routeStr
 | 
				
			|||||||
			// Definetely not accessible from the CLI tool.
 | 
								// Definetely not accessible from the CLI tool.
 | 
				
			||||||
			// We need RPC to the server - or some kind of 'needsUpdate' field in the DB
 | 
								// We need RPC to the server - or some kind of 'needsUpdate' field in the DB
 | 
				
			||||||
			peers, _ := h.getPeers(*m)
 | 
								peers, _ := h.getPeers(*m)
 | 
				
			||||||
			h.pollMu.Lock()
 | 
					 | 
				
			||||||
			for _, p := range *peers {
 | 
								for _, p := range *peers {
 | 
				
			||||||
				if pUp, ok := h.clientsPolling.Load(uint64(p.ID)); ok {
 | 
									if pUp, ok := h.clientsPolling.Load(uint64(p.ID)); ok {
 | 
				
			||||||
					pUp.(chan []byte) <- []byte{}
 | 
										pUp.(chan []byte) <- []byte{}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			h.pollMu.Unlock()
 | 
					 | 
				
			||||||
			return &rIP, nil
 | 
								return &rIP, nil
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user