Added better checks that entry is never expired if it is joined
authorPekka Riikonen <priikone@silcnet.org>
Fri, 28 Jun 2002 13:27:58 +0000 (13:27 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 28 Jun 2002 13:27:58 +0000 (13:27 +0000)
on channels.

apps/silcd/idlist.c
apps/silcd/packet_receive.c
apps/silcd/server.c

index 3862582cb9e3f3afec92d3079f3568b7cbcf7bf0..883319034af96adfdf022ebde913794e5ea572c1 100644 (file)
@@ -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;
@@ -493,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;
index b2b04a4234a4c5be07768697b98a27b8c509c708..02d835634b71e65982520907de8d13b80e8e503c 100644 (file)
@@ -3370,6 +3370,7 @@ void silc_server_resume_client(SilcServer server,
 {
   SilcBuffer buffer = packet->buffer, buf;
   SilcIDListData idata;
+  SilcIDCacheEntry id_cache = NULL;
   SilcClientEntry detached_client;
   SilcClientID *client_id = NULL;
   unsigned char *id_string, *auth = NULL;
@@ -3741,10 +3742,12 @@ void silc_server_resume_client(SilcServer server,
 
     /* Get entry to the client, and resolve it if we don't have it. */
     detached_client = silc_idlist_find_client_by_id(server->local_list, 
-                                                   client_id, TRUE, NULL);
+                                                   client_id, TRUE,
+                                                   &id_cache);
     if (!detached_client) {
       detached_client = silc_idlist_find_client_by_id(server->global_list,
-                                                     client_id, TRUE, NULL);
+                                                     client_id, TRUE,
+                                                     &id_cache);
       if (!detached_client) {
        SILC_LOG_DEBUG(("Resuming client is unknown"));
        silc_free(client_id);
@@ -3797,6 +3800,7 @@ void silc_server_resume_client(SilcServer server,
     detached_client->mode &= ~SILC_UMODE_DETACHED;
     detached_client->data.status |= SILC_IDLIST_STATUS_RESUMED;
     detached_client->data.status &= ~SILC_IDLIST_STATUS_LOCAL;
+    id_cache->expire = 0;
 
     /* Update channel information regarding global clients on channel. */
     if (server->server_type == SILC_SERVER) {
index 63e3a609231a6dac52298a1cb4620a959b2b04ac..bd30f64b72f2a300f324abbf613d388ad82d3530 100644 (file)
@@ -4477,7 +4477,6 @@ void silc_server_save_users_on_channel(SilcServer server,
   SilcClientEntry client;
   SilcIDCacheEntry cache;
   SilcChannelClientEntry chl;
-  bool global;
 
   SILC_LOG_DEBUG(("Start"));
 
@@ -4499,17 +4498,15 @@ void silc_server_save_users_on_channel(SilcServer server,
       continue;
     }
 
-    global = FALSE;
+    cache = NULL;
 
     /* Check if we have this client cached already. */
     client = silc_idlist_find_client_by_id(server->local_list, client_id,
                                           server->server_type, &cache);
-    if (!client) {
+    if (!client)
       client = silc_idlist_find_client_by_id(server->global_list,
                                             client_id, server->server_type,
                                             &cache);
-      global = TRUE;
-    }
     if (!client) {
       /* If router did not find such Client ID in its lists then this must
         be bogus client or some router in the net is buggy. */
@@ -4531,13 +4528,10 @@ void silc_server_save_users_on_channel(SilcServer server,
       }
 
       client->data.status |= SILC_IDLIST_STATUS_REGISTERED;
-    } else {
-      /* Found, if it is from global list we'll assure that we won't
-        expire it now that the entry is on channel. */
-      if (global)
-       cache->expire = 0;
     }
 
+    if (cache)
+      cache->expire = 0;
     silc_free(client_id);
 
     if (!(client->data.status & SILC_IDLIST_STATUS_REGISTERED)) {