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

Refactor listener closing code #2112

Merged
merged 4 commits into from Mar 3, 2020
Merged

Conversation

@wjordan
Copy link
Contributor

wjordan commented Feb 8, 2020

Description

This PR fixes a bug/issue where a Unix socket created for a control server (e.g., --control-url unix://control.sock) was not being properly removed on server shutdown.

This fix has two parts:

  1. Binder#parse adds its urls to @listeners allowing them to be automatically cleaned up by Binder#close_listeners when the server shuts down, and the code path setting up the control-server listeners was not adding its urls to this array. #2111 (which this PR extends) fixes this part by simplifying the control-server code to call Binder#parse instead.
  2. The control server was only being stopped on shutdown, but the associated listeners were never closed. This PR adds a call to close_binder_listeners to always close the control listeners as well.

I've modified the pumactl integration tests to ensure the unix paths are cleaned up after getting shutdown by halt and stop commands. (Both tests fail without the fix in this PR.)

Finally, for related cleanup the call to @binder.close_unix_paths on launcher shutdown was no longer needed (because closing listeners is handled more consistently by calls to close_binder_listeners). I've removed this method to simplify the interface.

Your checklist for this pull request

  • I have reviewed the guidelines for contributing to this repository.
  • I have added an entry to History.md if this PR fixes a bug or adds a feature. If it doesn't need an entry to HISTORY.md, I have added [changelog skip] the pull request title.
  • I have added appropriate tests if this PR fixes a bug or adds a feature.
  • My pull request is 100 lines added/removed or less so that it can be easily reviewed.
  • If this PR doesn't need tests (docs change), I added [ci skip] to the title of the PR.
  • If this closes any issues, I have added "Closes #issue" to the PR description or my commit messages.
  • I have updated the documentation accordingly.
  • All new and existing tests passed, including Rubocop.
wjordan added 2 commits Feb 7, 2020
Reuse logic from Binder#parse.
@nateberkopec nateberkopec added the bug label Feb 9, 2020
@wjordan wjordan force-pushed the wjordan:listener_refactor branch 3 times, most recently from 09d638d to cfc7b0f Feb 10, 2020
Remove Binder#close_unix_paths
@wjordan wjordan force-pushed the wjordan:listener_refactor branch from cfc7b0f to 493b3f5 Feb 11, 2020
@nateberkopec
Copy link
Member

nateberkopec commented Mar 3, 2020

Confirmed test fails on master 👍

@nateberkopec nateberkopec merged commit 9647470 into puma:master Mar 3, 2020
1 check was pending
1 check was pending
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@MSP-Greg
Copy link
Contributor

MSP-Greg commented Mar 3, 2020

Confirmed test fails on master

Actually, Actions can't download the Ruby binary, although all of the Ruby binaries are downloaded on install..

Both the Ubuntu & macOS files come from the same place, https://github.com/ruby/ruby-dev-builder/releases. Why it can retrieve the macOS fine, but not Ubuntu is odd. The code used is standard GitHub code, it may not have any retry code, I'm not sure...

@nateberkopec
Copy link
Member

nateberkopec commented Mar 3, 2020

@MSP-Greg sorry, I meant I did a checkout on that test locally against the master branch, and it fails on master branch

@nateberkopec
Copy link
Member

nateberkopec commented Mar 3, 2020

This may have broken the 2.2 build though, ugh.

@nateberkopec
Copy link
Member

nateberkopec commented Mar 3, 2020

2.2 on Travis will be the death of me, I'm sure.

@MSP-Greg
Copy link
Contributor

MSP-Greg commented Mar 3, 2020

2.2 on Travis will be the death of me, I'm sure.

Don't know if I mentioned it, but 2.2 was left out of Actions CI because...

See https://bugs.ruby-lang.org/issues/13239

It was not backported to 2.2. Maybe it's time?

@MSP-Greg
Copy link
Contributor

MSP-Greg commented Mar 3, 2020

JFYI, I added two 'unless <io>.closed?' statements, and Actions Ruby 2.2 was failing on:

TestLauncher#test_dependencies_and_files_to_require_after_prune_is_correctly_built_with_extra_deps [/home/runner/work/puma/puma/test/test_launcher.rb:30]:
Expected /puma\/lib$/ to match # encoding: US-ASCII
#    valid: true
"/home/runner/work/puma/extensions/x86_64-linux/2.2.0-static/puma-4.3.3".

  2) Failure:
TestLauncher#test_dependencies_and_files_to_require_after_prune_is_correctly_built_for_no_extra_deps [/home/runner/work/puma/puma/test/test_launcher.rb:14]:
Expected /puma\/lib$/ to match # encoding: US-ASCII
#    valid: true
"/home/runner/work/puma/extensions/x86_64-linux/2.2.0-static/puma-4.3.3".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.