Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

producer: fix connection race #133

Merged
merged 1 commit into from
Apr 8, 2015
Merged

producer: fix connection race #133

merged 1 commit into from
Apr 8, 2015

Commits on Apr 8, 2015

  1. producer: fix connection race

    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.
    jeddenlea committed Apr 8, 2015
    Configuration menu
    Copy the full SHA
    79c45bd View commit details
    Browse the repository at this point in the history