dig_lookup_t *default_lookup = NULL;
-static char *batchname = NULL;
+static atomic_uintptr_t batchname = ATOMIC_VAR_INIT(0);
static FILE *batchfp = NULL;
static char *argv0;
static int addresscount = 0;
value);
return (value_from_next);
case 'f':
- batchname = value;
+ atomic_store(&batchname, (uintptr_t)value);
return (value_from_next);
case 'k':
strlcpy(keyfile, value, sizeof(keyfile));
* first entry, then trust the callback in dighost_shutdown
* to get the rest
*/
- if ((batchname != NULL) && !(is_batchfile)) {
- if (strcmp(batchname, "-") == 0)
+ char *filename = (char *)atomic_load(&batchname);
+ if ((filename != NULL) && !(is_batchfile)) {
+ if (strcmp(filename, "-") == 0) {
batchfp = stdin;
- else
- batchfp = fopen(batchname, "r");
+ } else {
+ batchfp = fopen(filename, "r");
+ }
if (batchfp == NULL) {
- perror(batchname);
+ perror(filename);
if (exitcode < 8)
exitcode = 8;
fatal("couldn't open specified batch file");
int bargc;
char *bargv[16];
- if (batchname == NULL) {
+ if (atomic_load(&batchname) == 0) {
isc_app_shutdown();
return;
}
fflush(stdout);
if (feof(batchfp)) {
- batchname = NULL;
+ atomic_store(&batchname, 0);
isc_app_shutdown();
if (batchfp != stdin)
fclose(batchfp);
parse_args(true, false, bargc, (char **)bargv);
start_lookup();
} else {
- batchname = NULL;
+ atomic_store(&batchname, 0);
if (batchfp != stdin)
fclose(batchfp);
isc_app_shutdown();
void
dig_shutdown() {
destroy_lookup(default_lookup);
- if (batchname != NULL) {
- if (batchfp != stdin)
+ if (atomic_load(&batchname) != 0) {
+ if (batchfp != stdin) {
fclose(batchfp);
- batchname = NULL;
+ }
+ atomic_store(&batchname, 0);
}
cancel_all();
destroy_libs();