cfg_obj_asstring(obj));
}
- dns_dt_attach(named_g_server->dtenv, &view->dtenv);
+ dns_dtenv_attach(named_g_server->dtenv, &view->dtenv);
view->dttypes = dttypes;
result = ISC_R_SUCCESS;
#ifdef HAVE_DNSTAP
if (server->dtenv != NULL) {
- dns_dt_detach(&server->dtenv);
+ dns_dtenv_detach(&server->dtenv);
}
#endif /* HAVE_DNSTAP */
struct dns_dtenv {
unsigned int magic;
- isc_refcount_t refcount;
+ isc_refcount_t references;
isc_mem_t *mctx;
isc_loop_t *loop;
struct fstrm_iothr_queue *ioq;
} dt__ioq_t;
+static void
+destroy(dns_dtenv_t *env);
+
static thread_local dt__ioq_t dt_ioq = { 0 };
static atomic_uint_fast32_t global_generation;
+#if DNS_DTENV_TRACE
+ISC_REFCOUNT_TRACE_IMPL(dns_dtenv, destroy);
+#else
+ISC_REFCOUNT_IMPL(dns_dtenv, destroy);
+#endif /* DNS_DTENV_TRACE */
+
isc_result_t
dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
struct fstrm_iothr_options **foptp, isc_loop_t *loop,
isc_mem_attach(mctx, &env->mctx);
isc_mutex_init(&env->reopen_lock);
env->path = isc_mem_strdup(env->mctx, path);
- isc_refcount_init(&env->refcount, 1);
+ isc_refcount_init(&env->references, 1);
isc_stats_create(env->mctx, &env->stats, dns_dnstapcounter_max);
fwopt = fstrm_writer_options_init();
return dt_ioq.ioq;
}
-void
-dns_dt_attach(dns_dtenv_t *source, dns_dtenv_t **destp) {
- REQUIRE(VALID_DTENV(source));
- REQUIRE(destp != NULL && *destp == NULL);
-
- isc_refcount_increment(&source->refcount);
- *destp = source;
-}
-
isc_result_t
dns_dt_getstats(dns_dtenv_t *env, isc_stats_t **statsp) {
REQUIRE(VALID_DTENV(env));
isc_mem_putanddetach(&env->mctx, env, sizeof(*env));
}
-void
-dns_dt_detach(dns_dtenv_t **envp) {
- REQUIRE(envp != NULL && VALID_DTENV(*envp));
- dns_dtenv_t *env = *envp;
- *envp = NULL;
-
- if (isc_refcount_decrement(&env->refcount) == 1) {
- isc_refcount_destroy(&env->refcount);
- destroy(env);
- }
-}
-
static isc_result_t
pack_dt(const Dnstap__Dnstap *d, void **buf, size_t *sz) {
ProtobufCBufferSimple sbuf;
};
#endif /* HAVE_DNSTAP */
+#if DNS_DTENV_TRACE
+#define dns_dtenv_ref(ptr) dns_dtenv__ref(ptr, __func__, __FILE__, __LINE__)
+#define dns_dtenv_unref(ptr) dns_dtenv__unref(ptr, __func__, __FILE__, __LINE__)
+#define dns_dtenv_attach(ptr, ptrp) \
+ dns_dtenv__attach(ptr, ptrp, __func__, __FILE__, __LINE__)
+#define dns_dtenv_detach(ptrp) \
+ dns_dtenv__detach(ptrp, __func__, __FILE__, __LINE__)
+ISC_REFCOUNT_TRACE_DECL(dns_dtenv);
+#else
+ISC_REFCOUNT_DECL(dns_dtenv);
+#endif /* DNS_DTENV_TRACE */
+/*%
+ * Reference counting for dns_dtenv
+ */
+
isc_result_t
dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
struct fstrm_iothr_options **foptp, isc_loop_t *loop,
*\li 'env' is a valid dnstap environment.
*/
-void
-dns_dt_attach(dns_dtenv_t *source, dns_dtenv_t **destp);
-/*%<
- * Attach '*destp' to 'source', incrementing the reference counter.
- *
- * Requires:
- *
- *\li 'source' is a valid dnstap environment.
- *
- *\li 'destp' is not NULL and '*destp' is NULL.
- *
- *\li *destp is attached to source.
- */
-
-void
-dns_dt_detach(dns_dtenv_t **envp);
-/*%<
- * Detach '*envp', decrementing the reference counter.
- *
- * Requires:
- *
- *\li '*envp' is a valid dnstap environment.
- *
- * Ensures:
- *
- *\li '*envp' will be destroyed when the number of references reaches zero.
- *
- *\li '*envp' is NULL.
- */
-
isc_result_t
dns_dt_getstats(dns_dtenv_t *env, isc_stats_t **statsp);
/*%<
}
#ifdef HAVE_DNSTAP
if (view->dtenv != NULL) {
- dns_dt_detach(&view->dtenv);
+ dns_dtenv_detach(&view->dtenv);
}
#endif /* HAVE_DNSTAP */
if (view->newzone.cleanup != NULL) {
NULL, &dtenv);
assert_int_equal(result, ISC_R_SUCCESS);
if (dtenv != NULL) {
- dns_dt_detach(&dtenv);
+ dns_dtenv_detach(&dtenv);
}
if (fopt != NULL) {
fstrm_iothr_options_destroy(&fopt);
NULL, &dtenv);
assert_int_equal(result, ISC_R_SUCCESS);
if (dtenv != NULL) {
- dns_dt_detach(&dtenv);
+ dns_dtenv_detach(&dtenv);
}
if (fopt != NULL) {
fstrm_iothr_options_destroy(&fopt);
assert_int_equal(result, ISC_R_FAILURE);
assert_null(dtenv);
if (dtenv != NULL) {
- dns_dt_detach(&dtenv);
+ dns_dtenv_detach(&dtenv);
}
if (fopt != NULL) {
fstrm_iothr_options_destroy(&fopt);
NULL, &dtenv);
assert_int_equal(result, ISC_R_SUCCESS);
- dns_dt_attach(dtenv, &view->dtenv);
+ dns_dtenv_attach(dtenv, &view->dtenv);
view->dttypes = DNS_DTTYPE_ALL;
/*
m);
}
- dns_dt_detach(&view->dtenv);
- dns_dt_detach(&dtenv);
+ dns_dtenv_detach(&view->dtenv);
+ dns_dtenv_detach(&dtenv);
dns_view_detach(&view);
result = dns_dt_open(TAPFILE, dns_dtmode_file, isc_g_mctx, &handle);