Merged silc_1_0_branch to trunk.
[silc.git] / apps / silcd / server.c
index 2c3875a5c12bc8826866dcbfbe418621fddc5a20..f5a2ffe71fd2d1fcb9d9ac48ca36d3541245f459 100644 (file)
@@ -278,7 +278,7 @@ bool silc_server_init_secondary(SilcServer server)
 
 bool silc_server_init(SilcServer server)
 {
-  int sock;
+  int sock = -1;
   SilcServerID *id;
   SilcServerEntry id_entry;
   SilcIDListPurge purge;
@@ -295,7 +295,7 @@ bool silc_server_init(SilcServer server)
 #ifdef SILC_DEBUG
   /* Set debugging on if configured */
   if (server->config->debug_string) {
-    silc_debug = TRUE;
+    silc_log_debug(TRUE);
     silc_log_set_debug_string(server->config->debug_string);
   }
 #endif /* SILC_DEBUG */
@@ -343,22 +343,22 @@ bool silc_server_init(SilcServer server)
   /* Initialize ID caches */
   server->local_list->clients =
     silc_idcache_alloc(0, SILC_ID_CLIENT, silc_idlist_client_destructor,
-                      FALSE, TRUE);
+                      server, FALSE, TRUE);
   server->local_list->servers =
-    silc_idcache_alloc(0, SILC_ID_SERVER, NULL, FALSE, TRUE);
+    silc_idcache_alloc(0, SILC_ID_SERVER, NULL, NULL, FALSE, TRUE);
   server->local_list->channels =
-    silc_idcache_alloc(0, SILC_ID_CHANNEL, NULL, FALSE, TRUE);
+    silc_idcache_alloc(0, SILC_ID_CHANNEL, NULL, NULL, FALSE, TRUE);
 
   /* These are allocated for normal server as well as these hold some
      global information that the server has fetched from its router. For
      router these are used as they are supposed to be used on router. */
   server->global_list->clients =
     silc_idcache_alloc(0, SILC_ID_CLIENT, silc_idlist_client_destructor,
-                      FALSE, TRUE);
+                      server, FALSE, TRUE);
   server->global_list->servers =
-    silc_idcache_alloc(0, SILC_ID_SERVER, NULL, FALSE, TRUE);
+    silc_idcache_alloc(0, SILC_ID_SERVER, NULL, NULL, FALSE, TRUE);
   server->global_list->channels =
-    silc_idcache_alloc(0, SILC_ID_CHANNEL, NULL, FALSE, TRUE);
+    silc_idcache_alloc(0, SILC_ID_CHANNEL, NULL, NULL, FALSE, TRUE);
 
   /* Init watcher lists */
   server->watcher_list =
@@ -572,7 +572,7 @@ bool silc_server_rehash(SilcServer server)
   SILC_LOG_INFO(("Rehashing server"));
 
   /* Reset the logging system */
-  silc_log_quick = TRUE;
+  silc_log_quick(TRUE);
   silc_log_flush_all();
 
   /* Start the main rehash phase (read again the config file) */
@@ -764,7 +764,7 @@ bool silc_server_rehash(SilcServer server)
 #ifdef SILC_DEBUG
   /* Set debugging on if configured */
   if (server->config->debug_string) {
-    silc_debug = TRUE;
+    silc_log_debug(TRUE);
     silc_log_set_debug_string(server->config->debug_string);
   }
 #endif /* SILC_DEBUG */
@@ -2862,6 +2862,7 @@ void silc_server_packet_parse_type(SilcServer server,
      */
     if (packet->flags & SILC_PACKET_FLAG_LIST)
       break;
+    server->stat.commands_received++;
     silc_server_command_process(server, sock, packet);
     break;
 
@@ -2873,6 +2874,7 @@ void silc_server_packet_parse_type(SilcServer server,
      */
     if (packet->flags & SILC_PACKET_FLAG_LIST)
       break;
+    server->stat.commands_received++;
     silc_server_command_reply(server, sock, packet);
     break;
 
@@ -5079,6 +5081,8 @@ void silc_server_announce_watches(SilcServer server,
     if (!client || !client->id)
       continue;
 
+    server->stat.commands_sent++;
+
     idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
     args = silc_buffer_alloc_size(2);
     silc_buffer_format(args,
@@ -5718,6 +5722,7 @@ SILC_TASK_CALLBACK(silc_server_get_stats)
 
   if (!server->standalone) {
     SILC_LOG_DEBUG(("Retrieving stats from router"));
+    server->stat.commands_sent++;
     idp = silc_id_payload_encode(server->router->id, SILC_ID_SERVER);
     packet = silc_command_payload_encode_va(SILC_COMMAND_STATS,
                                            ++server->cmd_ident, 1,