BewareMyPower opened a new pull request #631: URL: https://github.com/apache/pulsar-client-go/pull/631
### Motivation There's no need to lock the `changeState` method. We don't need the whole operation is atomic. Instead, we just need that `c.setState(state)` takes effect so that `c.cond.Broadcast()` can broadcast the correct notification that the state has been changed successfully. https://github.com/apache/pulsar-client-go/pull/451 changed `state` field to an atomic variable, so we don't need the lock for changing `state` anymore. I guess the lock for `changeState` was added when the `state` field was just a normal `int32` variable. But https://github.com/apache/pulsar-client-go/pull/451 didn't remove the lock. ### Modifications Remove the `Lock()`/`Unlock()` calls in `changeState`, then reuse `changeState` in `connection.Close()`. ### Verifying this change - [ ] Make sure that the change passes the CI checks. This change is a trivial rework / code cleanup without any test coverage. -- 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]
