From 95fc2076c8fa714b5ab648073e51a22f1ca11508 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sun, 20 May 2001 11:14:45 +0000 Subject: [PATCH] updates. --- CHANGES | 9 +++++++++ apps/silcd/command.c | 17 ++++++++++++----- apps/silcd/idlist.c | 8 ++++++++ lib/silcclient/command_reply.c | 9 ++++++--- lib/silcclient/idlist.c | 6 ++---- lib/silccore/idcache.c | 11 ++++++++++- prepare | 2 +- 7 files changed, 48 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index bc2d871e..0af54380 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,12 @@ +Sun May 20 13:45:58 EEST 2001 Pekka Riikonen + + * silc_idcache_purge_by_context deletes the entry now by context + as it is supposed to do. Affected file lib/silccore/idcache.c. + + * Send the ERR_NO_SUCH_NICK in the WHOIS command reply if the + client is not anymore valid (WHOWAS givens the info) and not + the ERR_NO_SUCH_CLIENT_ID if the nickname still exists. + Sat May 19 16:30:03 EEST 2001 Pekka Riikonen * Removed the `data' and `data_len' arguments from the ID Cache diff --git a/apps/silcd/command.c b/apps/silcd/command.c index 28cd5674..31283fd0 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -555,11 +555,18 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd, if (entry->data.registered == FALSE) { if (clients_count == 1) { - SilcBuffer idp = silc_id_payload_encode(entry->id, SILC_ID_CLIENT); - silc_server_command_send_status_data(cmd, SILC_COMMAND_WHOIS, - SILC_STATUS_ERR_NO_SUCH_CLIENT_ID, - 2, idp->data, idp->len); - silc_buffer_free(idp); + if (entry->nickname) { + silc_server_command_send_status_data(cmd, SILC_COMMAND_WHOIS, + SILC_STATUS_ERR_NO_SUCH_NICK, + 3, entry->nickname, + strlen(entry->nickname)); + } else { + SilcBuffer idp = silc_id_payload_encode(entry->id, SILC_ID_CLIENT); + silc_server_command_send_status_data(cmd, SILC_COMMAND_WHOIS, + SILC_STATUS_ERR_NO_SUCH_CLIENT_ID, + 2, idp->data, idp->len); + silc_buffer_free(idp); + } } continue; } diff --git a/apps/silcd/idlist.c b/apps/silcd/idlist.c index 8da13662..a647c949 100644 --- a/apps/silcd/idlist.c +++ b/apps/silcd/idlist.c @@ -383,6 +383,8 @@ int silc_idlist_get_clients_by_nickname(SilcIDList id_list, char *nickname, *clients_count += i; + SILC_LOG_DEBUG(("Found %d clients", *clients_count)); + return TRUE; } @@ -404,6 +406,10 @@ int silc_idlist_get_clients_by_hash(SilcIDList id_list, char *nickname, silc_hash_make(md5hash, nickname, strlen(nickname), hash); + /* As the Client ID is hashed in the ID cache by hashing only the hash + from the Client ID, we can do a lookup with only the hash not the + other parts of the ID and get all the clients with that hash, ie. + with that nickname, as the hash is from the nickname. */ memset(&client_id, 0, sizeof(client_id)); memcpy(&client_id.hash, hash, sizeof(client_id.hash)); if (!silc_idcache_find_by_id(id_list->clients, &client_id, &list)) @@ -424,6 +430,8 @@ int silc_idlist_get_clients_by_hash(SilcIDList id_list, char *nickname, *clients_count += i; + SILC_LOG_DEBUG(("Found %d clients", *clients_count)); + return TRUE; } diff --git a/lib/silcclient/command_reply.c b/lib/silcclient/command_reply.c index 629acd05..03f13c98 100644 --- a/lib/silcclient/command_reply.c +++ b/lib/silcclient/command_reply.c @@ -1043,7 +1043,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(join) SILC_GET32_MSB(mode, client_mode_list->data); /* Check if we have this client cached already. */ - if (!silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)client_id, + if (!silc_idcache_find_by_id_one_ext(conn->client_cache, + (void *)client_id, NULL, NULL, silc_hash_client_id_compare, NULL, &id_cache)) { @@ -1638,7 +1639,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(users) SILC_GET32_MSB(mode, client_mode_list->data); /* Check if we have this client cached already. */ - if (!silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)client_id, + if (!silc_idcache_find_by_id_one_ext(conn->client_cache, + (void *)client_id, NULL, NULL, silc_hash_client_id_compare, NULL, &id_cache)) { @@ -1773,7 +1775,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(getkey) if (id_type == SILC_ID_CLIENT) { client_id = silc_id_payload_get_id(idp); - if (!silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)client_id, + if (!silc_idcache_find_by_id_one_ext(conn->client_cache, + (void *)client_id, NULL, NULL, silc_hash_client_id_compare, NULL, &id_cache)) diff --git a/lib/silcclient/idlist.c b/lib/silcclient/idlist.c index 487b739c..e03b89df 100644 --- a/lib/silcclient/idlist.c +++ b/lib/silcclient/idlist.c @@ -124,8 +124,7 @@ SilcClientEntry *silc_client_get_clients_local(SilcClient client, int i = 0; /* Find ID from cache */ - if (!silc_idcache_find_by_name(conn->client_cache, nickname, - &list)) + if (!silc_idcache_find_by_name(conn->client_cache, nickname, &list)) return NULL; if (!silc_idcache_list_count(list)) { @@ -357,8 +356,7 @@ SilcClientEntry silc_idlist_get_client(SilcClient client, SilcClientEntry entry = NULL; /* Find ID from cache */ - if (!silc_idcache_find_by_name(conn->client_cache, nickname, - &list)) { + if (!silc_idcache_find_by_name(conn->client_cache, nickname, &list)) { identify: if (query) { diff --git a/lib/silccore/idcache.c b/lib/silccore/idcache.c index ee557dce..7b8b1fa7 100644 --- a/lib/silccore/idcache.c +++ b/lib/silccore/idcache.c @@ -304,6 +304,7 @@ bool silc_idcache_purge(SilcIDCache cache) bool silc_idcache_purge_by_context(SilcIDCache cache, void *context) { SilcIDCacheEntry entry; + bool ret = FALSE; if (!silc_hash_table_find(cache->context_table, context, NULL, (void *)&entry)) @@ -313,7 +314,15 @@ bool silc_idcache_purge_by_context(SilcIDCache cache, void *context) if (cache->destructor) cache->destructor(cache, entry); - return silc_idcache_del(cache, entry); + if (entry->name) + ret = silc_hash_table_del_by_context(cache->name_table, entry->name, + entry); + if (entry->context) + ret = silc_hash_table_del(cache->context_table, entry->context); + if (entry->id) + ret = silc_hash_table_del_by_context(cache->id_table, entry->id, entry); + + return ret; } /* Callback that is called by the hash table routine when traversing diff --git a/prepare b/prepare index 275bed67..c3405b91 100755 --- a/prepare +++ b/prepare @@ -25,7 +25,7 @@ # temporary files (including these prepare* scripts) are removed. # -SILC_VERSION=0.2.4 +SILC_VERSION=0.2.5 version=$1 if test "$version" = ""; then -- 2.24.0