From 4be71e775873d7cb24f22f90de9a4ae65f9d9a5a Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Wed, 13 Dec 2023 21:16:22 +0800 Subject: [PATCH] fix: reduce the granularity of the lock. --- internal/push/push_to_client.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/push/push_to_client.go b/internal/push/push_to_client.go index e483c7987b..2ee8c457fe 100644 --- a/internal/push/push_to_client.go +++ b/internal/push/push_to_client.go @@ -299,6 +299,9 @@ func (p *Pusher) GetConnsAndOnlinePush(ctx context.Context, msg *sdkws.MsgData, maxWorkers = 3 } + wg.SetLimit(maxWorkers) + + // Online push message for _, conn := range conns { conn := conn // loop var safe wg.Go(func() error { @@ -319,6 +322,8 @@ func (p *Pusher) GetConnsAndOnlinePush(ctx context.Context, msg *sdkws.MsgData, }) } + _ = wg.Wait() + // always return nil return wsResults, nil }