service: send summary when executing "server notice"

Sometimes this command times out. Display the number of skipped
users.
This commit is contained in:
Simon Ser 2021-12-08 14:55:31 +01:00
parent f7e151396d
commit 9caa6f9ca0

View File

@ -1090,12 +1090,20 @@ func handleServiceServerNotice(ctx context.Context, dc *downstreamConn, params [
Params: []string{"$" + dc.srv.Config().Hostname, text}, Params: []string{"$" + dc.srv.Config().Hostname, text},
} }
var err error var err error
sent := 0
total := 0
dc.srv.forEachUser(func(u *user) { dc.srv.forEachUser(func(u *user) {
total++
select { select {
case <-ctx.Done(): case <-ctx.Done():
err = ctx.Err() err = ctx.Err()
case u.events <- eventBroadcast{broadcastMsg}: case u.events <- eventBroadcast{broadcastMsg}:
sent++
} }
}) })
dc.logger.Printf("broadcast bouncer-wide NOTICE to %v/%v downstreams", sent, total)
sendServicePRIVMSG(dc, fmt.Sprintf("sent to %v/%v downstream connections", sent, total))
return err return err
} }