From 14e9088d0451b764fc214246814883c9a018f7bf Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Tue, 19 Apr 2005 09:01:51 +0000 Subject: [PATCH] Delete client's public key from public key has in idcache destructor. --- apps/silcd/idlist.c | 10 ++++++++-- apps/silcd/idlist.h | 3 ++- apps/silcd/server.c | 12 ++++++------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/apps/silcd/idlist.c b/apps/silcd/idlist.c index 621c4c4f..d47ba04a 100644 --- a/apps/silcd/idlist.c +++ b/apps/silcd/idlist.c @@ -407,7 +407,6 @@ int silc_idlist_del_client(SilcIDList id_list, SilcClientEntry entry) SILC_LOG_DEBUG(("Start")); if (entry) { - /* Remove from cache. Destructor callback deletes stuff. */ if (!silc_idcache_del_by_context(id_list->clients, entry)) { SILC_LOG_DEBUG(("Unknown client, did not delete")); return FALSE; @@ -435,12 +434,19 @@ int silc_idlist_del_client(SilcIDList id_list, SilcClientEntry entry) /* ID Cache destructor */ void silc_idlist_client_destructor(SilcIDCache cache, - SilcIDCacheEntry entry) + SilcIDCacheEntry entry, + void *context) { + SilcServer server = context; SilcClientEntry client; client = (SilcClientEntry)entry->context; if (client) { + /* Remove this client from the public key hash list */ + if (client->data.public_key) + silc_hash_table_del_by_context(server->pk_hash, + client->data.public_key, client); + assert(!silc_hash_table_count(client->channels)); silc_free(client->nickname); silc_free(client->servername); diff --git a/apps/silcd/idlist.h b/apps/silcd/idlist.h index cff9c43c..0c4d0a60 100644 --- a/apps/silcd/idlist.h +++ b/apps/silcd/idlist.h @@ -616,7 +616,8 @@ silc_idlist_replace_client_id(SilcServer server, SilcIDList id_list, SilcClientID *old_id, SilcClientID *new_id, const char *nickname); void silc_idlist_client_destructor(SilcIDCache cache, - SilcIDCacheEntry entry); + SilcIDCacheEntry entry, + void *context); SilcChannelEntry silc_idlist_add_channel(SilcIDList id_list, char *channel_name, int mode, SilcChannelID *id, SilcServerEntry router, diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 2c3875a5..345fd62f 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -343,22 +343,22 @@ bool silc_server_init(SilcServer server) /* Initialize ID caches */ server->local_list->clients = silc_idcache_alloc(0, SILC_ID_CLIENT, silc_idlist_client_destructor, - FALSE, TRUE); + server, FALSE, TRUE); server->local_list->servers = - silc_idcache_alloc(0, SILC_ID_SERVER, NULL, FALSE, TRUE); + silc_idcache_alloc(0, SILC_ID_SERVER, NULL, NULL, FALSE, TRUE); server->local_list->channels = - silc_idcache_alloc(0, SILC_ID_CHANNEL, NULL, FALSE, TRUE); + silc_idcache_alloc(0, SILC_ID_CHANNEL, NULL, NULL, FALSE, TRUE); /* These are allocated for normal server as well as these hold some global information that the server has fetched from its router. For router these are used as they are supposed to be used on router. */ server->global_list->clients = silc_idcache_alloc(0, SILC_ID_CLIENT, silc_idlist_client_destructor, - FALSE, TRUE); + server, FALSE, TRUE); server->global_list->servers = - silc_idcache_alloc(0, SILC_ID_SERVER, NULL, FALSE, TRUE); + silc_idcache_alloc(0, SILC_ID_SERVER, NULL, NULL, FALSE, TRUE); server->global_list->channels = - silc_idcache_alloc(0, SILC_ID_CHANNEL, NULL, FALSE, TRUE); + silc_idcache_alloc(0, SILC_ID_CHANNEL, NULL, NULL, FALSE, TRUE); /* Init watcher lists */ server->watcher_list = -- 2.43.0