Skip to content

TCP keepalive on Darwin is overlooked and is not enabled on some platforms #336

@panjf2000

Description

@panjf2000

Environment

Include the result of the following commands:

  • nginx -V: master branch
  • uname -a: Darwin 23.6.0 arm64, macOS 14.6.1

Description

Currently, nginx detects TCP_KEEPIDLE when running configure on all Unix-like platforms. However, macOS uses TCP_KEEPALIVE in place of TCP_KEEPIDLE, which leads nginx on macOS to fail the detection and overlook the TCP keepalive mechanism that is fully supported on macOS.

Furthermore, for TCP keepalive mechanism, SO_KEEPALIVE is inherited by a accepted socket from the listening socket on most UNIX-like OS's, whereas TCP_KEEP* options are only inherited on Linux, FreeBSD, or DragonFlyBSD, which means platforms other than linux, freebsd and dragonflybsd don't not enable TCP keepalive currently.

  • The bug is reproducible with the latest version of nginx
  • The nginx configuration is minimized to the smallest possible
    to reproduce the issue and doesn't contain third-party modules

nginx configuration

-

nginx debug log

auto/configure

...

checking for IPV6_MTU_DISCOVER ... not found
checking for IP_DONTFRAG ... found
checking for IPV6_DONTFRAG ... found
checking for TCP_DEFER_ACCEPT ... not found
*checking for TCP_KEEPIDLE ... not found*

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