updates.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 28 Mar 2002 17:12:43 +0000 (17:12 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 28 Mar 2002 17:12:43 +0000 (17:12 +0000)
CHANGES
apps/silcd/server.c
apps/silcd/serverconfig.c
apps/silcd/serverconfig.h
apps/silcd/silcd.c
lib/silcutil/silclog.c

diff --git a/CHANGES b/CHANGES
index a8b37f51ae8021e5fc1b78ba44146f7e247d6ebe..f1c3b550495b5ac705a61d17dd69dfcb0dd4291d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,14 @@
+Thu Mar 28 19:02:05 EET 2002  Pekka Riikonen <priikone@silcnet.org>
+
+       * Created new branch silc_protocol_1_0_branch.
+
+       * Reverted the silc_log_quick change in lib/silcutil/silclog.c.
+
+       * Changed the silc_server_config_* routines to be SilcServer
+         independent.  They are now officially application specific code
+         and not part of generic server implementation.  Affected files
+         are silcd/serverconfig.[ch], silcd/silcd.c, silcd/server.c.
+
 Thu Mar 28 17:01:43 EET 2002  Pekka Riikonen <priikone@silcnet.org>
 
        * Added automatic referencing of config context in the
index 1aab542f6aae01a239566ea5c6db16c7bd4a0174..b785c5188adf7c5604404157413ff22c80748527 100644 (file)
@@ -87,6 +87,7 @@ void silc_server_free(SilcServer server)
     silc_dlist_uninit(server->sim);
 #endif
 
+    silc_server_config_unref(&server->config_ref);
     if (server->rng)
       silc_rng_free(server->rng);
     if (server->pkcs)
@@ -149,6 +150,9 @@ bool silc_server_init(SilcServer server)
   assert(server);
   assert(server->config);
 
+  silc_server_config_ref(&server->config_ref, server->config, 
+                        server->config);
+
   /* Set public and private keys */
   if (!server->config->server_info ||
       !server->config->server_info->public_key ||
@@ -362,22 +366,27 @@ bool silc_server_rehash(SilcServer server)
 {
   SilcServerConfig newconfig;
 
+  /* Our old config is gone now. We'll unreference our reference made in
+     silc_server_init and then destroy it since we are destroying it 
+     underneath the application (layer which called silc_server_init). */
+  silc_server_config_unref(&server->config_ref);
+  silc_server_config_destroy(server->config);
+
   /* Reset the logging system */
   silc_log_quick = TRUE;
   silc_log_flush_all();
 
   /* Start the main rehash phase (read again the config file) */
   SILC_LOG_INFO(("Rehashing server"));
-  newconfig = silc_server_config_alloc(server, server->config_file);
+  newconfig = silc_server_config_alloc(server->config_file);
   if (!newconfig) {
     SILC_LOG_ERROR(("Rehash FAILED."));
     return FALSE;
   }
 
-  /* Destroy old config context. This is destroyed if no one is referencing
-     it at the moment. */
-  silc_server_config_destroy(server->config);
+  /* Take new config context */
   server->config = newconfig;
+  silc_server_config_ref(&server->config_ref, server->config, server->config);
 
   /* Set public and private keys */
   if (!server->config->server_info ||
index eb743d834de81fe472f17e0f9dd1f3bfa01a8200..8a8aea500800cdd32d573cc359c3622f8df23617 100644 (file)
@@ -1195,11 +1195,11 @@ static void silc_server_config_set_defaults(SilcServerConfig config)
 }
 
 /* Allocates a new configuration object, opens configuration file and
- * parses it. The parsed data is returned to the newly allocated
- * configuration object. */
+   parses it. The parsed data is returned to the newly allocated
+   configuration object. The SilcServerConfig must be freed by calling
+   the silc_server_config_destroy function. */
 
-SilcServerConfig silc_server_config_alloc(SilcServer server,
-                                         const char *filename)
+SilcServerConfig silc_server_config_alloc(const char *filename)
 {
   SilcServerConfig config_new;
   SilcConfigEntity ent;
@@ -1265,7 +1265,7 @@ SilcServerConfig silc_server_config_alloc(SilcServer server,
   /* Set default to configuration parameters */
   silc_server_config_set_defaults(config_new);
 
-  silc_server_config_ref(&server->config_ref, config_new, config_new);
+  config_new->refcount = 1;
   return config_new;
 }
 
@@ -1288,14 +1288,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);
-  }
+  if (ref->ref_ptr)
+    silc_server_config_destroy(ref->config);
 }
 
 /* Destroy a config object with all his children lists */
@@ -1304,13 +1298,11 @@ void silc_server_config_destroy(SilcServerConfig config)
 {
   void *tmp;
 
-  if (config->refcount > 0) {
-    config->refcount--;
-    SILC_LOG_DEBUG(("Unreferencing config [%p] refcnt %hu->%hu", config,
-                   config->refcount + 1, config->refcount));
-    if (config->refcount > 0)
-      return;
-  }
+  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"));
 
index d2e0a40eccda21662a79e2d5532458d9ea6638f5..a842576b92c736966b4c83e28a3628176c49dc33 100644 (file)
@@ -150,7 +150,7 @@ typedef struct {
   void *tmp;
 
   /* Reference count (when this reaches zero, config object is destroyed) */
-  SilcUInt16 refcount;
+  SilcInt16 refcount;
 
   /* The General section */
   char *module_path;
@@ -189,8 +189,7 @@ typedef struct {
 /* Prototypes */
 
 /* Basic config operations */
-SilcServerConfig silc_server_config_alloc(SilcServer server, 
-                                         const char *filename);
+SilcServerConfig silc_server_config_alloc(const char *filename);
 void silc_server_config_destroy(SilcServerConfig config);
 void silc_server_config_ref(SilcServerConfigRef *ref, SilcServerConfig config,
                            void *ref_ptr);
index c2318925f06e52c9596e32555e6f5360bc14199b..ee328f939c5cf0cd3e2793cba41a2bd49b644187 100644 (file)
@@ -268,7 +268,7 @@ int main(int argc, char **argv)
     goto fail;
 
   /* Read configuration files */
-  silcd->config = silc_server_config_alloc(silcd, silcd_config_file);
+  silcd->config = silc_server_config_alloc(silcd_config_file);
   if (silcd->config == NULL)
     goto fail;
   silcd->config_file = silcd_config_file;
index 3bd46b3554b051000903afdf8a1e8ed38aa78f2e..040f51e0ae4e61c0d76686c3fc7d12f83ed9e17a 100644 (file)
@@ -158,7 +158,7 @@ static bool silc_log_reset(SilcLog log)
 SILC_TASK_CALLBACK(silc_log_fflush_callback)
 {
   unsigned int u;
-  if (silc_log_quick) {
+  if (!silc_log_quick) {
     silc_log_flush_all();
     SILC_FOREACH_LOG(u)
       silc_log_checksize(&silclogs[u]);