diff options
Diffstat (limited to 'lib/dns/xfrin.c')
-rw-r--r-- | lib/dns/xfrin.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 30f2f3b347f45..a5e4bf8742197 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2008, 2011-2013 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008, 2011-2013, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -107,6 +107,7 @@ struct dns_xfrin_ctx { int sends; /*%< Send in progress */ int recvs; /*%< Receive in progress */ isc_boolean_t shuttingdown; + isc_result_t shutdown_result; dns_name_t name; /*%< Name of zone to transfer */ dns_rdataclass_t rdclass; @@ -657,7 +658,8 @@ dns_xfrin_create2(dns_zone_t *zone, dns_rdatatype_t xfrtype, CHECK(xfrin_start(xfr)); xfr->done = done; - xfr->refcount++; + if (xfr->done != NULL) + xfr->refcount++; *xfrp = xfr; failure: @@ -762,6 +764,7 @@ xfrin_fail(dns_xfrin_ctx_t *xfr, isc_result_t result, const char *msg) { xfr->done = NULL; } xfr->shuttingdown = ISC_TRUE; + xfr->shutdown_result = result; maybe_free(xfr); } @@ -802,6 +805,7 @@ xfrin_create(isc_mem_t *mctx, xfr->sends = 0; xfr->recvs = 0; xfr->shuttingdown = ISC_FALSE; + xfr->shutdown_result = ISC_R_UNSET; dns_name_init(&xfr->name, NULL); xfr->rdclass = rdclass; @@ -1365,6 +1369,7 @@ xfrin_recv_done(isc_task_t *task, isc_event_t *ev) { * point, thus maybe_free() should succeed. */ xfr->shuttingdown = ISC_TRUE; + xfr->shutdown_result = ISC_R_SUCCESS; maybe_free(xfr); break; default: @@ -1403,6 +1408,7 @@ static void maybe_free(dns_xfrin_ctx_t *xfr) { isc_uint64_t msecs; isc_uint64_t persec; + const char *result_str; REQUIRE(VALID_XFRIN(xfr)); @@ -1411,6 +1417,16 @@ maybe_free(dns_xfrin_ctx_t *xfr) { xfr->recvs != 0) return; + INSIST(! xfr->shuttingdown || xfr->shutdown_result != ISC_R_UNSET); + + /* If we're called through dns_xfrin_detach() and are not + * shutting down, we can't know what the transfer status is as + * we are only called when the last reference is lost. + */ + result_str = (xfr->shuttingdown ? + isc_result_totext(xfr->shutdown_result) : "unknown"); + xfrin_log(xfr, ISC_LOG_INFO, "Transfer status: %s", result_str); + /* * Calculate the length of time the transfer took, * and print a log message with the bytes and rate. |