Added debug logs for updating stat.clients value
[silc.git] / apps / silcd / packet_receive.c
index ac8156106e02c5616018027769623d1ff4fe015b..0d96f7bbe6f026005ed9f4af246c70ea986ee17a 100644 (file)
@@ -326,6 +326,8 @@ static void silc_server_notify_process(SilcServer server,
       tmp_len = 128;
 
     /* Update statistics */
+    SILC_LOG_DEBUG(("stat.clients %d->%d", server->stat.clients,
+                   server->stat.clients - 1));
     SILC_VERIFY(server->stat.clients > 0);
     server->stat.clients--;
     if (server->stat.cell_clients)
@@ -1246,6 +1248,8 @@ static void silc_server_notify_process(SilcServer server,
            }
 
            /* Update statistics */
+           SILC_LOG_DEBUG(("stat.clients %d->%d", server->stat.clients,
+                           server->stat.clients - 1));
            SILC_VERIFY(server->stat.clients > 0);
            server->stat.clients--;
            if (server->stat.cell_clients)
@@ -1492,6 +1496,8 @@ static void silc_server_notify_process(SilcServer server,
       }
 
       /* Update statistics */
+      SILC_LOG_DEBUG(("stat.clients %d->%d", server->stat.clients,
+                     server->stat.clients - 1));
       SILC_VERIFY(server->stat.clients > 0);
       server->stat.clients--;
       if (server->stat.cell_clients)
@@ -1500,7 +1506,8 @@ static void silc_server_notify_process(SilcServer server,
       SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
 
       if (SILC_IS_LOCAL(client)) {
-       server->stat.my_clients--;
+       if (!client->local_detached)
+         server->stat.my_clients--;
        silc_schedule_task_del_by_context(server->schedule, client);
        silc_idlist_del_data(client);
        client->mode = 0;
@@ -2685,6 +2692,8 @@ static void silc_server_new_id_real(SilcServer server,
 
       if (idata->conn_type == SILC_CONN_SERVER)
        server->stat.cell_clients++;
+      SILC_LOG_DEBUG(("stat.clients %d->%d", server->stat.clients,
+                     server->stat.clients + 1));
       server->stat.clients++;
 
       /* Check if anyone is watching this nickname */
@@ -3740,6 +3749,9 @@ void silc_server_resume_client(SilcServer server,
        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. */
+    detached_client->local_detached = FALSE;
+    SILC_LOG_DEBUG(("stat.clients %d->%d", server->stat.clients,
+                   server->stat.clients - 1));
     SILC_VERIFY(server->stat.clients > 0);
     server->stat.clients--;
     if (server->stat.cell_clients)
@@ -4025,8 +4037,12 @@ void silc_server_resume_client(SilcServer server,
                                       detached_client, &id_cache))
        silc_idcache_move(server->local_list->clients,
                          server->global_list->clients, id_cache);
-    }
+      }
 
+    /* We don't own this client anymore, if we ever did, as we were just
+     * told that someone else resumed it.  Thus, it is most definitely no
+     * a detached client.*/
+    detached_client->local_detached = FALSE;
     /* Change the owner of the client */
     detached_client->router = server_entry;