X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Fsilcd%2Fcommand_reply.c;h=d7202f2714344505b3ff27a4bdcf2ea461c9c959;hb=a939f27e19b8084ef2acd25156b19d26d1440ace;hp=97aedf0e8e37455267c4818136418a9c24510b9f;hpb=8e164669b363452ae89fd48b5ddeee3446636217;p=silc.git diff --git a/apps/silcd/command_reply.c b/apps/silcd/command_reply.c index 97aedf0e..d7202f27 100644 --- a/apps/silcd/command_reply.c +++ b/apps/silcd/command_reply.c @@ -515,7 +515,7 @@ silc_server_command_reply_whowas_save(SilcServerCommandReplyContext cmd) if (!nickname) { SILC_LOG_ERROR(("Malformed nickname '%s' received in WHOWAS reply " "from %s", - hostname ? hostname : "", nick)); + nick, hostname ? hostname : "")); return FALSE; } @@ -533,22 +533,23 @@ 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; - /* Remove the old cache entry and create a new one */ - silc_idcache_del_by_context(global ? server->global_list->clients : - server->local_list->clients, client, NULL); - silc_idcache_add(global ? server->global_list->clients : - server->local_list->clients, nickname, client->id, - client); + /* Update cache entry */ + silc_idcache_update_by_context(global ? server->global_list->clients : + server->local_list->clients, client, NULL, + nickname, TRUE); } /* 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)) { + silc_dlist_del(server->expired_clients, client); silc_dlist_add(server->expired_clients, client); + } } return TRUE; @@ -675,17 +676,13 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd) return FALSE; } - /* Remove the old cache entry */ - silc_idcache_del_by_context(global ? server->global_list->clients : - server->local_list->clients, client, NULL); - silc_free(client->nickname); client->nickname = strdup(nick); - /* Add new cache entry */ - silc_idcache_add(global ? server->global_list->clients : - server->local_list->clients, name, client->id, - client); + /* Update the context */ + silc_idcache_update_by_context(global ? server->global_list->clients : + server->local_list->clients, client, + NULL, name, TRUE); } if (info) {