Merged silc_1_0_branch to trunk.
[silc.git] / apps / silcd / server_query.c
index a248600953631b6993644b96b3a47a42a334ee81..b9b769713e601c1e3849d5a1c93fbe397a1edb5d 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,
@@ -1532,6 +1543,7 @@ void silc_server_query_send_reply(SilcServer server,
                                         3, nh, strlen(nh));
          sent_reply = TRUE;
        } else {
+         memset(uh, 0, sizeof(uh));
          silc_strncat(uh, sizeof(uh), entry->username,
                       strlen(entry->username));
          if (!strchr(entry->username, '@') && entry->connection) {
@@ -1551,6 +1563,7 @@ void silc_server_query_send_reply(SilcServer server,
        break;
 
       case SILC_COMMAND_WHOWAS:
+       memset(uh, 0, sizeof(uh));
        silc_strncat(uh, sizeof(uh), entry->username, strlen(entry->username));
        if (!strchr(entry->username, '@'))
          silc_strncat(uh, sizeof(uh), "@-private-", 10);
@@ -1968,6 +1981,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;