From ce742c4140e578ab25c84eef9c189892c3681214 Mon Sep 17 00:00:00 2001 From: Skywing Date: Thu, 11 Dec 2008 23:22:04 -0500 Subject: [PATCH] Don't count detached users in server local user count. This commit decrements the count of users when a detach occurs, and increments the count when a user re-attaches. This is done as current silc routers have a bug where only a detached users previous home server is not properly pro-actively notified of a user resuming elsewhere unless the user resumes on a router server. The issue with non-router-server resume notification will be fixed seperately. This change allows member servers to operate reliably in the event that there is a router with the aforementioned bug in their silcnet. --- apps/silcd/command.c | 7 +++++++ apps/silcd/packet_receive.c | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/silcd/command.c b/apps/silcd/command.c index 2bd8198e..698b2265 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -4078,6 +4078,13 @@ SILC_TASK_CALLBACK(silc_server_command_detach_cb) client->router = NULL; client->connection = NULL; silc_server_close_connection(server, sock); + + /* + * Decrement the user count; we'll increment it if the user resumes on our + * server. + */ + SILC_VERIFY(&server->stat.my_clients > 0); + server->stat.my_clients--; } silc_free(client_id); diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index ab174e4f..5a49ca31 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -3734,8 +3734,12 @@ void silc_server_resume_client(SilcServer server, silc_server_check_watcher_list(server, detached_client, NULL, SILC_NOTIFY_TYPE_UMODE_CHANGE); - /* Delete this current client entry since we're resuming to old one. */ - server->stat.my_clients--; + /* Delete this current client entry since we're resuming to old one. + We decrement clients/cell_clients as we are getting rid of the + current client and replacing it with the detached one. We keep the + server user count as-is (incremented by the current client entry) as + we decremented the count already during detach, thus we'd be undoing + that operation. */ SILC_VERIFY(server->stat.clients > 0); server->stat.clients--; if (server->stat.cell_clients) -- 2.24.0