]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
reset taskmgr mode immediately after returning from zone load
authorEvan Hunt <each@isc.org>
Sat, 8 May 2021 19:01:45 +0000 (12:01 -0700)
committerEvan Hunt <each@isc.org>
Mon, 10 May 2021 19:26:27 +0000 (12:26 -0700)
all privileged tasks are complete by the time we return from
isc_task_endexclusive(), so it makes sense to reset the taskmgr
mode to non-privileged right then.

bin/named/server.c

index d411647c443776a628a4ea3ab73da6d6414b07ef..f8d65e3b327298475cce4e400b48e9863355c47e 100644 (file)
@@ -9845,12 +9845,6 @@ view_loaded(void *arg) {
                                      "all zones loaded");
                }
 
-               /*
-                * Clear taskmgr privileged mode now that zones are loaded.
-                */
-               isc_taskmgr_setmode(dns_zonemgr_gettaskmgr(server->zonemgr),
-                                   isc_taskmgrmode_normal);
-
                CHECKFATAL(dns_zonemgr_forcemaint(server->zonemgr),
                           "forcing zone maintenance");
 
@@ -9875,8 +9869,9 @@ view_loaded(void *arg) {
 static isc_result_t
 load_zones(named_server_t *server, bool init, bool reconfig) {
        isc_result_t result;
-       dns_view_t *view;
-       ns_zoneload_t *zl;
+       isc_taskmgr_t *taskmgr = dns_zonemgr_gettaskmgr(server->zonemgr);
+       ns_zoneload_t *zl = NULL;
+       dns_view_t *view = NULL;
 
        zl = isc_mem_get(server->mctx, sizeof(*zl));
        zl->server = server;
@@ -9930,20 +9925,26 @@ cleanup:
                isc_mem_put(server->mctx, zl, sizeof(*zl));
        }
 
-       /*
-        * If we're setting up the server for the first time,
-        * set the task manager into privileged mode; this ensures
-        * that no other tasks will begin to run until after
-        * zone loading is complete.
-        *
-        * We do *not* want to do this in the case of reload or
-        * reconfig, as loading a large zone could cause the server
-        * to be inactive for too long a time.
-        */
-       isc_taskmgr_setmode(named_g_taskmgr, init ? isc_taskmgrmode_privileged
-                                                 : isc_taskmgrmode_normal);
+       if (init) {
+               /*
+                * If we're setting up the server for the first time, set
+                * the task manager into privileged mode; this ensures
+                * that no other tasks will begin to run until after zone
+                * loading is complete. We won't return from exclusive mode
+                * until the loading is finished; we can then drop out of
+                * privileged mode.
+                *
+                * We do *not* want to do this in the case of reload or
+                * reconfig, as loading a large zone could cause the server
+                * to be inactive for too long a time.
+                */
+               isc_taskmgr_setmode(taskmgr, isc_taskmgrmode_privileged);
+               isc_task_endexclusive(server->task);
+               isc_taskmgr_setmode(taskmgr, isc_taskmgrmode_normal);
+       } else {
+               isc_task_endexclusive(server->task);
+       }
 
-       isc_task_endexclusive(server->task);
        return (result);
 }