From e3b1930bf2163063f4828aee974b0fda4b4157d3 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 8 Nov 2021 19:48:32 +0100 Subject: [PATCH] Add partial context support to handleUserUpdate More plumbing needed to make sure we don't block too long waiting for the reply. --- service.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/service.go b/service.go index 6a15e94..ff5c633 100644 --- a/service.go +++ b/service.go @@ -813,11 +813,17 @@ func handleUserUpdate(ctx context.Context, dc *downstreamConn, params []string) } done := make(chan error, 1) - u.events <- eventUserUpdate{ + event := eventUserUpdate{ password: hashed, admin: admin, done: done, } + select { + case <-ctx.Done(): + return ctx.Err() + case u.events <- event: + } + // TODO: send context to the other side if err := <-done; err != nil { return err }