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

Undefined constant on platforms without tcp_cork support and with closed_socket support #2556

Closed
gamecreature opened this issue Feb 15, 2021 · 6 comments · Fixed by #2588
Closed
Labels

Comments

@gamecreature
Copy link

gamecreature commented Feb 15, 2021

Missing constant Read: #<NameError: uninitialized constant Puma::Server::UNPACK_TCP_STATE_FROM_TCP_INFO> on platforms that have no 'tcp_cork_support?' and do have 'closed_socket_supported?'

https://stackoverflow.com/questions/66088219/pumaserverunpack-tcp-state-from-tcp-info/66214024#66214024

In file lib/puma/server.rb is the following construct:

    if tcp_cork_supported?
      UNPACK_TCP_STATE_FROM_TCP_INFO = "C".freeze
      # ...
    end 
 
    if closed_socket_supported?
     # ... 
      state = tcp_info.unpack(UNPACK_TCP_STATE_FROM_TCP_INFO)[0]
    end

If tcp_cork_supported? is FALSE and closed_socket_supported? is TRUE, an uninitialized constant Puma::Server::UNPACK_TCP_STATE_FROM_TCP_INFO is used!

Is it a problem to move 'UNPACK_TCP_STATE_FROM_TCP_INFO = "C".freeze' outside the if condition?

@MSP-Greg
Copy link
Member

MSP-Greg commented Feb 15, 2021

@gamecreature

Thanks. This is a bug, as UNPACK_TCP_STATE_FROM_TCP_INFO is defined in the incorrect location. Not picked up by the available CI OS's (Ubuntu, macOS, Windows).

I added it to #2554, which a a minor refactor of a few files...

@dentarg
Copy link
Member

dentarg commented Feb 15, 2021

Regression since Puma v5.0.1: 7928173 (also related: 55e4ead)

@dentarg dentarg added the bug label Feb 15, 2021
dentarg added a commit to dentarg/puma that referenced this issue Apr 1, 2021
This fixes the issue for me when I run Puma in FreeBSD using Vagrant.

Close puma#2556
nateberkopec pushed a commit that referenced this issue Apr 2, 2021
This fixes the issue for me when I run Puma in FreeBSD using Vagrant.

Close #2556
@gamecreature
Copy link
Author

Thank you!!

@khustochka
Copy link
Contributor

It is reproduced for me on FreeBSD 13.0-RELEASE

Puma version: 5.2.2 (ruby 3.0.1-p64) ("Fettisdagsbulle")

Is there anything I may be doing wrong, or any debug information I can provide?

Thank you!

@MSP-Greg
Copy link
Member

Bug fixed in master by the above referenced PR / commit. So, next release

@khustochka
Copy link
Contributor

Thank you!

Sorry, I assumed it is released from the dates.

JuanitoFatas pushed a commit to JuanitoFatas/puma that referenced this issue Sep 9, 2022
This fixes the issue for me when I run Puma in FreeBSD using Vagrant.

Close puma#2556
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants