Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I had max open file problems on Mac, but I suppose the problem is on other platforms too.
I'm not familiar with the TCPSocket implementation but it looks like the socket is not being released if it's not explicitly closed, I read that it will be closed when it'll be read from or written to (and catch EOF or something like that), but it never seems to happen and the socket stays in a CLOSED state forever.
The way to reproduce was pretty much (in Rails console):
Then leave the Rails console open and run "lsof -n" on the PID of the Rails console and there will be a CLOSED TCP socket open like this:
If you start more in the same session, they'll pile up.
I'm not sure that there's a way to add an rspec test for this without lsof.