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

core: Apply SO_REUSEPORT to UDP sockets #5725

Merged
merged 14 commits into from
Oct 17, 2023
Merged

core: Apply SO_REUSEPORT to UDP sockets #5725

merged 14 commits into from
Oct 17, 2023

Commits on Aug 9, 2023

  1. core: Apply SO_REUSEPORT to UDP sockets

    For some reason, 10 months ago when I implemented SO_REUSEPORT
    for TCP, I didn't realize, or forgot, that it can be used for UDP too. It is a
    much better solution than using deadline hacks to reuse a socket, at
    least for TCP.
    
    Then mholt/caddy-l4#132 was posted,
    in which we see that UDP servers never actually stopped when the
    L4 app was stopped. I verified this using this command:
    
        $ nc -u 127.0.0.1 55353
    
    combined with POSTing configs to the /load admin endpoint (which
    alternated between an echo server and a proxy server so I could tell
    which config was being used).
    
    I refactored the code to use SO_REUSEPORT for UDP, but of course
    we still need graceful reloads on all platforms, not just Unix, so I
    also implemented a deadline hack similar to what we used for
    TCP before. That implementation for TCP was not perfect, possibly
    having a logical (not data) race condition; but for UDP so far it
    seems to be working. Verified the same way I verified that SO_REUSEPORT
    works.
    
    I think this code is slightly cleaner and I'm fairly confident this code
    is effective.
    mholt committed Aug 9, 2023
    Configuration menu
    Copy the full SHA
    06b24ed View commit details
    Browse the repository at this point in the history
  2. Check error

    mholt committed Aug 9, 2023
    Configuration menu
    Copy the full SHA
    665e389 View commit details
    Browse the repository at this point in the history
  3. Fix return

    mholt committed Aug 9, 2023
    Configuration menu
    Copy the full SHA
    056eb19 View commit details
    Browse the repository at this point in the history
  4. Fix var name

    mholt committed Aug 9, 2023
    Configuration menu
    Copy the full SHA
    ebd092c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    30d3a2e View commit details
    Browse the repository at this point in the history

Commits on Oct 12, 2023

  1. Configuration menu
    Copy the full SHA
    4a88af4 View commit details
    Browse the repository at this point in the history

Commits on Oct 13, 2023

  1. Configuration menu
    Copy the full SHA
    ea27801 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    324d1a6 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d967980 View commit details
    Browse the repository at this point in the history

Commits on Oct 16, 2023

  1. Configuration menu
    Copy the full SHA
    80b3ce0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8162f5a View commit details
    Browse the repository at this point in the history
  3. Fix Windows

    mholt committed Oct 16, 2023
    Configuration menu
    Copy the full SHA
    348067c View commit details
    Browse the repository at this point in the history

Commits on Oct 17, 2023

  1. Configuration menu
    Copy the full SHA
    3cd28ed View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7f96635 View commit details
    Browse the repository at this point in the history