+void adns_afterselect(adns_state ads, int maxfd, const fd_set *readfds,
+ const fd_set *writefds, const fd_set *exceptfds,
+ const struct timeval *now) {
+ struct timeval tv_buf;
+ struct pollfd pollfds[MAX_POLLFDS];
+ int npollfds, i;
+
+ adns__consistency(ads,0,cc_entex);
+ adns__must_gettimeofday(ads,&now,&tv_buf);
+ if (!now) goto xit;
+ adns_processtimeouts(ads,now);
+
+ npollfds= adns__pollfds(ads,pollfds);
+ for (i=0; i<npollfds; i++) pollfds[i].revents= POLLIN|POLLOUT|POLLPRI;
+ adns__fdevents(ads,
+ pollfds,npollfds,
+ maxfd,readfds,writefds,exceptfds,
+ *now, 0);
+xit:
+ adns__returning(ads,0);
+}
+
+/* General helpful functions. */
+
+void adns_globalsystemfailure(adns_state ads) {
+ adns__consistency(ads,0,cc_entex);
+
+ while (ads->udpw.head) adns__query_fail(ads->udpw.head, adns_s_systemfail);
+ while (ads->tcpw.head) adns__query_fail(ads->tcpw.head, adns_s_systemfail);
+
+ switch (ads->tcpstate) {
+ case server_connecting:
+ case server_ok:
+ adns__tcp_broken(ads,0,0);
+ break;
+ case server_disconnected:
+ case server_broken:
+ break;
+ default:
+ abort();
+ }
+ adns__returning(ads,0);
+}
+
+int adns_processany(adns_state ads) {
+ int r, i;
+ struct timeval now;
+ struct pollfd pollfds[MAX_POLLFDS];
+ int npollfds;
+
+ adns__consistency(ads,0,cc_entex);
+
+ r= gettimeofday(&now,0);
+ if (!r) adns_processtimeouts(ads,&now);
+
+ /* We just use adns__fdevents to loop over the fd's trying them.
+ * This seems more sensible than calling select, since we're most
+ * likely just to want to do a read on one or two fds anyway.
+ */
+ npollfds= adns__pollfds(ads,pollfds);
+ for (i=0; i<npollfds; i++) pollfds[i].revents= pollfds[i].events & ~POLLPRI;
+ adns__fdevents(ads,
+ pollfds,npollfds,
+ 0,0,0,0,
+ now,&r);
+
+ adns__returning(ads,0);
+ return 0;
+}