Added support for removing unconfigured client connections in
[silc.git] / apps / silcd / idlist.c
index 7ecb033cd298cfe1207579a596cb976a8c18c384..900092bfbdf7cebd6b0eab200b404cbbb07cb910 100644 (file)
@@ -90,13 +90,13 @@ void silc_idlist_del_data(void *entry)
 
 SILC_TASK_CALLBACK_GLOBAL(silc_idlist_purge)
 {
+  SilcServer server = app_context;
   SilcIDListPurge i = (SilcIDListPurge)context;
 
   SILC_LOG_DEBUG(("Purging cache"));
 
   silc_idcache_purge(i->cache);
-  silc_schedule_task_add(i->schedule, 0, 
-                        silc_idlist_purge,
+  silc_schedule_task_add(server->schedule, 0, silc_idlist_purge,
                         (void *)i, i->timeout, 0,
                         SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);
 }
@@ -159,13 +159,13 @@ silc_idlist_find_server_by_id(SilcIDList id_list, SilcServerID *id,
 
   server = (SilcServerEntry)id_cache->context;
 
-  if (ret_entry)
-    *ret_entry = id_cache;
-
   if (server && registered && 
       !(server->data.status & SILC_IDLIST_STATUS_REGISTERED))
     return NULL;
 
+  if (ret_entry)
+    *ret_entry = id_cache;
+
   SILC_LOG_DEBUG(("Found"));
 
   return server;
@@ -187,13 +187,13 @@ silc_idlist_find_server_by_name(SilcIDList id_list, char *name,
 
   server = (SilcServerEntry)id_cache->context;
   
-  if (ret_entry)
-    *ret_entry = id_cache;
-
   if (server && registered &&
       !(server->data.status & SILC_IDLIST_STATUS_REGISTERED))
     return NULL;
 
+  if (ret_entry)
+    *ret_entry = id_cache;
+
   SILC_LOG_DEBUG(("Found"));
 
   return server;
@@ -239,13 +239,13 @@ silc_idlist_find_server_by_conn(SilcIDList id_list, char *hostname,
   
   silc_idcache_list_free(list);
 
-  if (ret_entry)
-    *ret_entry = id_cache;
-
   if (server && registered &&
       !(server->data.status & SILC_IDLIST_STATUS_REGISTERED))
     return NULL;
 
+  if (ret_entry)
+    *ret_entry = id_cache;
+
   SILC_LOG_DEBUG(("Found"));
 
   return server;
@@ -368,6 +368,8 @@ int silc_idlist_del_client(SilcIDList id_list, SilcClientEntry entry)
     if (!silc_idcache_del_by_context(id_list->clients, entry))
       return FALSE;
 
+    assert(!silc_hash_table_count(entry->channels));
+
     /* Free data */
     silc_free(entry->nickname);
     silc_free(entry->servername);
@@ -491,13 +493,13 @@ silc_idlist_find_client_by_id(SilcIDList id_list, SilcClientID *id,
 
   client = (SilcClientEntry)id_cache->context;
 
-  if (ret_entry)
-    *ret_entry = id_cache;
-
   if (client && registered &&
       !(client->data.status & SILC_IDLIST_STATUS_REGISTERED))
     return NULL;
 
+  if (ret_entry)
+    *ret_entry = id_cache;
+
   SILC_LOG_DEBUG(("Found"));
 
   return client;
@@ -568,6 +570,7 @@ void silc_idlist_client_destructor(SilcIDCache cache,
 
   client = (SilcClientEntry)entry->context;
   if (client) {
+    assert(!silc_hash_table_count(client->channels));
     silc_free(client->nickname);
     silc_free(client->username);
     silc_free(client->userinfo);