Report the number of memos, not recipients, in /msg MemoServ status.
authorMichael Poole <mdpoole@troilus.org>
Fri, 6 Mar 2009 13:04:13 +0000 (08:04 -0500)
committerMichael Poole <mdpoole@troilus.org>
Fri, 6 Mar 2009 13:04:13 +0000 (08:04 -0500)
Another bug spotted by ZeRoFiGhter.

src/mod-memoserv.c (memoCount): New variable.
  (delete_memo): Decrement it.
  (add_memo): Increment it.
  (cmd_status): Report it.

src/mod-memoserv.c

index d580b6650e986d59087771aaa44131896aa8bfdd..447744fe07d391a0dd7ba6c71a91a46030ffaca8 100644 (file)
@@ -118,7 +118,9 @@ static struct {
 const char *memoserv_module_deps[] = { NULL };
 static struct module *memoserv_module;
 static struct log_type *MS_LOG;
-static unsigned long memosSent, memosExpired;
+static unsigned long memoCount;
+static unsigned long memosSent;
+static unsigned long memosExpired;
 static struct dict *memos; /* memo_account->handle->handle -> memo_account */
 
 static struct memo_account *
@@ -146,6 +148,7 @@ delete_memo(struct memo *memo)
     memoList_remove(&memo->sender->sent, memo);
     free(memo->message);
     free(memo);
+    memoCount--;
 }
 
 static void
@@ -205,6 +208,7 @@ add_memo(unsigned long sent, struct memo_account *recipient, struct memo_account
     memo->sent = sent;
     memo->message = strdup(message);
     memosSent++;
+    memoCount++;
     return memo;
 }
 
@@ -436,7 +440,7 @@ static MODCMD_FUNC(cmd_set_private)
 
 static MODCMD_FUNC(cmd_status)
 {
-    reply("MSMSG_STATUS_TOTAL", dict_size(memos));
+    reply("MSMSG_STATUS_TOTAL", memoCount);
     reply("MSMSG_STATUS_EXPIRED", memosExpired);
     reply("MSMSG_STATUS_SENT", memosSent);
     return 1;