]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanserv/database/chanservdb_hash.c
fix bug in G stats
[irc/quakenet/newserv.git] / chanserv / database / chanservdb_hash.c
index d06b7210a8ec0a6a2e4792104b799dd3f29a10b1..34ab783ce5e6cc1c291394749d1fa6a081952b0b 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <string.h>
+#include <strings.h>
 
 #include "../chanserv.h"
 #include "../../lib/irc_string.h"
@@ -34,7 +35,7 @@ void addregusertohash(reguser *rup) {
   rup->nextbyname=regusernicktable[hash];
   regusernicktable[hash]=rup;
 
-  anp=findorcreateauthname(rup->ID);
+  anp=findorcreateauthname(rup->ID, rup->username);
   anp->exts[chanservaext]=rup;
 }
 
@@ -214,7 +215,7 @@ maildomain *findnearestmaildomain(char *domain) {
   if(!m && (p=strchr(domain, '.')))
     return findnearestmaildomain(++p);
 
-  return NULL;
+  return m;
 }
 
 maildomain *findmaildomainbyemail(char *email) {
@@ -315,7 +316,7 @@ void addregusertomaildomain(reguser *rup, maildomain *mdp) {
 }
 
 void delreguserfrommaildomain(reguser *rup, maildomain *mdp) {
-  maildomain *smdp;
+  maildomain *smdp, *nmdp;
   reguser *ruh, *pruh=NULL;
   int found=0;
 
@@ -341,16 +342,21 @@ void delreguserfrommaildomain(reguser *rup, maildomain *mdp) {
     return;
   }
 
-  for(smdp=mdp;smdp;smdp=smdp->parent) {
-    smdp->count--;
+  /* Free it from all the parent domains, cleaning up as we go.. */
+  for(smdp=mdp;smdp;smdp=nmdp) {
+    nmdp=smdp->parent;
+
+    /* Keep it if there are users left or we're remembering something about it. */    
+    if (--smdp->count || (smdp->flags != MDFLAG_DEFAULT) || (smdp->actlimit != MD_DEFAULTACTLIMIT))
+      continue;
+    
+    removemaildomainfromhash(smdp);
+    freesstring(smdp->name);
+    freemaildomain(smdp);
   }
+
   rup->domain=NULL;
   freesstring(rup->localpart);
   rup->localpart=NULL;
-
-  if (!mdp->count && !MDHasLimit(mdp)) {
-    removemaildomainfromhash(mdp);
-    freemaildomain(mdp);
-  }
 }