mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2024-12-11 22:35:40 +01:00
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() {
|
func (captivePortalHandler *CaptivePortalHandler) Stop() {
|
||||||
for _, cancelChannel := range captivePortalHandler.cancelChannels {
|
for _, cancelChannel := range captivePortalHandler.cancelChannels {
|
||||||
cancelChannel <- struct{}{}
|
close(cancelChannel)
|
||||||
<-cancelChannel
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +83,6 @@ func handleColdStartClient(clientPc *net.UDPConn, cancelChannel chan struct{}, i
|
|||||||
exit := false
|
exit := false
|
||||||
select {
|
select {
|
||||||
case <-cancelChannel:
|
case <-cancelChannel:
|
||||||
cancelChannel <- struct{}{}
|
|
||||||
exit = true
|
exit = true
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
@ -96,12 +94,6 @@ func handleColdStartClient(clientPc *net.UDPConn, cancelChannel chan struct{}, i
|
|||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dlog.Warn(err)
|
dlog.Warn(err)
|
||||||
select {
|
|
||||||
case <-cancelChannel:
|
|
||||||
cancelChannel <- struct{}{}
|
|
||||||
default:
|
|
||||||
cancelChannel = make(chan struct{}, 1)
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
packet := buffer[:length]
|
packet := buffer[:length]
|
||||||
|
Loading…
Reference in New Issue
Block a user