mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Share one listening socket among services on one address
Services of one configuration on the same address, port, network
namespace and device now share one listener and its socket, all
accepting on it, instead of each binding its own: on Linux the second
bind failed unless SO_REUSEPORT was set. A listener keeps a list of the
services accepting on it; the first to start opens the socket under the
listener's open_mutex, as binding may take long, and the others use it
("Accepting connections, shared"). The socket is closed once the last of
them stops.
Such services must be of one type with the same -ol options: otherwise
the configuration is refused ("a service of another type listens
there", "a service with other socket options listens there").
mainclaim() now runs for every service, at startup too: it joins the
listener of its configuration for the address, takes over one of an
older configuration (one of its type first), or makes a new one, under
one hold of listener_mutex so that a listener found is not freed before
it is joined.
Services connecting back (-r) to one place share a pseudo-listener
without a socket, of any type. After a reload a client moves to one of
the newest services of its type on its listener with a slot free: 26 if
there is none of its type, 27 if none has a slot.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d33e2d76c0
commit
d83a48fe18
6 files changed
+260
-144
No files matched your search
@@ -161,17 +161,19 @@ 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, takes over the old
|
||||
service's TCP or UDP socket, so no connection is refused or lost
|
||||
meanwhile, and UDP sessions go on through it; a service of the same type
|
||||
is preferred where several share an address, as two services of one
|
||||
configuration may. Of the <b>-ol</b> options only those acting when the socket is
|
||||
meanwhile, and UDP sessions go on through it. Services of one
|
||||
configuration on one address share its socket, all accepting on it; they
|
||||
must be of the same type with the same <b>-ol</b> options, or the
|
||||
configuration is refused. Of the <b>-ol</b> options only those acting when the socket is
|
||||
bound must be the same (SO_REUSEADDR, SO_REUSEPORT, SO_EXCLUSIVEADDRUSE,
|
||||
IP_TRANSPARENT, TCP_FASTOPEN); the others are set on the socket taken over,
|
||||
those no longer given turned off. Otherwise the old service closes its
|
||||
socket and the new one opens another. Connections of the old services are
|
||||
re-authenticated as clients of the new service on their address, or on the
|
||||
place a service connecting back (<b>-r</b>) connects to, unless <b>noforce</b> is set;
|
||||
place a service connecting back (<b>-r</b>) connects to (several
|
||||
may connect to one place), unless <b>noforce</b> is set;
|
||||
they are closed if their service was removed or is of another type, or if
|
||||
the new one has no free slot of its maxconn. Settings left out of
|
||||
none of the new ones of their type has a free slot of its maxconn. Settings left out of
|
||||
the new file go back to their defaults.</p>
|
||||
|
||||
<p style="margin-left:9%; margin-top: 1em">Under Windows,
|
||||
|
||||
Reference in new issue
Block a user