Merged silc_1_0_branch to trunk.
[silc.git] / apps / silcd / server_query.c
index a248600953631b6993644b96b3a47a42a334ee81..f54145da589c2cd00c4601e13bc4d36101bde079 100644 (file)
@@ -294,6 +294,9 @@ void silc_server_query_send_router(SilcServer server, SilcServerQuery query)
 
   SILC_LOG_DEBUG(("Forwarding the query to router for processing"));
 
+  /* Statistics */
+  server->stat.commands_sent++;
+
   /* Send WHOIS command to our router */
   old_ident = silc_command_get_ident(query->cmd->payload);
   silc_command_set_ident(query->cmd->payload, ++server->cmd_ident);
@@ -336,6 +339,9 @@ void silc_server_query_send_router_reply(void *context, void *reply)
 
     SILC_LOG_DEBUG(("Sending error to original query"));
 
+    /* Statistics */
+    server->stat.commands_sent++;
+
     /* Send the same command reply payload which contains the error */
     silc_command_set_command(cmdr->payload, query->querycmd);
     silc_command_set_ident(cmdr->payload,
@@ -407,16 +413,18 @@ void silc_server_query_parse(SilcServer server, SilcServerQuery query)
       }
 
       /* Check nickname */
-      tmp = silc_identifier_check(query->nickname, strlen(query->nickname),
-                                 SILC_STRING_UTF8, 128, &tmp_len);
-      if (!tmp) {
-       silc_server_query_send_error(server, query,
-                                    SILC_STATUS_ERR_BAD_NICKNAME, 0);
-       silc_server_query_free(query);
-       return;
+      if (tmp) {
+       tmp = silc_identifier_check(query->nickname, strlen(query->nickname),
+                                   SILC_STRING_UTF8, 128, &tmp_len);
+       if (!tmp) {
+         silc_server_query_send_error(server, query,
+                                      SILC_STATUS_ERR_BAD_NICKNAME, 0);
+         silc_server_query_free(query);
+         return;
+       }
+       silc_free(query->nickname);
+       query->nickname = tmp;
       }
-      silc_free(query->nickname);
-      query->nickname = tmp;
 
     } else {
       /* Parse the IDs included in the query */
@@ -1100,6 +1108,9 @@ void silc_server_query_resolve(SilcServer server, SilcServerQuery query,
        r->argc++;
       }
 
+      /* Statistics */
+      server->stat.commands_sent++;
+
       /* Send WHOIS command */
       res_cmd = silc_command_payload_encode(SILC_COMMAND_WHOIS,
                                            r->argc, r->arg, r->arg_lens,
@@ -1968,6 +1979,9 @@ SilcClientEntry silc_server_query_client(SilcServer server,
       always_resolve) {
     SilcBuffer buffer, idp;
 
+    /* Statistics */
+    server->stat.commands_sent++;
+
     if (client) {
       client->data.status |= SILC_IDLIST_STATUS_RESOLVING;
       client->data.status &= ~SILC_IDLIST_STATUS_RESOLVED;