updates.
authorPekka Riikonen <priikone@silcnet.org>
Fri, 29 Mar 2002 08:45:36 +0000 (08:45 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 29 Mar 2002 08:45:36 +0000 (08:45 +0000)
apps/silcd/server.c
apps/silcd/serverconfig.c
apps/silcd/serverconfig.h

index 579d85ba091b123fe430778e82d2533d5b4eb6ba..c00c3ea94495435f9d70e17a5745a6e706bbba80 100644 (file)
@@ -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;
index 0d217e7c3e39f7c22d9feaf46d94a4b56d887492..0b31048af5093fcc86a32b7cb33f9196555426de 100644 (file)
@@ -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);
index a842576b92c736966b4c83e28a3628176c49dc33..cd5e2201be09a62a512316dd2cb2b0c8a7f22d1c 100644 (file)
@@ -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;