From b1b8d9a82b7c4e0b0b999ec173e1038533fe88eb Mon Sep 17 00:00:00 2001 From: Gerhard Tan Date: Wed, 1 Feb 2023 13:09:31 +0800 Subject: [PATCH] frpc: do a graceful close for quic protocol at exit (#3282) --- cmd/frpc/sub/root.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/frpc/sub/root.go b/cmd/frpc/sub/root.go index cea8ecc..19206c6 100644 --- a/cmd/frpc/sub/root.go +++ b/cmd/frpc/sub/root.go @@ -216,15 +216,16 @@ func startService( return } - kcpDoneCh := make(chan struct{}) - // Capture the exit signal if we use kcp. - if cfg.Protocol == "kcp" { - go handleSignal(svr, kcpDoneCh) + closedDoneCh := make(chan struct{}) + shouldGracefulClose := cfg.Protocol == "kcp" || cfg.Protocol == "quic" + // Capture the exit signal if we use kcp or quic. + if shouldGracefulClose { + go handleSignal(svr, closedDoneCh) } err = svr.Run() - if err == nil && cfg.Protocol == "kcp" { - <-kcpDoneCh + if err == nil && shouldGracefulClose { + <-closedDoneCh } return }