dnspr: name servers asked from the loop, nothing waits in it

dnspr answered an A or AAAA query missing from the name cache with
udpresolve(), which waited for the name servers in place, and a name
server over TCP was waited for in place too, holding up every query of
the service. Now only the name cache is looked at in place; anything it
does not have goes to the name servers from the loop: over UDP the query
is sent on a socket the loop waits on, over TCP the socket is connected
without waiting, the query written once the loop sees it writable, and
the answer read in as many pieces as it comes. A name server silent for
DNS_TO is followed by the next one, as udpresolve() did; the last ends
the query with 821. An address in an answer is kept in the name cache,
unless -s says not to use it.

The UDP loop lets a session say what it waits for on its socket
(events) and a service handle a session's deadline itself (timeout).

Tests: an A query not in the cache answered by the name server and then
from the cache with the server gone, an A query waiting for a silent
name server while another is answered, a name server over TCP whose
answer comes in pieces, and the second name server asked when the
first is silent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir DubrovinandClaude Opus 5.5 committed 2026-10-18 16:50:34 +03:00
1 parent f28552fc6f
commit 58334cb51c
5 files changed
+296 -97

No files matched your search

+4
View File
@@ -252,6 +252,7 @@ struct udpsession {
int idle; /* seconds of silence it lasts, 0: deadline fixed */
int keyed; /* found by its client's address */
int done; /* to be ended, param->res saying how */
short events; /* polled for on remsock, 0: POLLIN */
void *data; /* the service's own, freed by it in end() */
};
struct udpservice {
@@ -269,6 +270,9 @@ struct udpservice {
void (*end)(struct udploop *u, struct udpsession *ss);
/* param->res of a session whose deadline passed */
int timeoutres;
/* or, if set, its deadline passed: 0 if it goes on, a new deadline
set, nonzero to end it, param->res saying how */
int (*timeout)(struct udploop *u, struct udpsession *ss);
};
struct udploop {
struct srvparam *srv;