Yet more checks for assuring client is not expired if it is on
authorPekka Riikonen <priikone@silcnet.org>
Sun, 7 Jul 2002 10:11:04 +0000 (10:11 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 7 Jul 2002 10:11:04 +0000 (10:11 +0000)
channels.

CHANGES
apps/silcd/command_reply.c
apps/silcd/server.c

diff --git a/CHANGES b/CHANGES
index 67bb578af45aa3852d39cb0752834dde2dcb283f..48d825b191e9173b28c4a3e99853ae51a0699ef4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+Sun Jul  7 13:10:01 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
+
+       * Added yet more checks that client is not expired on global
+         list if it is on channels.  Affected file is
+         silcd/command_reply.c.
+
 Sat Jul  6 11:45:11 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
 
        * Merged c0ffee's MIME signal patch which adds support for
index 76a30b89037cd2c9273c4783d38cd734cc7f8b47..64ca3abaa2f346835581670ffc80f00322d5e4b6 100644 (file)
@@ -210,8 +210,7 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
     client = silc_idlist_add_client(server->global_list, nick, 
                                    strdup(username), 
                                    strdup(realname), client_id, 
-                                   cmd->sock->user_data, NULL, 
-                                   time(NULL) + 300);
+                                   cmd->sock->user_data, NULL, 0);
     if (!client) {
       SILC_LOG_ERROR(("Could not add new client to the ID Cache"));
       return FALSE;
@@ -250,7 +249,7 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
     /* Create new cache entry */
     silc_idcache_add(global ? server->global_list->clients :
                     server->local_list->clients, nick, client->id, 
-                    client, 0, &cache); 
+                    client, 0, NULL); 
     silc_free(client_id);
   }
 
@@ -268,11 +267,16 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
       silc_server_save_user_channels(server, cmd->sock, client, NULL, NULL);
     }
 
-    if (cache)
-      /* If client is global and is not on any channel then add that we'll
-        expire the entry after a while. */
-      if (global && !silc_hash_table_count(client->channels))
+    /* If client is global and is not on any channel then add that we'll
+       expire the entry after a while. */
+    if (global) {
+      silc_idlist_find_client_by_id(server->global_list, client->id,
+                                   FALSE, &cache);
+      if (!silc_hash_table_count(client->channels))
        cache->expire = time(NULL) + 300;
+      else
+       cache->expire = 0;
+    }
   }
 
   if (fingerprint && flen == sizeof(client->data.fingerprint))
@@ -491,8 +495,8 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd)
         global. */
       client = silc_idlist_add_client(server->global_list, nick, 
                                      info ? strdup(info) : NULL, NULL,
-                                     client_id, cmd->sock->user_data, NULL,
-                                     time(NULL) + 300);
+                                     client_id, cmd->sock->user_data,
+                                     NULL, time(NULL) + 300);
       if (!client) {
        SILC_LOG_ERROR(("Could not add new client to the ID Cache"));
        goto error;
@@ -526,18 +530,24 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd)
       client->data.status &= ~SILC_IDLIST_STATUS_RESOLVING;
       
       if (name) {
-       /* If client is global and is not on any channel then add that we'll
-          expire the entry after a while. */
-       if (global && !silc_hash_table_count(client->channels) &&
-           server->server_type == SILC_SERVER)
-         expire = time(NULL) + 300;
-
        /* Add new cache entry */
        silc_idcache_add(global ? server->global_list->clients :
                         server->local_list->clients, nick, client->id, 
                         client, expire, NULL);
       }
 
+      /* If client is global and is not on any channel then add that we'll
+         expire the entry after a while. */
+      if (global && server->server_type == SILC_SERVER) {
+       SilcIDCacheEntry cache = NULL;
+        silc_idlist_find_client_by_id(server->global_list, client->id,
+                                     FALSE, &cache);
+        if (!silc_hash_table_count(client->channels))
+         cache->expire = time(NULL) + 300;
+        else
+         cache->expire = 0;
+      }
+
       silc_free(client_id);
     }
 
index 2c0099ddc0f63090850d2a9fe1ca37f2b2bc103d..a5b956f202e48901fabb405f6810879057f83762 100644 (file)
@@ -4610,7 +4610,7 @@ void silc_server_save_users_on_channel(SilcServer server,
     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. */
-      if (server->server_type == SILC_ROUTER) {
+      if (server->server_type != SILC_SERVER) {
        silc_free(client_id);
        continue;
       }