From: Wouter Wijngaards Date: Fri, 25 Jan 2008 10:23:57 +0000 (+0000) Subject: Fixup race. X-Git-Tag: release-0.9~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bb9aaafcac6f1516a12727cc260fc53cccf1ca6;p=thirdparty%2Funbound.git Fixup race. git-svn-id: file:///svn/unbound/trunk@897 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index f286979df..373aa6613 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,6 +1,8 @@ 25 January 2008: Wouter - added tpkg for asynclook and library use. - 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 - tested the cancel() function. diff --git a/libunbound/unbound.c b/libunbound/unbound.c index a3fcf95c3..aab29f521 100644 --- a/libunbound/unbound.c +++ b/libunbound/unbound.c @@ -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); if(!q) { 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); diff --git a/libunbound/worker.c b/libunbound/worker.c index 9f35b6d8c..4af41b198 100644 --- a/libunbound/worker.c +++ b/libunbound/worker.c @@ -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); 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; } q->cancelled = 1;