frpc: do a graceful close for quic protocol at exit

This commit is contained in:
Gerhard Tan 2023-02-01 12:12:52 +08:00
parent d205c26480
commit 4f2629cbb1
No known key found for this signature in database
GPG Key ID: 205411781EEFB8D4

View File

@ -216,15 +216,16 @@ func startService(
return return
} }
kcpDoneCh := make(chan struct{}) closedDoneCh := make(chan struct{})
// Capture the exit signal if we use kcp. shouldGracefulClose := cfg.Protocol == "kcp" || cfg.Protocol == "quic"
if cfg.Protocol == "kcp" { // Capture the exit signal if we use kcp or quic.
go handleSignal(svr, kcpDoneCh) if shouldGracefulClose {
go handleSignal(svr, closedDoneCh)
} }
err = svr.Run() err = svr.Run()
if err == nil && cfg.Protocol == "kcp" { if err == nil && shouldGracefulClose {
<-kcpDoneCh <-closedDoneCh
} }
return return
} }