silcd: IDENTIFY command reply didn't save userinfo correctly
[silc.git] / apps / silcd / command_reply.c
index 36eb1368497914f62fe0e3623ee9276aa6f71b08..47c7a3f5315aad7e49dfb9c552d44e14077072b2 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2005, 2007 Pekka Riikonen
+  Copyright (C) 1997 - 2009 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -152,6 +152,7 @@ silc_server_command_process_error(SilcServerCommandReplyContext cmd,
 
       silc_server_remove_from_channels(server, NULL, client, TRUE,
                                       NULL, TRUE, FALSE);
+      silc_dlist_del(server->expired_clients, client);
       silc_idlist_del_data(client);
       silc_idlist_del_client(server->global_list, client);
     }
@@ -235,6 +236,10 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
     client->data.status &= ~SILC_IDLIST_STATUS_RESOLVING;
     client->mode = mode;
     client->servername = servername[0] ? strdup(servername) : NULL;
+
+    SILC_LOG_DEBUG(("stat.clients %d->%d", server->stat.clients,
+                   server->stat.clients + 1));
+    server->stat.clients++;
   } else {
     /* We have the client already, update the data */
 
@@ -533,6 +538,7 @@ silc_server_command_reply_whowas_save(SilcServerCommandReplyContext cmd)
     client->servername = servername[0] ? strdup(servername) : NULL;
     client->data.status |= SILC_IDLIST_STATUS_RESOLVED;
     client->data.status &= ~SILC_IDLIST_STATUS_RESOLVING;
+    client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
 
     /* Update cache entry */
     silc_idcache_update_by_context(global ? server->global_list->clients :
@@ -543,10 +549,13 @@ silc_server_command_reply_whowas_save(SilcServerCommandReplyContext cmd)
   /* If client is global and is not on any channel then add that we'll
      expire the entry after a while. */
   if (global) {
-    silc_idlist_find_client_by_id(server->global_list, client->id,
-                                 FALSE, &cache);
-    if (!silc_hash_table_count(client->channels))
+    client = silc_idlist_find_client_by_id(server->global_list, client->id,
+                                          FALSE, &cache);
+    if (client && !silc_hash_table_count(client->channels)) {
+      client->data.created = silc_time();
+      silc_dlist_del(server->expired_clients, client);
       silc_dlist_add(server->expired_clients, client);
+    }
   }
 
   return TRUE;
@@ -643,7 +652,8 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd)
         to global list since server didn't have it in the lists so it must be
         global. */
       client = silc_idlist_add_client(server->global_list,
-                                     nick[0] ? nick : NULL, info, NULL,
+                                     nick[0] ? strdup(nick) : NULL, 
+                                     info ? strdup(info) : NULL, NULL,
                                      silc_id_dup(&client_id, SILC_ID_CLIENT),
                                      silc_packet_get_context(cmd->sock),
                                      NULL);
@@ -655,6 +665,10 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd)
       client->data.status |= SILC_IDLIST_STATUS_REGISTERED;
       client->data.status |= SILC_IDLIST_STATUS_RESOLVED;
       client->data.status &= ~SILC_IDLIST_STATUS_RESOLVING;
+
+      SILC_LOG_DEBUG(("stat.clients %d->%d", server->stat.clients,
+                     server->stat.clients + 1));
+      server->stat.clients++;
     } else {
       /* We have the client already, update the data */
 
@@ -1237,6 +1251,8 @@ SILC_SERVER_CMD_REPLY_FUNC(stats)
                         SILC_STR_END);
   }
 
+  SILC_LOG_DEBUG(("stat.clients = %d", server->stat.clients));
+
  out:
   SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_STATS);
  err: