]> git.ipfire.org Git - thirdparty/systemd.git/commit
resolved: Read as much as possible per stream EPOLLIN event
authorJoan Bruguera <joanbrugueram@gmail.com>
Sun, 30 Jan 2022 11:51:10 +0000 (12:51 +0100)
committerJoan Bruguera <joanbrugueram@gmail.com>
Tue, 1 Feb 2022 18:25:32 +0000 (19:25 +0100)
commit839a70c3534ce10ed7a66b5925f4570d88b2b64a
tree105dd504b6317311540e89b37f0086e264daff02
parentaa892849d50e9dd5da03a628463ccf6c55ff1b44
resolved: Read as much as possible per stream EPOLLIN event

In commit 2aaf6bb6e99b0f2bd73e0c49bef9e11a2844bf1a, an issue was fixed where
systemd-resolved could get stuck for multiple seconds waiting for incoming data,
since GnuTLS/OpenSSL can buffer a TLS record, so data could be available, but
no EPOLLIN event would be generated.

To fix this, a somewhat elaborate logic consisting on asking the TLS library
whether it had buffered data, then "faking" an EPOLLIN event was implemented.

However, there is a much simpler solution: Always read as much data as available
(i.e. until we get an event like EAGAIN when trying to read) from the stream
when we get an EPOLLIN event, instead of at most a single packet per event.
This approach does not require asking the TLS library whether it has buffered
data, and the logic is exactly the same for both the TCP and TLS case.

test-resolved-stream is fixed to avoid a latent double free bug.
src/resolve/resolved-dns-stream.c
src/resolve/resolved-dnstls-gnutls.c
src/resolve/resolved-dnstls-openssl.c
src/resolve/resolved-dnstls.h
src/resolve/test-resolved-stream.c