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 data race when closing amqp connection #200

Closed
wants to merge 1 commit into from

Conversation

mouadino
Copy link

When using conn.NotifyClose, this later append to a list of channels
me.closes, while conn.shutdown() range over this list, so when a
connection is closed, conn.NotifyClose() may detect the connection closing
in the same time as the conn.shutdown() call, this is done in two
goroutine, which end up in data race where one appending to me.closes
and the other looping over it.

The fix is to move setting noNotify to True to the top of
conn.shutdown(), this way conn.NotifyClose() will not append to the
list anymore.

When using conn.NotifyClose, this later append to a list of channels
``me.closes``, while conn.shutdown() range over this list, so when a
connection is closed, ``conn.NotifyClose()`` may detect the connection closing
in the same time as the ``conn.shutdown()`` call, this is done in two
goroutine, which end up in data race where one appending to me.closes
and the other looping over it.

The fix is to move setting ``noNotify`` to True to the top of
``conn.shutdown()``, this way ``conn.NotifyClose()`` will not append to the
list anymore.
@mouadino
Copy link
Author

mouadino commented Apr 28, 2016

@streadway In case tests are needed please let me know.

@michaelklishin
Copy link
Collaborator

Tests are never a bad idea and force closing connections is something that other client test suites often do, either via rabbitmqctl or HTTP API (part of the management plugin).

@imkira
Copy link
Contributor

imkira commented Apr 28, 2016

@mouadino how different would be that be from #196 ?
I wonder if that passes the tests I wrote too.

@mouadino
Copy link
Author

mouadino commented May 4, 2016

@imkira your PR looks more complete than this one. Any chance we can get your PR merged?

@imkira
Copy link
Contributor

imkira commented May 4, 2016

@mouadino I hope so. I am waiting for @streadway but he seems to be busy lately.

@mouadino
Copy link
Author

As mentioned before #196 will take care of fixing the issue, closing.

@mouadino mouadino closed this Aug 22, 2016
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.

3 participants