This is an automated email from the ASF dual-hosted git repository.
rfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git
The following commit(s) were added to refs/heads/master by this push:
new a28dbd4 Remove unnecessary lock of changeState (#631)
a28dbd4 is described below
commit a28dbd413741a726ddb037ccf6bb55fecce60b15
Author: Yunze Xu <[email protected]>
AuthorDate: Sat Oct 9 11:13:38 2021 +0800
Remove unnecessary lock of changeState (#631)
---
pulsar/internal/connection.go | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/pulsar/internal/connection.go b/pulsar/internal/connection.go
index 875c84e..0313e4e 100644
--- a/pulsar/internal/connection.go
+++ b/pulsar/internal/connection.go
@@ -842,10 +842,8 @@ func (c *connection) Close() {
c.closeOnce.Do(func() {
c.Lock()
cnx := c.cnx
- // do not use changeState() since they share the same lock
- c.setState(connectionClosed)
- c.cond.Broadcast()
c.Unlock()
+ c.changeState(connectionClosed)
if cnx != nil {
_ = cnx.Close()
@@ -884,10 +882,8 @@ func (c *connection) Close() {
}
func (c *connection) changeState(state connectionState) {
- c.Lock()
c.setState(state)
c.cond.Broadcast()
- c.Unlock()
}
func (c *connection) getState() connectionState {