Delete client's public key from public key has in idcache
authorPekka Riikonen <priikone@silcnet.org>
Tue, 19 Apr 2005 09:01:51 +0000 (09:01 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 19 Apr 2005 09:01:51 +0000 (09:01 +0000)
destructor.

apps/silcd/idlist.c
apps/silcd/idlist.h
apps/silcd/server.c

index 621c4c4ffccc8600c8db86416e5c3bf5b9b7c40c..d47ba04aeb1bb77271a6f3fb1f309260cb3edeea 100644 (file)
@@ -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);
index cff9c43c161f1dc219339e142bd48e2fbc6c99ba..0c4d0a60808c4b1a885893e93c259bb686734a17 100644 (file)
@@ -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,
index 2c3875a5c12bc8826866dcbfbe418621fddc5a20..345fd62f27369d4229abfdace34659a982fd375d 100644 (file)
@@ -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 =