#include <unistd.h>
#include <isc/app.h>
+#include <isc/atomic.h>
#include <isc/base32.h>
#include <isc/commandline.h>
#include <isc/event.h>
#include <isc/print.h>
#include <isc/random.h>
#include <isc/rwlock.h>
-#include <isc/serial.h>
#include <isc/safe.h>
+#include <isc/serial.h>
#include <isc/stdio.h>
#include <isc/string.h>
#include <isc/task.h>
static size_t salt_length = 0;
static isc_task_t *master = NULL;
static unsigned int ntasks = 0;
-static bool shuttingdown = false, finished = false;
+static atomic_bool shuttingdown = ATOMIC_VAR_INIT(false);
+static atomic_bool finished = ATOMIC_VAR_INIT(false);
static bool nokeys = false;
static bool removefile = false;
static bool generateds = false;
cleannode(gdb, gversion, node);
dns_db_detachnode(gdb, &node);
result = dns_dbiterator_first(gdbiter);
- if (result == ISC_R_NOMORE)
- finished = true;
- else if (result != ISC_R_SUCCESS)
+ if (result == ISC_R_NOMORE) {
+ atomic_store(&finished, true);
+ } else if (result != ISC_R_SUCCESS) {
fatal("failure iterating database: %s",
isc_result_totext(result));
+ }
}
/*%
static dns_fixedname_t fzonecut; /* Protected by namelock. */
static unsigned int ended = 0; /* Protected by namelock. */
- if (shuttingdown)
+ if (atomic_load(&shuttingdown)) {
return;
+ }
LOCK(&namelock);
- if (finished) {
+ if (atomic_load(&finished)) {
ended++;
if (ended == ntasks) {
isc_task_detach(&task);
next:
result = dns_dbiterator_next(gdbiter);
if (result == ISC_R_NOMORE) {
- finished = true;
+ atomic_store(&finished, true);
break;
} else if (result != ISC_R_SUCCESS)
fatal("failure iterating database: %s",
presign();
TIME_NOW(&sign_start);
signapex();
- if (!finished) {
+ if (!atomic_load(&finished)) {
/*
* There is more work to do. Spread it out over multiple
* processors if possible.
isc_result_totext(result));
}
(void)isc_app_run();
- if (!finished)
+ if (!atomic_load(&finished)) {
fatal("process aborted by user");
+ }
} else
isc_task_detach(&master);
- shuttingdown = true;
+ atomic_store(&shuttingdown, true);;
for (i = 0; i < (int)ntasks; i++)
isc_task_detach(&tasks[i]);
isc_taskmgr_destroy(&taskmgr);