Fixup race.

git-svn-id: file:///svn/unbound/trunk@897 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2008-01-25 10:23:57 +00:00
parent 7bfaf07981
commit 3bb9aaafca
3 changed files with 7 additions and 2 deletions

View file

@ -1,6 +1,8 @@
25 January 2008: Wouter 25 January 2008: Wouter
- added tpkg for asynclook and library use. - added tpkg for asynclook and library use.
- allows localhost to be queried when as a library. - allows localhost to be queried when as a library.
- fixup race condition between cancel and answer (in case of
really fast answers that beat the cancel).
24 January 2008: Wouter 24 January 2008: Wouter
- tested the cancel() function. - tested the cancel() function.

View file

@ -377,7 +377,9 @@ process_answer(struct ub_val_ctx* ctx, uint8_t* msg, uint32_t len)
q = context_deserialize_answer(ctx, msg, len, &err); q = context_deserialize_answer(ctx, msg, len, &err);
if(!q) { if(!q) {
lock_basic_unlock(&ctx->cfglock); lock_basic_unlock(&ctx->cfglock);
return 0; /* probably simply the lookup that failed, i.e.
* response returned before cancel was sent out, so noerror */
return 1;
} }
log_assert(q->async); log_assert(q->async);

View file

@ -166,7 +166,8 @@ handle_cancel(struct libworker* w, uint8_t* buf, uint32_t len)
{ {
struct ctx_query* q = context_deserialize_cancel(w->ctx, buf, len); struct ctx_query* q = context_deserialize_cancel(w->ctx, buf, len);
if(!q) { if(!q) {
log_err("deserialize cancel failed"); /* probably simply lookup failed, i.e. the message had been
* processed and answered before the cancel arrived */
return; return;
} }
q->cancelled = 1; q->cancelled = 1;