Optimize stopping CaptivePortalHandler (#2151)
* Optimize stopping CaptivePortalHandler * Still use unbuffered channel as we close it instead of sending a signal
This commit is contained in:
parent
3d641b758a
commit
8e46f44799
|
@ -20,8 +20,7 @@ type CaptivePortalHandler struct {
|
|||
|
||||
func (captivePortalHandler *CaptivePortalHandler) Stop() {
|
||||
for _, cancelChannel := range captivePortalHandler.cancelChannels {
|
||||
cancelChannel <- struct{}{}
|
||||
<-cancelChannel
|
||||
close(cancelChannel)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +83,6 @@ func handleColdStartClient(clientPc *net.UDPConn, cancelChannel chan struct{}, i
|
|||
exit := false
|
||||
select {
|
||||
case <-cancelChannel:
|
||||
cancelChannel <- struct{}{}
|
||||
exit = true
|
||||
default:
|
||||
}
|
||||
|
@ -96,12 +94,6 @@ func handleColdStartClient(clientPc *net.UDPConn, cancelChannel chan struct{}, i
|
|||
}
|
||||
if err != nil {
|
||||
dlog.Warn(err)
|
||||
select {
|
||||
case <-cancelChannel:
|
||||
cancelChannel <- struct{}{}
|
||||
default:
|
||||
cancelChannel = make(chan struct{}, 1)
|
||||
}
|
||||
return true
|
||||
}
|
||||
packet := buffer[:length]
|
||||
|
|
Loading…
Reference in New Issue