mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
use a thread-local variable to get the current running loop
if we had a method to get the running loop, similar to how isc_tid() gets the current thread ID, we can simplify loop and loopmgr initialization. remove most uses of isc_loop_current() in favor of isc_loop(). in some places where that was the only reason to pass loopmgr, remove loopmgr from the function parameters.
This commit is contained in:
@@ -46,6 +46,8 @@
|
||||
* Private
|
||||
*/
|
||||
|
||||
thread_local isc_loop_t *isc__loop_local = NULL;
|
||||
|
||||
static void
|
||||
ignore_signal(int sig, void (*handler)(int)) {
|
||||
struct sigaction sa = { .sa_handler = handler };
|
||||
@@ -263,8 +265,10 @@ loop_close(isc_loop_t *loop) {
|
||||
static void *
|
||||
loop_thread(void *arg) {
|
||||
isc_loop_t *loop = (isc_loop_t *)arg;
|
||||
/* Initialize the thread_local variables*/
|
||||
|
||||
/* Initialize the thread_local variable */
|
||||
REQUIRE(isc__loop_local == NULL || isc__loop_local == loop);
|
||||
isc__loop_local = loop;
|
||||
|
||||
isc__tid_init(loop->tid);
|
||||
|
||||
@@ -284,6 +288,8 @@ loop_thread(void *arg) {
|
||||
r = uv_run(&loop->loop, UV_RUN_DEFAULT);
|
||||
UV_RUNTIME_CHECK(uv_run, r);
|
||||
|
||||
isc__loop_local = NULL;
|
||||
|
||||
/* Invalidate the loop early */
|
||||
loop->magic = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user