- if (opts & OPT_DEBUG)
- msg("%d in queue; checking %.*s", len,
- head->rest-head->addr, head->addr);
- if (eof || len > MAXPENDING)
- if (opts & OPT_POLL)
- err= adns_wait_poll(adns, &head->query, &answer, NULL);
- else
- err= adns_wait(adns, &head->query, &answer, NULL);
- else
- err= adns_check(adns, &head->query, &answer, NULL);
- if (err != EAGAIN) {
+ while (head) {
+ if (opts & OPT_DEBUG)
+ msg("%d in queue; checking %.*s", len,
+ head->rest-head->addr, guard_null(head->addr));
+ if (eof || len >= maxpending) {
+ if (opts & OPT_POLL)
+ err= adns_wait_poll(adns, &head->query, &answer, NULL);
+ else
+ err= adns_wait(adns, &head->query, &answer, NULL);
+ } else {
+ err= adns_check(adns, &head->query, &answer, NULL);
+ }
+ if (err == EAGAIN) break;
+ if (err) {
+ fprintf(stderr, "%s: adns_wait/check: %s", progname, strerror(err));
+ exit(1);
+ }