#include <dns/stats.h>
#include <dns/types.h>
-#define DISPATCH_TRACE
-
typedef ISC_LIST(dns_dispentry_t) dns_displist_t;
typedef struct dns_qid {
return (ev);
}
-#define dispentry_attach(r, rp) \
- __dispentry_attach(r, rp, __func__, __FILE__, __LINE__)
-
static void
-__dispentry_attach(dns_dispentry_t *resp, dns_dispentry_t **respp,
- const char *func, const char *file, unsigned int line) {
- uint_fast32_t ref;
-
+dispentry_attach(dns_dispentry_t *resp, dns_dispentry_t **respp) {
REQUIRE(VALID_RESPONSE(resp));
REQUIRE(respp != NULL && *respp == NULL);
- ref = isc_refcount_increment(&resp->references);
-
-#ifdef DISPATCH_TRACE
- fprintf(stderr, "%s:%s:%u:%s(%p, %p) = %" PRIuFAST32 "\n", func, file,
- line, __func__, resp, respp, ref + 1);
-#else
- UNUSED(func);
- UNUSED(file);
- UNUSED(line);
- UNUSED(ref);
-#endif /* DISPATCH_TRACE */
+ isc_refcount_increment(&resp->references);
*respp = resp;
}
static void
-__dispentry_destroy(dns_dispentry_t *resp) {
+dispentry_destroy(dns_dispentry_t *resp) {
dns_dispatch_t *disp = resp->disp;
resp->magic = 0;
isc_refcount_destroy(&resp->references);
-#ifdef DISPATCH_TRACE
- fprintf(stderr, "%s:%d:%s:isc_task_detach(%p) -> %p\n", __FILE__,
- __LINE__, __func__, &resp->task, resp->task);
-#endif /* DISPATCH_TRACE */
-
isc_task_detach(&resp->task);
isc_mem_put(disp->mgr->mctx, resp, sizeof(*resp));
dns_dispatch_detach(&disp);
}
-#define dispentry_detach(rp) \
- __dispentry_detach(rp, __func__, __FILE__, __LINE__)
-
static void
-__dispentry_detach(dns_dispentry_t **respp, const char *func, const char *file,
- unsigned int line) {
+dispentry_detach(dns_dispentry_t **respp) {
dns_dispentry_t *resp = NULL;
uint_fast32_t ref;
*respp = NULL;
ref = isc_refcount_decrement(&resp->references);
-
-#ifdef DISPATCH_TRACE
- fprintf(stderr, "%s:%s:%u:%s(%p, %p) = %" PRIuFAST32 "\n", func, file,
- line, __func__, resp, respp, ref - 1);
-#else
- UNUSED(func);
- UNUSED(file);
- UNUSED(line);
-#endif /* DISPATCH_TRACE */
-
if (ref == 1) {
- __dispentry_destroy(resp);
+ dispentry_destroy(resp);
}
}
}
void
-dns__dispatchmgr_attach(dns_dispatchmgr_t *mgr, dns_dispatchmgr_t **mgrp,
- const char *func, const char *file, unsigned int line) {
- uint_fast32_t ref;
-
+dns_dispatchmgr_attach(dns_dispatchmgr_t *mgr, dns_dispatchmgr_t **mgrp) {
REQUIRE(VALID_DISPATCHMGR(mgr));
REQUIRE(mgrp != NULL && *mgrp == NULL);
- ref = isc_refcount_increment(&mgr->references);
-
-#ifdef DISPATCH_TRACE
- fprintf(stderr, "%s:%s:%u:%s(%p, %p) = %" PRIuFAST32 "\n", func, file,
- line, __func__, mgr, mgrp, ref + 1);
-#else
- UNUSED(func);
- UNUSED(file);
- UNUSED(line);
- UNUSED(ref);
-#endif /* DISPATCH_TRACE */
+ isc_refcount_increment(&mgr->references);
*mgrp = mgr;
}
void
-dns__dispatchmgr_detach(dns_dispatchmgr_t **mgrp, const char *func,
- const char *file, unsigned int line) {
+dns_dispatchmgr_detach(dns_dispatchmgr_t **mgrp) {
dns_dispatchmgr_t *mgr = NULL;
uint_fast32_t ref;
*mgrp = NULL;
ref = isc_refcount_decrement(&mgr->references);
-
-#ifdef DISPATCH_TRACE
- fprintf(stderr, "%s:%s:%u:%s(%p, %p) = %" PRIuFAST32 "\n", func, file,
- line, __func__, mgr, mgrp, ref - 1);
-#else
- UNUSED(func);
- UNUSED(file);
- UNUSED(line);
-#endif /* DISPATCH_TRACE */
-
if (ref == 1) {
dispatchmgr_destroy(mgr);
}
}
result = isc_task_create(taskmgr, 50, &disp->task);
-
-#ifdef DISPATCH_TRACE
- fprintf(stderr, "%s:%d:%s:isc_task_create() -> %p\n", __FILE__,
- __LINE__, __func__, disp->task);
-#endif /* DISPATCH_TRACE */
-
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
disp->local = *localaddr;
result = isc_task_create(taskmgr, 0, &disp->task);
-
-#ifdef DISPATCH_TRACE
- fprintf(stderr, "%s:%d:%s:isc_task_create() -> %p\n", __FILE__,
- __LINE__, __func__, disp->task);
-#endif /* DISPATCH_TRACE */
-
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
isc_nmhandle_detach(&disp->handle);
}
-#ifdef DISPATCH_TRACE
- fprintf(stderr, "%s:%d:%s:isc_task_detach(%p) -> %p\n", __FILE__,
- __LINE__, __func__, &disp->task, disp->task);
-#endif /* DISPATCH_TRACE */
-
isc_task_detach(&disp->task);
dispatch_free(&disp);
}
void
-dns__dispatch_attach(dns_dispatch_t *disp, dns_dispatch_t **dispp,
- const char *func, const char *file, unsigned int line) {
- uint_fast32_t ref;
-
+dns_dispatch_attach(dns_dispatch_t *disp, dns_dispatch_t **dispp) {
REQUIRE(VALID_DISPATCH(disp));
REQUIRE(dispp != NULL && *dispp == NULL);
- ref = isc_refcount_increment(&disp->references);
-
-#ifdef DISPATCH_TRACE
- fprintf(stderr, "%s:%s:%u:%s(%p, %p) = %" PRIuFAST32 "\n", func, file,
- line, __func__, disp, dispp, ref + 1);
-#else
- UNUSED(func);
- UNUSED(file);
- UNUSED(line);
- UNUSED(ref);
-#endif /* DISPATCH_TRACE */
+ isc_refcount_increment(&disp->references);
*dispp = disp;
}
void
-dns__dispatch_detach(dns_dispatch_t **dispp, const char *func, const char *file,
- unsigned int line) {
+dns_dispatch_detach(dns_dispatch_t **dispp) {
dns_dispatch_t *disp = NULL;
uint_fast32_t ref;
*dispp = NULL;
ref = isc_refcount_decrement(&disp->references);
-
-#ifdef DISPATCH_TRACE
- fprintf(stderr, "%s:%s:%u:%s(%p, %p) = %" PRIuFAST32 "\n", func, file,
- line, __func__, disp, dispp, ref - 1);
-#else
- UNUSED(func);
- UNUSED(file);
- UNUSED(line);
-#endif /* DISPATCH_TRACE */
-
dispatch_log(disp, LVL(90), "detach: refcount %" PRIuFAST32, ref - 1);
-
if (ref == 1) {
LOCK(&disp->lock);
REQUIRE(disp->recv_pending == 0);
dns_dispatch_attach(disp, &res->disp);
-#ifdef DISPATCH_TRACE
- fprintf(stderr, "%s:%d:%s:isc_task_attach(%p, %p)\n", __FILE__,
- __LINE__, __func__, task, &res->task);
-#endif /* DISPATCH_TRACE */
-
isc_task_attach(task, &res->task);
res->id = id;
*\li anything else -- failure
*/
-#define dns_dispatchmgr_attach(mgr, mgrp) \
- dns__dispatchmgr_attach(mgr, mgrp, __func__, __FILE__, __LINE__)
-
void
-dns__dispatchmgr_attach(dns_dispatchmgr_t *mgr, dns_dispatchmgr_t **mgrp,
- const char *func, const char *file, unsigned int line);
-
-#define dns_dispatchmgr_detach(mgrp) \
- dns__dispatchmgr_detach(mgrp, __func__, __FILE__, __LINE__)
+dns_dispatchmgr_attach(dns_dispatchmgr_t *mgr, dns_dispatchmgr_t **mgrp);
+/*%<
+ * Attach to a dispatch manger.
+ *
+ * Requires:
+ *\li is valid.
+ *
+ *\li mgrp != NULL && *mgrp == NULL
+ */
void
-dns__dispatchmgr_detach(dns_dispatchmgr_t **mgrp, const char *func,
- const char *file, unsigned int line);
+dns_dispatchmgr_detach(dns_dispatchmgr_t **mgrp);
/*%<
- * Destroys the dispatchmgr when it becomes empty. This could be
- * immediately.
+ * Detach from the dispatch manager, and destroy it if no references
+ * remain.
*
* Requires:
*\li mgrp != NULL && *mgrp is a valid dispatchmgr.
*\li Anything else -- failure.
*/
-#define dns_dispatch_attach(d, dp) \
- dns__dispatch_attach(d, dp, __func__, __FILE__, __LINE__)
-
void
-dns__dispatch_attach(dns_dispatch_t *disp, dns_dispatch_t **dispp,
- const char *func, const char *file, unsigned int line);
+dns_dispatch_attach(dns_dispatch_t *disp, dns_dispatch_t **dispp);
/*%<
* Attach to a dispatch handle.
*
*\li dispp != NULL && *dispp == NULL
*/
-#define dns_dispatch_detach(dp) \
- dns__dispatch_detach(dp, __func__, __FILE__, __LINE__)
-
void
-dns__dispatch_detach(dns_dispatch_t **dispp, const char *func, const char *file,
- unsigned int line);
+dns_dispatch_detach(dns_dispatch_t **dispp);
/*%<
* Detaches from the dispatch.
*
*\li 'requestmgr' is a valid requestmgr.
*/
-#define dns_requestmgr_attach(source, targetp) \
- dns__requestmgr_attach(source, targetp, __FILE__, __LINE__, __func__)
-
void
-dns__requestmgr_attach(dns_requestmgr_t *source, dns_requestmgr_t **targetp,
- const char *file, unsigned int line, const char *func);
+dns_requestmgr_attach(dns_requestmgr_t *source, dns_requestmgr_t **targetp);
/*%<
* Attach to the request manager. dns_requestmgr_shutdown() must not
* have been called on 'source' prior to calling dns_requestmgr_attach().
*\li 'targetp' to be non NULL and '*targetp' to be NULL.
*/
-#define dns_requestmgr_detach(requestmgrp) \
- dns__requestmgr_detach(requestmgrp, __FILE__, __LINE__, __func__)
-
void
-dns__requestmgr_detach(dns_requestmgr_t **requestmgrp, const char *file,
- unsigned int line, const char *func);
+dns_requestmgr_detach(dns_requestmgr_t **requestmgrp);
/*%<
* Detach from the given requestmgr. If this is the final detach
* requestmgr will be destroyed. dns_requestmgr_shutdown() must
#include <dns/result.h>
#include <dns/tsig.h>
-#define REQ_TRACE
-
#define REQUESTMGR_MAGIC ISC_MAGIC('R', 'q', 'u', 'M')
#define VALID_REQUESTMGR(mgr) ISC_MAGIC_VALID(mgr, REQUESTMGR_MAGIC)
static void
req_timeout(isc_nmhandle_t *handle, isc_result_t eresult, void *arg);
static void
-__req_attach(dns_request_t *source, dns_request_t **targetp, const char *file,
- unsigned int line, const char *func);
+req_attach(dns_request_t *source, dns_request_t **targetp);
static void
-__req_detach(dns_request_t **requestp, const char *file, unsigned int line,
- const char *func);
+req_detach(dns_request_t **requestp);
static void
req_destroy(dns_request_t *request);
static void
void
request_cancel(dns_request_t *request);
-#define req_attach(source, targetp) \
- __req_attach(source, targetp, __FILE__, __LINE__, __func__)
-#define req_detach(requestp) \
- __req_detach(requestp, __FILE__, __LINE__, __func__)
-
/***
*** Public
***/
}
void
-dns__requestmgr_attach(dns_requestmgr_t *source, dns_requestmgr_t **targetp,
- const char *file, unsigned int line, const char *func) {
+dns_requestmgr_attach(dns_requestmgr_t *source, dns_requestmgr_t **targetp) {
uint_fast32_t ref;
REQUIRE(VALID_REQUESTMGR(source));
ref = isc_refcount_increment(&source->references);
-#ifdef REQ_TRACE
- fprintf(stderr, "%s:%s:%u:%s(%p, %p) = %" PRIuFAST32 "\n", func, file,
- line, __func__, source, targetp, ref + 1);
-#else
- UNUSED(func);
- UNUSED(file);
- UNUSED(line);
- UNUSED(ref);
-#endif /* REQ_TRACE */
-
req_log(ISC_LOG_DEBUG(3),
"dns_requestmgr_attach: %p: references = %" PRIuFAST32, source,
ref + 1);
}
void
-dns__requestmgr_detach(dns_requestmgr_t **requestmgrp, const char *file,
- unsigned int line, const char *func) {
+dns_requestmgr_detach(dns_requestmgr_t **requestmgrp) {
dns_requestmgr_t *requestmgr = NULL;
uint_fast32_t ref;
ref = isc_refcount_decrement(&requestmgr->references);
-#ifdef REQ_TRACE
- fprintf(stderr, "%s:%s:%u:%s(%p, %p) = %" PRIuFAST32 "\n", func, file,
- line, __func__, requestmgr, requestmgrp, ref - 1);
-#else
- UNUSED(func);
- UNUSED(file);
- UNUSED(line);
- UNUSED(ref);
-#endif /* REQ_TRACE */
-
req_log(ISC_LOG_DEBUG(3),
"dns_requestmgr_detach: %p: references = %" PRIuFAST32,
requestmgr, ref - 1);
}
static void
-__req_attach(dns_request_t *source, dns_request_t **targetp, const char *file,
- unsigned int line, const char *func) {
- uint_fast32_t ref;
-
+req_attach(dns_request_t *source, dns_request_t **targetp) {
REQUIRE(VALID_REQUEST(source));
REQUIRE(targetp != NULL && *targetp == NULL);
- ref = isc_refcount_increment(&source->references);
-
-#ifdef REQ_TRACE
- fprintf(stderr, "%s:%s:%u:%s(%p, %p) = %" PRIuFAST32 "\n", func, file,
- line, __func__, source, targetp, ref + 1);
-#else
- UNUSED(func);
- UNUSED(file);
- UNUSED(line);
- UNUSED(ref);
-#endif /* REQ_TRACE */
+ isc_refcount_increment(&source->references);
*targetp = source;
}
static void
-__req_detach(dns_request_t **requestp, const char *file, unsigned int line,
- const char *func) {
+req_detach(dns_request_t **requestp) {
dns_request_t *request = NULL;
uint_fast32_t ref;
ref = isc_refcount_decrement(&request->references);
-#ifdef REQ_TRACE
- fprintf(stderr, "%s:%s:%u:%s(%p, %p) = %" PRIuFAST32 "\n", func, file,
- line, __func__, request, requestp, ref - 1);
-#else
- UNUSED(func);
- UNUSED(file);
- UNUSED(line);
- UNUSED(ref);
-#endif /* REQ_TRACE */
-
if (request->requestmgr != NULL &&
atomic_load_acquire(&request->requestmgr->exiting))
{
#include <dns/tsig.h>
#include <dns/validator.h>
-#define RESOLVER_TRACE 1
-
-#define WANT_QUERYTRACE 1
-
#ifdef WANT_QUERYTRACE
#define RTRACE(m) \
isc_log_write(dns_lctx, DNS_LOGCATEGORY_RESOLVER, \
}
}
-#define resquery_attach(s, t) \
- __resquery_attach(s, t, __FILE__, __LINE__, __func__)
-
-static void __attribute__((unused))
-__resquery_attach(resquery_t *source, resquery_t **targetp, const char *file,
- unsigned int line, const char *func) {
- uint_fast32_t ref;
-
+static void
+resquery_attach(resquery_t *source, resquery_t **targetp) {
REQUIRE(VALID_QUERY(source));
REQUIRE(targetp != NULL && *targetp == NULL);
- ref = isc_refcount_increment(&source->references);
-
-#ifdef RESOLVER_TRACE
- fprintf(stderr, "%s:%s:%u:%s(%p, %p) = %" PRIuFAST32 "\n", func, file,
- line, __func__, source, targetp, ref + 1);
-#else
- UNUSED(func);
- UNUSED(file);
- UNUSED(line);
- UNUSED(ref);
-#endif /* RESOLVER_TRACE */
+ isc_refcount_increment(&source->references);
*targetp = source;
}
-#define resquery_detach(q) __resquery_detach(q, __FILE__, __LINE__, __func__)
-
static void
-__resquery_detach(resquery_t **queryp, const char *file, unsigned int line,
- const char *func) {
+resquery_detach(resquery_t **queryp) {
uint_fast32_t ref;
resquery_t *query = NULL;
*queryp = NULL;
ref = isc_refcount_decrement(&query->references);
-
-#ifdef RESOLVER_TRACE
- fprintf(stderr, "%s:%s:%u:%s(%p, %p) = %" PRIuFAST32 "\n", func, file,
- line, __func__, query, queryp, ref - 1);
-#else
- UNUSED(func);
- UNUSED(file);
- UNUSED(line);
-#endif /* RESOLVER_TRACE */
-
if (ref == 1) {
resquery_destroy(query);
}
}
}
-#define fctx_cancelquery(q, d, f, n, a) \
- __fctx_cancelquery(q, d, f, n, a, __FILE__, __LINE__, __func__)
-
static void
-__fctx_cancelquery(resquery_t *query, dns_dispatchevent_t **deventp,
- isc_time_t *finish, bool no_response, bool age_untried,
- const char *file, unsigned int line, const char *func) {
+fctx_cancelquery(resquery_t *query, dns_dispatchevent_t **deventp,
+ isc_time_t *finish, bool no_response, bool age_untried) {
fetchctx_t *fctx = NULL;
unsigned int rtt, rttms;
unsigned int factor;
fctx = query->fctx;
-#ifdef RESOLVER_TRACE
- fprintf(stderr, "%s:%s:%u:%s(query = %p, ...)\n", func, file, line,
- __func__, query);
-#else
- UNUSED(func);
- UNUSED(file);
- UNUSED(line);
-#endif /* RESOLVER_TRACE */
-
FCTXTRACE("cancelquery");
if (RESQUERY_CANCELED(query)) {