mirror of
https://github.com/juanfont/headscale.git
synced 2025-11-09 13:39:39 -05:00
app: fix sigint hanging
When the node notifier was replaced with batcher, we removed its closing, but forgot to add the batchers so it was never stopping node connections and waiting forever. Fixes #2751 Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
committed by
Kristoffer Dalby
parent
01c1f6f82a
commit
d41fb4d540
@@ -1361,7 +1361,11 @@ func TestBatcherConcurrentClients(t *testing.T) {
|
||||
go func(nodeID types.NodeID, channel chan *tailcfg.MapResponse) {
|
||||
for {
|
||||
select {
|
||||
case data := <-channel:
|
||||
case data, ok := <-channel:
|
||||
if !ok {
|
||||
// Channel was closed, exit gracefully
|
||||
return
|
||||
}
|
||||
if valid, reason := validateUpdateContent(data); valid {
|
||||
tracker.recordUpdate(
|
||||
nodeID,
|
||||
@@ -1419,24 +1423,28 @@ func TestBatcherConcurrentClients(t *testing.T) {
|
||||
ch := make(chan *tailcfg.MapResponse, SMALL_BUFFER_SIZE)
|
||||
|
||||
churningChannelsMutex.Lock()
|
||||
|
||||
churningChannels[nodeID] = ch
|
||||
|
||||
churningChannelsMutex.Unlock()
|
||||
|
||||
batcher.AddNode(nodeID, ch, tailcfg.CapabilityVersion(100))
|
||||
|
||||
// Consume updates to prevent blocking
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case data := <-ch:
|
||||
case data, ok := <-ch:
|
||||
if !ok {
|
||||
// Channel was closed, exit gracefully
|
||||
return
|
||||
}
|
||||
if valid, _ := validateUpdateContent(data); valid {
|
||||
tracker.recordUpdate(
|
||||
nodeID,
|
||||
1,
|
||||
) // Use 1 as update size since we have MapResponse
|
||||
}
|
||||
case <-time.After(20 * time.Millisecond):
|
||||
case <-time.After(500 * time.Millisecond):
|
||||
// Longer timeout to prevent premature exit during heavy load
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user