Statistics updating fixes to not go negative.
authorPekka Riikonen <priikone@silcnet.org>
Tue, 18 Jun 2002 08:43:31 +0000 (08:43 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 18 Jun 2002 08:43:31 +0000 (08:43 +0000)
apps/silcd/command.c
apps/silcd/packet_receive.c

index 9760e1b52dfa1285f003e892339ab3503b939b04..ff46244a741154df51f5e5b8d0360bbd2659db3e 100644 (file)
@@ -3868,19 +3868,12 @@ SILC_SERVER_CMD_FUNC(umode)
 
     /* Update statistics */
     if (mask & SILC_UMODE_GONE) {
-      if (!client->mode & SILC_UMODE_GONE)
+      if (!(client->mode & SILC_UMODE_GONE))
        server->stat.my_aways++;
     } else {
       if (client->mode & SILC_UMODE_GONE)
        server->stat.my_aways--;
     }
-    if (mask & SILC_UMODE_DETACHED) {
-      if (!client->mode & SILC_UMODE_DETACHED)
-       server->stat.my_detached++;
-    } else {
-      if (client->mode & SILC_UMODE_DETACHED)
-       server->stat.my_detached--;
-    }
 
     /* Change the mode */
     client->mode = mask;
@@ -4982,6 +4975,7 @@ SILC_SERVER_CMD_FUNC(detach)
     silc_server_send_notify_umode(server, server->router->connection,
                                  server->server_type == SILC_SERVER ?
                                  FALSE : TRUE, client->id, client->mode);
+  server->stat.my_detached++;
 
   /* Check if anyone is watching this nickname */
   if (server->server_type == SILC_ROUTER)
index a2a756a0c4bb2ae80ce88950a1c7e6b3c7fa18e3..bd9545f8f1361b3f6b8af4be008eff578da4c5f1 100644 (file)
@@ -1442,14 +1442,14 @@ void silc_server_notify(SilcServer server,
     /* Update statistics */
     if (server->server_type == SILC_ROUTER) {
       if (mode & SILC_UMODE_GONE) {
-       if (!client->mode & SILC_UMODE_GONE)
+       if (!(client->mode & SILC_UMODE_GONE))
          server->stat.aways++;
       } else {
        if (client->mode & SILC_UMODE_GONE)
          server->stat.aways--;
       }
       if (mode & SILC_UMODE_DETACHED) {
-       if (!client->mode & SILC_UMODE_DETACHED)
+       if (!(client->mode & SILC_UMODE_DETACHED))
          server->stat.detached++;
       } else {
        if (client->mode & SILC_UMODE_DETACHED)
@@ -3369,6 +3369,7 @@ void silc_server_resume_client(SilcServer server,
     detached_client->data.status |= SILC_IDLIST_STATUS_REGISTERED;
     detached_client->data.status |= SILC_IDLIST_STATUS_RESUMED;
     detached_client->mode &= ~SILC_UMODE_DETACHED;
+    server->stat.my_detached--;
 
     /* Send the RESUME_CLIENT packet to our primary router so that others
        know this client isn't detached anymore. */