From 22f9ce1b868df1a277e1a1a952d7f521768e1bfb Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 8 Nov 2021 19:42:36 +0100 Subject: [PATCH] Check context cancellation in handleServiceServerNotice This prevents this function from blocking forever if it exceeds the deadline. --- service.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/service.go b/service.go index 06ed9ec..6a15e94 100644 --- a/service.go +++ b/service.go @@ -1046,8 +1046,13 @@ func handleServiceServerNotice(ctx context.Context, dc *downstreamConn, params [ Command: "NOTICE", Params: []string{"$" + dc.srv.Hostname, text}, } + var err error dc.srv.forEachUser(func(u *user) { - u.events <- eventBroadcast{broadcastMsg} + select { + case <-ctx.Done(): + err = ctx.Err() + case u.events <- eventBroadcast{broadcastMsg}: + } }) - return nil + return err }