}
static int dns_stream_update_io(DnsStream *s) {
- int f = 0;
+ uint32_t f = 0;
assert(s);
set_size(s->queries) < DNS_QUERIES_PER_STREAM)
f |= EPOLLIN;
+ s->requested_events = f;
+
#if ENABLE_DNS_OVER_TLS
/* For handshake and clean closing purposes, TLS can override requested events */
if (s->dnstls_events != 0)
}
}
- if (s->type == DNS_STREAM_LLMNR_SEND && s->packet_received) {
- uint32_t events;
-
- /* Complete the stream if finished reading and writing one packet, and there's nothing
- * else left to write. */
-
- r = sd_event_source_get_io_events(s->io_event_source, &events);
- if (r < 0)
- return r;
-
- if (!FLAGS_SET(events, EPOLLOUT))
- return dns_stream_complete(s, 0);
- }
+ /* Complete the stream if finished reading and writing one packet, and there's nothing
+ * else left to write. */
+ if (s->type == DNS_STREAM_LLMNR_SEND && s->packet_received &&
+ !FLAGS_SET(s->requested_events, EPOLLOUT))
+ return dns_stream_complete(s, 0);
/* If we did something, let's restart the timeout event source */
if (progressed && s->timeout_event_source) {
uint32_t events;
/* Make sure the stream still wants to process more data... */
- r = sd_event_source_get_io_events(s->io_event_source, &events);
- if (r < 0)
- return r;
- if (!FLAGS_SET(events, EPOLLIN))
+ if (!FLAGS_SET(s->requested_events, EPOLLIN))
break;
r = on_stream_io_impl(s, EPOLLIN);
uint32_t ttl;
bool identified;
bool packet_received; /* At least one packet is received. Used by LLMNR. */
+ uint32_t requested_events;
/* only when using TCP fast open */
union sockaddr_union tfo_address;
#if ENABLE_DNS_OVER_TLS
DnsTlsStreamData dnstls_data;
- int dnstls_events;
+ uint32_t dnstls_events;
#endif
sd_event_source *io_event_source;