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

Destroy existing socket before allocating a new one #34

Merged

Conversation

bval
Copy link

@bval bval commented Sep 10, 2018

When reconnecting on timeout node-irc will create a new socket without properly destroying the old one. I have observed a race condition as a result of this that can hold multiple connections open at once. I can reliably reproduce this with nandub/hubot-irc. I can end up with as many open sockets as my retry limit.

Documentation for the destroy method can be found here.

I debated various other places to put this, but invoking it in connect() before allocating the connection seems like the safest place for all callers. This code is called from reconnect but could have other callers in the future.

@Half-Shot
Copy link

Half-Shot commented Oct 1, 2018

This looks fairly safe, thanks for the PR! Are you okay to sign your PR either in the comment above or via commit? Basically follow https://github.com/matrix-org/synapse/blob/master/CONTRIBUTING.rst.

Signed-off-by: Brandon Valentine <brandon@brandonvalentine.com>
@bval bval force-pushed the destroy-socket-before-creating-a-new-one branch from 37b6b1a to 78f0b5d Compare October 1, 2018 19:07
@bval
Copy link
Author

bval commented Oct 1, 2018

@Half-Shot No problem! Commit amended w/ signature. Think I got that right. Thanks for the review!

@Half-Shot Half-Shot merged commit 912f864 into matrix-org:master Oct 1, 2018
@bval bval deleted the destroy-socket-before-creating-a-new-one branch October 1, 2018 21:03
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.

None yet

2 participants