From 4ab135822c88e5dce4927c5fd1c4235ec7e1b253 Mon Sep 17 00:00:00 2001 From: Mark Pashmfouroush Date: Fri, 15 Mar 2024 02:51:17 +0000 Subject: [PATCH] psiphon: fix bug with early proxy shutdown Signed-off-by: Mark Pashmfouroush --- psiphon/p.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/psiphon/p.go b/psiphon/p.go index 610d03a66..c8141880e 100644 --- a/psiphon/p.go +++ b/psiphon/p.go @@ -357,15 +357,16 @@ func RunPsiphon(ctx context.Context, l *slog.Logger, wgBind, localSocksPort, cou l.Info("Handshaking, Please Wait...") - ctx, _ = context.WithTimeout(ctx, 2*time.Minute) + childCtx, cancel := context.WithTimeout(ctx, 2*time.Minute) + defer cancel() t0 := time.Now() t := time.NewTicker(1 * time.Second) defer t.Stop() for { select { - case <-ctx.Done(): - if errors.Is(ctx.Err(), context.Canceled) { + case <-childCtx.Done(): + if errors.Is(childCtx.Err(), context.Canceled) { return errors.New("psiphon handshake operation canceled") } return errors.New("psiphon handshake maximum time exceeded")