1
0
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:
lifenjoiner 2022-07-15 03:53:13 +08:00 committed by GitHub
parent 3d641b758a
commit 8e46f44799
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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]