Skip to content

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

@gamecreature

Description

@gamecreature

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions