Skip to content

Commit

Permalink
fix: reduce the granularity of the lock.
Browse files Browse the repository at this point in the history
  • Loading branch information
FGadvancer committed Dec 13, 2023
1 parent d958056 commit 4be71e7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/push/push_to_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -319,6 +322,8 @@ func (p *Pusher) GetConnsAndOnlinePush(ctx context.Context, msg *sdkws.MsgData,
})
}

_ = wg.Wait()

// always return nil
return wsResults, nil
}
Expand Down

0 comments on commit 4be71e7

Please sign in to comment.