Backport initialization of mu in NewCtxClient to release-3.5

Tested against the demo code provided in PR #17001

References:
- #17001
- #17018

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
This commit is contained in:
Chun-Hung Tseng 2024-04-03 08:20:01 +02:00
parent cbd0aed094
commit 61a85b7a82
No known key found for this signature in database
GPG Key ID: EF93C20F55FB48BB

View File

@ -86,7 +86,7 @@ func New(cfg Config) (*Client, error) {
// service interface implementations and do not need connection management.
func NewCtxClient(ctx context.Context, opts ...Option) *Client {
cctx, cancel := context.WithCancel(ctx)
c := &Client{ctx: cctx, cancel: cancel, lgMu: new(sync.RWMutex)}
c := &Client{ctx: cctx, cancel: cancel, lgMu: new(sync.RWMutex), mu: new(sync.RWMutex)}
for _, opt := range opts {
opt(c)
}