From: Pekka Riikonen Date: Fri, 29 Mar 2002 08:45:36 +0000 (+0000) Subject: updates. X-Git-Tag: silc.client.0.8.6~4^2~61 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=c2617920b4fe8b5745d2399129105fdc59dc615c updates. --- diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 579d85ba..c00c3ea9 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -381,11 +381,7 @@ bool silc_server_rehash(SilcServer server) silc_server_config_ref(&server->config_ref, server->config, server->config); /* Fix the server_name field */ - if (!strcmp(server->server_name, newconfig->server_info->server_name)) { - /* We don't need any update */ - silc_free(newconfig->server_info->server_name); - newconfig->server_info->server_name = NULL; - } else { + if (strcmp(server->server_name, newconfig->server_info->server_name)) { silc_free(server->server_name); server->server_name = newconfig->server_info->server_name; newconfig->server_info->server_name = NULL; diff --git a/apps/silcd/serverconfig.c b/apps/silcd/serverconfig.c index 0d217e7c..0b31048a 100644 --- a/apps/silcd/serverconfig.c +++ b/apps/silcd/serverconfig.c @@ -1269,6 +1269,7 @@ SilcServerConfig silc_server_config_alloc(const char *filename) /* Set default to configuration parameters */ silc_server_config_set_defaults(config_new); + config_new->refcount = 1; return config_new; } @@ -1291,16 +1292,8 @@ void silc_server_config_ref(SilcServerConfigRef *ref, SilcServerConfig config, void silc_server_config_unref(SilcServerConfigRef *ref) { - SilcServerConfig config = ref->config; - - if (ref->ref_ptr) { - config->refcount--; - SILC_LOG_DEBUG(("Unreferencing config [%p] refcnt %hu->%hu", config, - config->refcount + 1, config->refcount)); - if (!config->refcount) - silc_server_config_destroy(config); - ref->ref_ptr = NULL; - } + if (ref->ref_ptr) + silc_server_config_destroy(ref->config); } /* Destroy a config object with all his children lists */ @@ -1309,6 +1302,12 @@ void silc_server_config_destroy(SilcServerConfig config) { void *tmp; + config->refcount--; + SILC_LOG_DEBUG(("Unreferencing config [%p] refcnt %hu->%hu", config, + config->refcount + 1, config->refcount)); + if (config->refcount > 0) + return; + SILC_LOG_DEBUG(("Freeing config context")); silc_free(config->module_path); diff --git a/apps/silcd/serverconfig.h b/apps/silcd/serverconfig.h index a842576b..cd5e2201 100644 --- a/apps/silcd/serverconfig.h +++ b/apps/silcd/serverconfig.h @@ -150,7 +150,7 @@ typedef struct { void *tmp; /* Reference count (when this reaches zero, config object is destroyed) */ - SilcInt16 refcount; + SilcInt32 refcount; /* The General section */ char *module_path;