2.2 Startup Sequence
2.2.1 The sequence #
- The native socket. The runtime directory and the socket are
created and given their modes and descriptors (§2.4). A failure to
create the directory, set a mode, remove a stale socket file, bind,
or make the listener nonblocking is fatal: resolvd logs
native socket: <error>at error level and exits with status 1. A failure to write a descriptor is not fatal (§2.4). - The stub listener. A UDP socket and then a TCP listener are bound
to
127.0.0.53:53. A failure of either is fatal: resolvd logsstub listener on 127.0.0.53:53: <error>and exits with status 1. - The registry.
Machine\System\Network\Dnsis read whole (§2.3). A missing or unreadable key is not an error; every value takes its default. - The registry watch. A subtree watch is armed on
Machine\System\Network(§2.3). If it cannot be armed, resolvd logsregistry watch unavailable (<error>); configuration is read onceand runs on the configuration it read in step 3 until it restarts. - Query entropy. The engine is given a kernel-randomness provider.
Every upstream transaction obtains fresh bytes through nonblocking
getrandom; startup does not seed a userspace generator or read/dev/urandom. There is no clock fallback. - The engine's inputs. The engine is given the kernel's hostname,
the fallback servers and search domains, and the static names. A
kernel hostname that is empty or
(none)counts as no hostname. - The control object is built from
ControlSecurity(§5.2). - netd. The first attempt to subscribe is made immediately (§3.1). Its failure is not fatal and is retried with backoff (§3.2).
- The listening line. resolvd logs
listening on /run/resolvd/resolv.sock and 127.0.0.53:53at info level. - Readiness.
READY=1is sent (§2.1). - The loop is entered (§2.5).
2.2.2 Answering from the moment of readiness #
Both doors are open, and answering, before readiness is reported, and
neither waits for netd. A question asked the moment resolvd is ready is
answered at once: synthetic and static names are answered, and anything
that needs a server is answered unavailable until either a snapshot
arrives or fallback servers are configured (§3.2).
2.2.3 Exiting #
resolvd has no shutdown path of its own. Apart from the startup failures above, nothing a client or an upstream server sends makes it exit.
2.2.3.1 Ending on a signal #
resolvd installs no signal handlers, so it ends when peinit signals it,
with the default disposition, and leaves /run/resolvd/resolv.sock
behind. The next start removes the stale socket file before binding
(§2.4).
2.2.3.2 A poll failure exits #
When poll fails with anything other than EINTR, resolvd logs
poll: <error> at error level and exits with status 1. EINTR is
retried.