From 631617d4ec84bfee7c8f08d80da88eb1bed890ed Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 21 Sep 2020 12:48:10 +1000 Subject: [PATCH] make controls->shuttingdown an atomic_bool --- bin/named/controlconf.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/named/controlconf.c b/bin/named/controlconf.c index 97b2c1efe7..93e1d82065 100644 --- a/bin/named/controlconf.c +++ b/bin/named/controlconf.c @@ -109,7 +109,7 @@ struct controllistener { struct named_controls { named_server_t *server; controllistenerlist_t listeners; - bool shuttingdown; + atomic_bool shuttingdown; isc_mutex_t symtab_lock; isccc_symtab_t *symtab; }; @@ -225,7 +225,9 @@ control_senddone(isc_nmhandle_t *handle, isc_result_t result, void *arg) { conn->sending = false; - if (listener->controls->shuttingdown || result == ISC_R_CANCELED) { + if (atomic_load_acquire(&listener->controls->shuttingdown) || + result == ISC_R_CANCELED) + { goto cleanup_sendhandle; } else if (result != ISC_R_SUCCESS) { char socktext[ISC_SOCKADDR_FORMATSIZE]; @@ -386,7 +388,7 @@ control_command(isc_task_t *task, isc_event_t *event) { UNUSED(task); - if (listener->controls->shuttingdown) { + if (atomic_load_acquire(&listener->controls->shuttingdown)) { conn_cleanup(conn); isc_nmhandle_detach(&conn->cmdhandle); goto done; @@ -413,13 +415,14 @@ control_recvmessage(isc_nmhandle_t *handle, isc_result_t result, void *arg) { conn->reading = false; /* Is the server shutting down? */ - if (listener->controls->shuttingdown) { + if (atomic_load_acquire(&listener->controls->shuttingdown)) { goto cleanup_readhandle; } if (result != ISC_R_SUCCESS) { if (result == ISC_R_CANCELED) { - listener->controls->shuttingdown = true; + atomic_store_release(&listener->controls->shuttingdown, + true); } else if (result != ISC_R_EOF) { log_invalid(&conn->ccmsg, result); } @@ -711,7 +714,7 @@ controls_shutdown(named_controls_t *controls) { void named_controls_shutdown(named_controls_t *controls) { controls_shutdown(controls); - controls->shuttingdown = true; + atomic_store_release(&controls->shuttingdown, true); } static isc_result_t