From f6115845375d1a0bc605df690ebcd728db995bb6 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Fri, 28 Jun 2002 13:27:58 +0000 Subject: [PATCH] Added better checks that entry is never expired if it is joined on channels. --- apps/silcd/idlist.c | 24 ++++++++++++------------ apps/silcd/packet_receive.c | 8 ++++++-- apps/silcd/server.c | 14 ++++---------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/apps/silcd/idlist.c b/apps/silcd/idlist.c index 3862582c..88331903 100644 --- a/apps/silcd/idlist.c +++ b/apps/silcd/idlist.c @@ -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; diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index b2b04a42..02d83563 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -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) { diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 63e3a609..bd30f64b 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -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)) { -- 2.24.0