Cancel future rekeys on a detaching client connection.
[silc.git] / apps / silcd / command.c
index 2bd8198ebcfd0e2583b84098c1063bfe777c8cdd..f68edccdc589984e4c364c4e4220df0ad1636201 100644 (file)
@@ -4074,10 +4074,20 @@ SILC_TASK_CALLBACK(silc_server_command_detach_cb)
   if (client && client->connection) {
     sock = client->connection;
 
+    /* Stop rekey for the client. */
+    silc_server_stop_rekey(server, client);
+
     /* Close the connection on our side */
     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);