- assert(t);
-
- if (revents & EPOLLOUT) {
- struct iovec iov[2];
- be16_t sz;
- ssize_t ss;
-
- sz = htobe16(t->sent->size);
-
- iov[0].iov_base = &sz;
- iov[0].iov_len = sizeof(sz);
- iov[1].iov_base = DNS_PACKET_DATA(t->sent);
- iov[1].iov_len = t->sent->size;
-
- IOVEC_INCREMENT(iov, 2, t->tcp_written);
-
- ss = writev(fd, iov, 2);
- if (ss < 0) {
- if (errno != EINTR && errno != EAGAIN) {
- dns_query_transaction_set_state(t, DNS_QUERY_RESOURCES);
- return -errno;
- }
- } else
- t->tcp_written += ss;
-
- /* Are we done? If so, disable the event source for EPOLLOUT */
- if (t->tcp_written >= sizeof(sz) + t->sent->size) {
- r = sd_event_source_set_io_events(s, EPOLLIN);
- if (r < 0) {
- dns_query_transaction_set_state(t, DNS_QUERY_RESOURCES);
- return r;
- }
- }
- }
-
- if (revents & (EPOLLIN|EPOLLHUP|EPOLLRDHUP)) {
-
- if (t->tcp_read < sizeof(t->tcp_read_size)) {
- ssize_t ss;