From b6320643194a3b435f2a6ae4569ace19db6ac795 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
Date: Fri, 11 Feb 2022 14:19:10 +0100
Subject: [PATCH] Propagate extra hp threads to dyndb plugins
Plugin may require extra threads for processing its own source data. If
that plugin needs to call isc_task_send() from those threads, it needs
extra hp threads initialized. Allow plugin to read how many such threads
it can use. Allows plugin to fail initialization if not enough workers
were initialized.
---
bin/named/server.c | 9 +++++----
lib/dns/dyndb.c | 4 +++-
lib/dns/include/dns/dyndb.h | 22 +++++++++++++---------
3 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/bin/named/server.c b/bin/named/server.c
index 721464db8e..27e23fd52e 100644
--- a/bin/named/server.c
+++ b/bin/named/server.c
@@ -5581,10 +5581,11 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
if (dctx == NULL) {
const void *hashinit = isc_hash_get_initializer();
- CHECK(dns_dyndb_createctx(mctx, hashinit, named_g_lctx,
- view, named_g_server->zonemgr,
- named_g_server->task,
- named_g_timermgr, &dctx));
+ CHECK(dns_dyndb_createctx(
+ mctx, hashinit, named_g_lctx, view,
+ named_g_server->zonemgr, named_g_server->task,
+ named_g_timermgr, named_g_hp_extra_workers,
+ &dctx));
}
CHECK(configure_dyndb(dyndb, mctx, dctx));
diff --git a/lib/dns/dyndb.c b/lib/dns/dyndb.c
index 1caf90bab7..7d2784c5fa 100644
--- a/lib/dns/dyndb.c
+++ b/lib/dns/dyndb.c
@@ -408,7 +408,8 @@ dns_dyndb_cleanup(bool exiting) {
isc_result_t
dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, isc_log_t *lctx,
dns_view_t *view, dns_zonemgr_t *zmgr, isc_task_t *task,
- isc_timermgr_t *tmgr, dns_dyndbctx_t **dctxp) {
+ isc_timermgr_t *tmgr, unsigned int extra_workers,
+ dns_dyndbctx_t **dctxp) {
dns_dyndbctx_t *dctx;
REQUIRE(dctxp != NULL && *dctxp == NULL);
@@ -429,6 +430,7 @@ dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, isc_log_t *lctx,
dctx->hashinit = hashinit;
dctx->lctx = lctx;
dctx->memdebug = &isc_mem_debugging;
+ dctx->extra_workers = extra_workers;
isc_mem_attach(mctx, &dctx->mctx);
dctx->magic = DNS_DYNDBCTX_MAGIC;
diff --git a/lib/dns/include/dns/dyndb.h b/lib/dns/include/dns/dyndb.h
index bda744a8d9..a93947d340 100644
--- a/lib/dns/include/dns/dyndb.h
+++ b/lib/dns/include/dns/dyndb.h
@@ -35,14 +35,15 @@ ISC_LANG_BEGINDECLS
*/
struct dns_dyndbctx {
unsigned int magic;
- const void *hashinit;
- isc_mem_t *mctx;
- isc_log_t *lctx;
- dns_view_t *view;
- dns_zonemgr_t *zmgr;
- isc_task_t *task;
+ const void * hashinit;
+ isc_mem_t * mctx;
+ isc_log_t * lctx;
+ dns_view_t * view;
+ dns_zonemgr_t * zmgr;
+ isc_task_t * task;
isc_timermgr_t *timermgr;
- unsigned int *memdebug;
+ unsigned int * memdebug;
+ unsigned int extra_workers;
};
#define DNS_DYNDBCTX_MAGIC ISC_MAGIC('D', 'd', 'b', 'c')
@@ -58,7 +59,7 @@ struct dns_dyndbctx {
*/
#ifndef DNS_DYNDB_VERSION
#define DNS_DYNDB_VERSION 1
-#define DNS_DYNDB_AGE 0
+#define DNS_DYNDB_AGE 1
#endif /* ifndef DNS_DYNDB_VERSION */
typedef isc_result_t
@@ -135,7 +136,8 @@ dns_dyndb_cleanup(bool exiting);
isc_result_t
dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, isc_log_t *lctx,
dns_view_t *view, dns_zonemgr_t *zmgr, isc_task_t *task,
- isc_timermgr_t *tmgr, dns_dyndbctx_t **dctxp);
+ isc_timermgr_t *tmgr, unsigned int extra_workers,
+ dns_dyndbctx_t **dctxp);
/*%
* Create a dyndb initialization context structure, with
* pointers to structures in the server that the dyndb module will
@@ -143,6 +145,8 @@ dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, isc_log_t *lctx,
* etc). This structure is expected to last only until all dyndb
* modules have been loaded and initialized; after that it will be
* destroyed with dns_dyndb_destroyctx().
+ * extra workers specifies how many extra worker threads can plugin
+ * use to send tasks to named threads by isc_task_send()
*
* Returns:
*\li #ISC_R_SUCCESS
--
2.34.1