Check context cancellation in handleServiceServerNotice

This prevents this function from blocking forever if it exceeds the
deadline.
This commit is contained in:
Simon Ser 2021-11-08 19:42:36 +01:00
parent 802e82c272
commit 22f9ce1b86

View File

@ -1046,8 +1046,13 @@ func handleServiceServerNotice(ctx context.Context, dc *downstreamConn, params [
Command: "NOTICE", Command: "NOTICE",
Params: []string{"$" + dc.srv.Hostname, text}, Params: []string{"$" + dc.srv.Hostname, text},
} }
var err error
dc.srv.forEachUser(func(u *user) { dc.srv.forEachUser(func(u *user) {
u.events <- eventBroadcast{broadcastMsg} select {
}) case <-ctx.Done():
return nil err = ctx.Err()
case u.events <- eventBroadcast{broadcastMsg}:
}
})
return err
} }