Skip to content

Commit

Permalink
control: prevent reconnect reentry
Browse files Browse the repository at this point in the history
  • Loading branch information
Zariel committed Oct 25, 2017
1 parent 900c1e0 commit 82ca7d1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions control.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ func init() {
// Ensure that the atomic variable is aligned to a 64bit boundary
// so that atomic operations can be applied on 32bit architectures.
type controlConn struct {
started int32
reconnecting int32

session *Session
conn atomic.Value

retry RetryPolicy

started int32
quit chan struct{}
quit chan struct{}
}

func createControlConn(session *Session) *controlConn {
Expand Down Expand Up @@ -310,6 +312,10 @@ func (c *controlConn) registerEvents(conn *Conn) error {
}

func (c *controlConn) reconnect(refreshring bool) {
if !atomic.CompareAndSwapInt32(&c.reconnecting, 0, 1) {
return
}
defer atomic.StoreInt32(&c.reconnecting, 0)
// TODO: simplify this function, use session.ring to get hosts instead of the
// connection pool

Expand Down

0 comments on commit 82ca7d1

Please sign in to comment.