mirror of
https://github.com/taigrr/go-fastping
synced 2025-01-18 05:03:15 -08:00
Allow shutdown after timeout
If a timeout has occurred, the send to recv in recvICMP would block forever because no goroutine was receiving on that channel anymore. This leaves behind 2 goroutines for each timeout: 1 trying to send an recv, and another waiting for the wait group. Instead, used a buffered channel so that the sender can send even with no listener. This cleans up the goroutines and collects the channel.
This commit is contained in:
parent
13ddfb32b1
commit
f2eec8c939
@ -315,7 +315,7 @@ func (p *Pinger) run(once bool) {
|
|||||||
defer conn6.Close()
|
defer conn6.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
recv := make(chan *packet)
|
recv := make(chan *packet, 1)
|
||||||
recvCtx := newContext()
|
recvCtx := newContext()
|
||||||
wg := new(sync.WaitGroup)
|
wg := new(sync.WaitGroup)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user