-static void sigterm_handler(void *data) {
- logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum));
- event_exit();
-}
-
-static void sighup_handler(void *data) {
- logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum));
- reopenlogger();
- reload_configuration();
-}
-
-static void sigalrm_handler(void *data) {
- logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum));
- retry();
-}
-
-int reload_configuration(void) {
- char *fname;
-
- /* Reread our own configuration file */
-
- exit_configuration(&config_tree);
- init_configuration(&config_tree);
-
- if(!read_server_config()) {
- logger(DEBUG_ALWAYS, LOG_ERR, "Unable to reread configuration file, exitting.");
- event_exit();
- return EINVAL;
- }
-
- read_config_options(config_tree, NULL);
-
- xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, myself->name);
- read_config_file(config_tree, fname);
- free(fname);
-
- /* Parse some options that are allowed to be changed while tinc is running */
-
- setup_myself_reloadable();
-
- /* If StrictSubnet is set, expire deleted Subnets and read new ones in */
-
- if(strictsubnets) {
- for splay_each(subnet_t, subnet, subnet_tree)
- subnet->expires = 1;
-
- load_all_subnets();
-
- for splay_each(subnet_t, subnet, subnet_tree) {
- if(subnet->expires == 1) {
- send_del_subnet(everyone, subnet);
- if(subnet->owner->status.reachable)
- subnet_update(subnet->owner, subnet, false);
- subnet_del(subnet->owner, subnet);
- } else if(subnet->expires == -1) {
- subnet->expires = 0;
- } else {
- send_add_subnet(everyone, subnet);
- if(subnet->owner->status.reachable)
- subnet_update(subnet->owner, subnet, true);
- }
- }
- } else { /* Only read our own subnets back in */
- for splay_each(subnet_t, subnet, myself->subnet_tree)
- if(!subnet->expires)
- subnet->expires = 1;
-
- config_t *cfg = lookup_config(config_tree, "Subnet");
-
- while(cfg) {
- subnet_t *subnet, *s2;
-
- if(!get_config_subnet(cfg, &subnet))
- continue;
-
- if((s2 = lookup_subnet(myself, subnet))) {
- if(s2->expires == 1)
- s2->expires = 0;
-
- free_subnet(subnet);
- } else {
- subnet_add(myself, subnet);
- send_add_subnet(everyone, subnet);
- subnet_update(myself, subnet, true);
- }
-
- cfg = lookup_config_next(config_tree, cfg);
- }
-
- for splay_each(subnet_t, subnet, myself->subnet_tree) {
- if(subnet->expires == 1) {
- send_del_subnet(everyone, subnet);
- subnet_update(myself, subnet, false);
- subnet_del(myself, subnet);
- }
- }