void dare_server_shutdown() { dare_ib_srv_shutdown(); free_server_data(); fclose(log_fp); exit(1); }
int dare_server_init(dare_server_input_t *input) { int rc; /* Initialize data fields to zero */ memset(&data, 0, sizeof(dare_server_data_t)); /* Store input into server's data structure */ data.input = input; data.cur_view = input->cur_view; data.my_address = input->my_address; /* Set log file handler */ log_fp = input->log; /* Init server data */ rc = init_server_data(); if (0 != rc) { free_server_data(); fprintf(stderr, "Cannot init server data\n"); return 1; } init_network_cb(); poll_cb(); return 0; }
/* * Re-Read the configuration file. * Return 1 on success, 0 on failure. * In case of failure, the old configuration will be unchanged (although the cache may not) and * **errstr will refer to a newly allocated string containing an error message. */ int reload_config_file(const char *nm, char **errstr) { globparm_t global_new; servparm_array servers_new; global_new=global; global_new.cache_dir=NULL; global_new.pidfile=NULL; global_new.scheme_file=NULL; global_new.deleg_only_zones=NULL; global_new.onquery=0; servers_new=NULL; if(read_config_file(nm,&global_new,&servers_new,0,errstr)) { if(global_new.cache_dir && strcmp(global_new.cache_dir,global.cache_dir)) { *errstr=strdup("Cannot reload config file: the specified cache_dir directory has changed.\n" "Try restarting pdnsd instead."); goto cleanup_return; } if(global_new.pidfile && (!global.pidfile || strcmp(global_new.pidfile,global.pidfile))) { *errstr=strdup("Cannot reload config file: the specified pid_file has changed.\n" "Try restarting pdnsd instead."); goto cleanup_return; } if(global_new.scheme_file && strcmp(global_new.scheme_file,global.scheme_file)) { *errstr=strdup("Cannot reload config file: the specified scheme_file has changed.\n" "Try restarting pdnsd instead."); goto cleanup_return; } if(global_new.port!=global.port) { *errstr=strdup("Cannot reload config file: the specified server_port has changed.\n" "Try restarting pdnsd instead."); goto cleanup_return; } if(!ADDR_EQUIV(&global_new.a,&global.a)) { *errstr=strdup("Cannot reload config file: the specified interface address (server_ip) has changed.\n" "Try restarting pdnsd instead."); goto cleanup_return; } #ifdef ENABLE_IPV6 if(!IN6_ARE_ADDR_EQUAL(&global_new.ipv4_6_prefix,&global.ipv4_6_prefix)) { *errstr=strdup("Cannot reload config file: the specified ipv4_6_prefix has changed.\n" "Try restarting pdnsd instead."); goto cleanup_return; } #endif if(strcmp(global_new.run_as,global.run_as)) { *errstr=strdup("Cannot reload config file: the specified run_as id has changed.\n" "Try restarting pdnsd instead."); goto cleanup_return; } if(global_new.daemon!=global.daemon) { *errstr=strdup("Cannot reload config file: the daemon option has changed.\n" "Try restarting pdnsd instead."); goto cleanup_return; } if(global_new.debug!=global.debug) { *errstr=strdup("Cannot reload config file: the debug option has changed.\n" "Try restarting pdnsd instead."); goto cleanup_return; } if(global_new.stat_pipe!=global.stat_pipe) { *errstr=strdup("Cannot reload config file: the status_ctl option has changed.\n" "Try restarting pdnsd instead."); goto cleanup_return; } if(global_new.notcp!=global.notcp) { *errstr=strdup("Cannot reload config file: the tcp_server option has changed.\n" "Try restarting pdnsd instead."); goto cleanup_return; } if(global_new.strict_suid!=global.strict_suid) { *errstr=strdup("Cannot reload config file: the strict_setuid option has changed.\n" "Try restarting pdnsd instead."); goto cleanup_return; } if(global_new.ctl_perms!=global.ctl_perms) { *errstr=strdup("Cannot reload config file: the specified ctl_perms has changed.\n" "Try restarting pdnsd instead."); goto cleanup_return; } if(ping_isocket==-1 #ifdef ENABLE_IPV6 && ping6_isocket==-1 #endif ) { int i,n=DA_NEL(servers_new); for (i=0;i<n;++i) { if (DA_INDEX(servers_new,i).uptest==C_PING) { if(asprintf(errstr,"Cannot reload config file: the ping socket is not initialized" " and the new config contains uptest=ping in server section %i.\n" "Try restarting pdnsd instead.",i)<0) *errstr=NULL; goto cleanup_return; } } } /* we need exclusive access to the server data to make the changes */ /* Wait at most 60 seconds to obtain a lock. */ if(!exclusive_lock_server_data(60)) { *errstr=strdup("Cannot reload config file: Timed out while waiting for access to config data."); goto cleanup_return; } free(global_new.cache_dir); global_new.cache_dir=global.cache_dir; free(global_new.pidfile); global_new.pidfile=global.pidfile; free(global_new.scheme_file); global_new.scheme_file=global.scheme_file; free_zones(global.deleg_only_zones); global=global_new; free_server_data(servers); servers=servers_new; /* schedule a retest to check which servers are up, and free the lock. */ exclusive_unlock_server_data(1); return 1; } cleanup_return: free(global_new.cache_dir); free(global_new.pidfile); free(global_new.scheme_file); free_zones(global_new.deleg_only_zones); free_server_data(servers_new); return 0; }
int dare_rdma_shutdown() { dare_ib_srv_shutdown(); free_server_data(); return 0; }