Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prior to this change, it is possible for more than one goroutine to check: if atomic.LoadInt32(&w.state) != StateConnected { ...thereafter calling w.connect. w.connect first grabs a lock on w.guard, and then asserts that it be the only goroutine attempting a connection: if !atomic.CompareAndSwapInt32(&w.state, StateInit, StateConnected) { return ErrNotConnected } This means if there are two parallel actions which attempt to initiate the connection, one of them will return ErrNotConnected if the first succesfully connected.
- Loading branch information