1
0
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:
Matt Jibson 2014-11-17 19:11:36 -05:00 committed by Tatsushi Demachi
parent 13ddfb32b1
commit f2eec8c939

View File

@ -315,7 +315,7 @@ func (p *Pinger) run(once bool) {
defer conn6.Close()
}
recv := make(chan *packet)
recv := make(chan *packet, 1)
recvCtx := newContext()
wg := new(sync.WaitGroup)