UDP loop: epoll on Linux

The UDP loop gave poll() every socket of its sessions each time round.
On Linux it now keeps them in an epoll set: the service's socket and
each session's socket and parent's control connection are registered
once and changed as the session changes, a socket replaced or other
events waited for, and an event leads straight to its session. A
handler replacing a session's socket marks it to be registered again,
as a closed socket leaves the set and its number may come back for the
new one; dnspr does so moving on to the next name server. Sessions
handed over on a reload leave the set of the old service's loop and are
registered by the one adopting them; the service's socket is left
unwatched while an older service still serves it. Elsewhere, or built
with NOEPOLL, poll() is used as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir DubrovinandClaude Opus 5.5 committed 2026-10-18 18:57:22 +03:00
1 parent f5e646ba86
commit d9b9d1b9b7
3 files changed
+139 -4

No files matched your search

+2
View File
@@ -156,6 +156,8 @@ static int dnsforward(struct udploop *u, struct udpsession *ss){
param->srv->so._closesocket(param->sostate, param->remsock);
param->remsock = INVALID_SOCKET;
}
/* another socket for the loop to watch */
ss->regsock = INVALID_SOCKET;
q->tcp = c->nservers[q->server].usetcp;
q->got = 0;
{