Aias00 commented on code in PR #3438:
URL: https://github.com/apache/dubbo-go/pull/3438#discussion_r4522483949
##########
remoting/exchange_client.go:
##########
@@ -82,20 +93,52 @@ func NewExchangeClient(url *common.URL, client Client,
connectTimeout time.Durat
}
func (cl *ExchangeClient) doInit(url *common.URL) error {
- if cl.init {
+ // Fast path: already initialized.
+ if cl.initState.Load() == initInitialized {
return nil
}
+ // Try to become the initializer.
+ if !cl.initState.CAS(initUninitialized, initInitializing) {
+ // Another goroutine is initializing. Wait for it to complete.
+ cl.initCond.L.Lock()
+ for cl.initState.Load() == initInitializing {
+ cl.initCond.Wait()
+ }
+ err := cl.initErr
Review Comment:
Fixed in `8e99b7ca`. Close now publishes `base.ErrClientClosed` and a
terminal closed state; both the waiter and a late successful initializer return
the closed error, and later calls cannot reconnect it. A deterministic
regression reproduces the old false-success behavior and covers repeated Close.
Remoting race tests, 30 repeated concurrency runs, Dubbo protocol tests, vet,
and golangci-lint v2.7.2 pass. Current develop is merged with its context-aware
methods and stdlib atomic changes preserved.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]