Re: merge-similar-outgoing-queries.patch and lame servers
Jeff King <[email protected]>
| Newsgroups | gmane.network.djbdns |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Mar 03, 2009 at 02:01:53PM +0000, Gerrit Pape wrote:
> Hi, it looks like the patch doesn't handle responses from lame servers
> properly. If such a single request gets a response from a lame server,
> it can happen that no further requests are sent. To reproduce, look for
> a domain with a lame server, and do
Thanks for the bug report.
I believe what is happening is that dnscache is hanging in the iopause
call due to a bug in the qmerge patch. A patch (on top of qmerge) is
below. Let me know if it solves your problem.
-- >8 --
fix qmerge iopause hang
The qmerge layer works by sitting between the query and
dns_transmit layers and silently merging duplicate queries.
Because there are multiple queriers interested in the
answer, a qmerge query may be in a state where we have
received an answer, but not all queriers have consumed the
answer (qm->state == 2).
When we are asked to provide an iopause_fd for such a query
in such a state, we fill in "-1" for the fd and claim we are
not interested in either reading or writing. Then when the
querier eventually asks to read data, we feed them the
already-received answer.
However, if _all_ of the active queries are in this state,
then we will call to iopause without any actual I/O pending,
waiting for either a new query to come in or the default
120-second timeout to occur.
The solution is to drop the iopause timeout to zero when we
already have an answer waiting to be consumed.
---
qmerge.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/qmerge.c b/qmerge.c
index 7c92299..be2fafd 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -90,11 +90,12 @@ void qmerge_io(struct qmerge *qm, iopause_fd *io, struct taia *deadline)
if (qm->state == 0) {
dns_transmit_io(&qm->dt, io, deadline);
qm->state = 1;
+ return;
}
- else {
- io->fd = -1;
- io->events = 0;
- }
+ if (qm->state == 2)
+ taia_now(deadline);
+ io->fd = -1;
+ io->events = 0;
}
int qmerge_get(struct qmerge **x, const iopause_fd *io, const struct taia *when)
--
1.6.2.rc2.330.gba39e