Commit b00ba7ac authored by Mark Andrews's avatar Mark Andrews

make (named_server_t).reload_status atomic

    WARNING: ThreadSanitizer: data race
    Write of size 4 at 0x000000000001 by thread T1:
    #0 view_loaded bin/named/server.c:9678:25
    #1 call_loaddone lib/dns/zt.c:308:3
    #2 doneloading lib/dns/zt.c:582:3
    #3 zone_asyncload lib/dns/zone.c:2322:3
    #4 dispatch lib/isc/task.c:1152:7
    #5 run lib/isc/task.c:1344:2

    Previous read of size 4 at 0x000000000001 by thread T2:
    #0 named_server_status bin/named/server.c:11903:14
    #1 named_control_docommand bin/named/control.c:272:12
    #2 control_command bin/named/controlconf.c:390:17
    #3 dispatch lib/isc/task.c:1152:7
    #4 run lib/isc/task.c:1344:2

    Location is heap block of size 409 at 0x000000000011 allocated by main thread:
    #0 malloc <null>
    #1 default_memalloc lib/isc/mem.c:713:8
    #2 mem_get lib/isc/mem.c:622:8
    #3 mem_allocateunlocked lib/isc/mem.c:1268:8
    #4 isc___mem_allocate lib/isc/mem.c:1288:7
    #5 isc__mem_allocate lib/isc/mem.c:2453:10
    #6 isc___mem_get lib/isc/mem.c:1037:11
    #7 isc__mem_get lib/isc/mem.c:2432:10
    #8 named_server_create bin/named/server.c:9978:27
    #9 setup bin/named/main.c:1256:2
    #10 main bin/named/main.c:1523:2

    Thread T1 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create lib/isc/pthreads/thread.c:73:8
    #2 isc_taskmgr_create lib/isc/task.c:1434:3
    #3 create_managers bin/named/main.c:915:11
    #4 setup bin/named/main.c:1223:11
    #5 main bin/named/main.c:1523:2

    Thread T2 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create lib/isc/pthreads/thread.c:73:8
    #2 isc_taskmgr_create lib/isc/task.c:1434:3
    #3 create_managers bin/named/main.c:915:11
    #4 setup bin/named/main.c:1223:11
    #5 main bin/named/main.c:1523:2

    SUMMARY: ThreadSanitizer: data race bin/named/server.c:9678:25 in view_loaded
parent 6e6ad6d3
......@@ -82,7 +82,7 @@ struct named_server {
uint32_t interface_interval;
uint32_t heartbeat_interval;
named_reload_t reload_status;
atomic_int reload_status;
bool flushonshutdown;
......
......@@ -9676,7 +9676,7 @@ view_loaded(void *arg) {
"FIPS mode is %s",
FIPS_mode() ? "enabled" : "disabled");
#endif /* ifdef HAVE_FIPS_MODE */
server->reload_status = NAMED_RELOAD_DONE;
atomic_store(&server->reload_status, NAMED_RELOAD_DONE);
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_NOTICE,
......@@ -10005,7 +10005,7 @@ named_server_create(isc_mem_t *mctx, named_server_t **serverp) {
&server->in_roothints),
"setting up root hints");
server->reload_status = NAMED_RELOAD_IN_PROGRESS;
atomic_store(&server->reload_status, NAMED_RELOAD_IN_PROGRESS);
/*
* Setup the server task, which is responsible for coordinating
......@@ -10318,7 +10318,7 @@ loadconfig(named_server_t *server) {
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
"reloading configuration failed: %s",
isc_result_totext(result));
server->reload_status = NAMED_RELOAD_FAILED;
atomic_store(&server->reload_status, NAMED_RELOAD_FAILED);
}
return (result);
......@@ -10327,7 +10327,9 @@ loadconfig(named_server_t *server) {
static isc_result_t
reload(named_server_t *server) {
isc_result_t result;
server->reload_status = NAMED_RELOAD_IN_PROGRESS;
atomic_store(&server->reload_status, NAMED_RELOAD_IN_PROGRESS);
CHECK(loadconfig(server));
result = load_zones(server, false, false);
......@@ -10340,7 +10342,7 @@ reload(named_server_t *server) {
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
"reloading zones failed: %s",
isc_result_totext(result));
server->reload_status = NAMED_RELOAD_FAILED;
atomic_store(&server->reload_status, NAMED_RELOAD_FAILED);
}
cleanup:
return (result);
......@@ -10686,7 +10688,7 @@ named_server_reloadcommand(named_server_t *server, isc_lex_t *lex,
isc_result_t
named_server_reconfigcommand(named_server_t *server) {
isc_result_t result;
server->reload_status = NAMED_RELOAD_IN_PROGRESS;
atomic_store(&server->reload_status, NAMED_RELOAD_IN_PROGRESS);
CHECK(loadconfig(server));
......@@ -10700,7 +10702,7 @@ named_server_reconfigcommand(named_server_t *server) {
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
"loading new zones failed: %s",
isc_result_totext(result));
server->reload_status = NAMED_RELOAD_FAILED;
atomic_store(&server->reload_status, NAMED_RELOAD_FAILED);
}
cleanup:
return (result);
......@@ -11808,6 +11810,7 @@ named_server_status(named_server_t *server, isc_buffer_t **text) {
char boottime[ISC_FORMATHTTPTIMESTAMP_SIZE];
char configtime[ISC_FORMATHTTPTIMESTAMP_SIZE];
char line[1024], hostname[256];
named_reload_t reload_status;
if (named_g_server->version_set) {
ob = " (";
......@@ -11910,9 +11913,10 @@ named_server_status(named_server_t *server, isc_buffer_t **text) {
ns_statscounter_tcphighwater));
CHECK(putstr(text, line));
if (server->reload_status != NAMED_RELOAD_DONE) {
reload_status = atomic_load(&server->reload_status);
if (reload_status != NAMED_RELOAD_DONE) {
snprintf(line, sizeof(line), "reload/reconfig %s\n",
(server->reload_status == NAMED_RELOAD_FAILED
(reload_status == NAMED_RELOAD_FAILED
? "failed"
: "in progress"));
CHECK(putstr(text, line));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment