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

Fix write/close deadlock #50

Merged
merged 1 commit into from
Apr 9, 2015
Merged

Conversation

ncdc
Copy link
Contributor

@ncdc ncdc commented Apr 9, 2015

When the monitor goroutine sees that the connection has closed, it is
sometimes possible for resetChan to be full and a Write() invocation
blocked sending to resetChan. If this happens, and monitor attempts to
grab the write lock, it will result in a deadlock because Write() has
the lock, monitor is trying to acquire the lock, and nothing is draining
resetChan.

Start a goroutine in monitor to drain resetChan, just before trying to
acquire the lock.

Fixes #49

Signed-off-by: Andy Goldstein agoldste@redhat.com

When the monitor goroutine sees that the connection has closed, it is
sometimes possible for resetChan to be full and a Write() invocation
blocked sending to resetChan. If this happens, and monitor attempts to
grab the write lock, it will result in a deadlock because Write() has
the lock, monitor is trying to acquire the lock, and nothing is draining
resetChan.

Start a goroutine in monitor to drain resetChan, just before trying to
acquire the lock.

Fixes moby#49

Signed-off-by: Andy Goldstein <agoldste@redhat.com>
@dmcgowan
Copy link
Member

dmcgowan commented Apr 9, 2015

LGTM

dmcgowan added a commit that referenced this pull request Apr 9, 2015
@dmcgowan dmcgowan merged commit 99515db into moby:master Apr 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible to deadlock connection closure
2 participants