Hand listening sockets over on a reload

A service's TCP listening socket is kept as a listener: when a reload
commits, before the old services are told to stop, each new service
takes over the listener of an older configuration's service on the same
address, port, network namespace and device with the same -ol options.
It skips socket() and bind(), calling only listen() again for its own
backlog, and logs "Accepting connections, taken over". The old service
stops accepting at its next poll and lets go of the socket; whoever
lets go last closes it, unlinking a Unix socket's path.

So a service staying where it was no longer leaves a gap: before, the
old one closed its socket and the new one opened another, and a
connection queued on the old socket was reset. UDP services, whose
clients read from the service's socket, and two services of the same
configuration on one address keep their own sockets as before.

A test case makes requests nonstop through three reloads and wants none
refused or reset; against the build before this, connections were
reset. The reload case no longer waits out the switch. SIGUSR1 in
3proxy(8) describes how a reload behaves now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir DubrovinandClaude Opus 5.5 committed 2026-10-14 22:14:04 +03:00
1 parent 06ba6570f8
commit 3520e6e7cf
9 files changed
+256 -8

No files matched your search

+10 -1
View File
@@ -154,7 +154,16 @@ connections</p>
<p style="margin-left:9%;"><b>SIGUSR1</b></p>
<p style="margin-left:18%;">reload configuration</p>
<p style="margin-left:18%;">reload configuration. The file is read whole before anything changes: if
it has an error, the configuration in force stays as it is, its services
running. Otherwise the new services start and the old ones stop accepting
within a second; connections already open finish under the old
configuration. A new service listening on the same address and port, in
the same network namespace and on the same device, with the same <b>-ol</b>
options, takes over the old service's TCP listening socket, so no
connection is refused or lost meanwhile; any other listening socket is
closed by the old service and opened by the new one. Settings left out of
the new file go back to their defaults.</p>
<p style="margin-left:9%; margin-top: 1em">Under Windows,
if <b>3proxy</b> is installed as a service you can use