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

Move ssl detection to puma.rb [changelog skip] #2541

Merged
merged 1 commit into from Feb 1, 2021

Conversation

MSP-Greg
Copy link
Member

@MSP-Greg MSP-Greg commented Jan 29, 2021

Description

puma.rb loads puma/puma_http11, which contains the compiled c code for ssl. Move ssl detection from puma/detect.rb to puma.rb

Fix Puma::IS_WINDOWS and Puma.windows? to work with JRuby.

No breaking API changes.

JFYI, quick benchmark of predicate methods (Puma.ssl?) vs constants (Puma::HAS_SSL), showed constants were about twice as fast. But, both are 'fast enough'. Haven't looked thru the code to change...

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] or [ci skip] to 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.

@nateberkopec
Copy link
Member

Hmmm... why are we moving it? It looks like everything is still loaded in the same order, right? It feels cleaner to keep it in detect.

@nateberkopec nateberkopec added maintenance waiting-for-changes Waiting on changes from the requestor labels Jan 30, 2021
@MSP-Greg
Copy link
Member Author

why are we moving it?

Since HAS_SSL is defined at loadtime, (and hence Puma.ssl?), puma/puma_http11 has to be loaded first. Currently I think it's loaded in puma.rb and one other file. I may have had an issue running a single test file, but also control_cli.rb uses methods from detect.rb. It doesn't load puma.rb, but it can if a 'start' command is issued.

So if detect.rb is loaded first, HAS_SSL is false, even though it may be true. By moving it to puma.rb, where the file that determines it is required, we avoid issues forever. That's why I added the comment that (I hope) states that only env/os related settings should be contained in detect.rb... I think that made sense...

@nateberkopec nateberkopec added waiting-for-review Waiting on review from anyone and removed waiting-for-changes Waiting on changes from the requestor labels Jan 31, 2021
puma.rb loads puma/puma_http11, which contains the compiled c code for ssl.  Move ssl detection from puma/detect.rb to puma.rb
@nateberkopec nateberkopec merged commit 37f47ca into puma:master Feb 1, 2021
@MSP-Greg MSP-Greg deleted the puma-detect branch February 2, 2021 04:21
JuanitoFatas pushed a commit to JuanitoFatas/puma that referenced this pull request Sep 9, 2022
puma.rb loads puma/puma_http11, which contains the compiled c code for ssl.  Move ssl detection from puma/detect.rb to puma.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance waiting-for-review Waiting on review from anyone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants