Browse Source

Must clear Auth users in clear_chanlist

Bryan Drewery 10 years ago
parent
commit
11f56b4458
4 changed files with 23 additions and 5 deletions
  1. 19 3
      src/auth.cc
  2. 2 1
      src/auth.h
  3. 2 0
      src/chanprog.cc
  4. 0 1
      src/userrec.cc

+ 19 - 3
src/auth.cc

@@ -41,6 +41,7 @@
 
 
 bd::HashTable<bd::String, Auth*> Auth::ht_handle(10);
 bd::HashTable<bd::String, Auth*> Auth::ht_handle(10);
 bd::HashTable<bd::String, Auth*> Auth::ht_host(10);
 bd::HashTable<bd::String, Auth*> Auth::ht_host(10);
+bd::HashTable<bd::String, Auth*> Auth::ht_nick(10);
 
 
 Auth::Auth(const char *_nick, const char *_host, struct userrec *u)
 Auth::Auth(const char *_nick, const char *_host, struct userrec *u)
 {
 {
@@ -58,6 +59,7 @@ Auth::Auth(const char *_nick, const char *_host, struct userrec *u)
 
 
 
 
   ht_host[host] = this;
   ht_host[host] = this;
+  ht_nick[_nick] = this;
   if (user)
   if (user)
     ht_handle[handle] = this;
     ht_handle[handle] = this;
 
 
@@ -72,6 +74,7 @@ Auth::~Auth()
   if (user)
   if (user)
     ht_handle.remove(handle);
     ht_handle.remove(handle);
   ht_host.remove(host);
   ht_host.remove(host);
+  ht_nick.remove(nick);
 }
 }
 
 
 void Auth::MakeHash()
 void Auth::MakeHash()
@@ -120,9 +123,20 @@ static void auth_clear_users_block(const bd::String key, Auth* auth, void *param
   }
   }
 }
 }
 
 
-void Auth::NullUsers()
+void Auth::NullUsers(const char *nick)
 {
 {
-  ht_host.each(auth_clear_users_block);
+  if (nick == NULL) {
+    ht_host.each(auth_clear_users_block);
+  } else {
+    if (ht_nick.contains(nick)) {
+      Auth *auth = ht_nick[nick];
+      if (auth->user) {
+        ht_handle.remove(auth->handle);
+      }
+      auth->user = NULL;
+      auth->handle[0] = '\0';
+    }
+  }
 }
 }
 
 
 static void auth_fill_users_block(const bd::String key, Auth* auth, void* param)
 static void auth_fill_users_block(const bd::String key, Auth* auth, void* param)
@@ -143,7 +157,8 @@ static void auth_expire_block(const bd::String key, Auth* auth, void* param)
 {
 {
   if (auth->Authed() && ((now - auth->atime) >= (60 * 60))) {
   if (auth->Authed() && ((now - auth->atime) >= (60 * 60))) {
     Auth::ht_host.remove(key);
     Auth::ht_host.remove(key);
-    Auth::ht_handle.remove(key);
+    Auth::ht_nick.remove(auth->nick);
+    Auth::ht_handle.remove(auth->handle);
     delete auth;
     delete auth;
   }
   }
 }
 }
@@ -168,6 +183,7 @@ void Auth::DeleteAll()
     putlog(LOG_DEBUG, "*", STR("Removing auth entries."));
     putlog(LOG_DEBUG, "*", STR("Removing auth entries."));
     ht_host.each(auth_delete_all_block);
     ht_host.each(auth_delete_all_block);
     ht_host.clear();
     ht_host.clear();
+    ht_nick.clear();
     ht_handle.clear();
     ht_handle.clear();
   }
   }
 }
 }

+ 2 - 1
src/auth.h

@@ -26,7 +26,7 @@ class Auth {
 
 
   static Auth *Find(const char * host);
   static Auth *Find(const char * host);
   static Auth *Find(const char * handle, bool _hand);
   static Auth *Find(const char * handle, bool _hand);
-  static void NullUsers();
+  static void NullUsers(const char *nick = NULL);
   static void FillUsers();
   static void FillUsers();
   static void ExpireAuths();
   static void ExpireAuths();
   static void InitTimer();
   static void InitTimer();
@@ -45,6 +45,7 @@ class Auth {
 
 
   static bd::HashTable<bd::String, Auth*> ht_handle;
   static bd::HashTable<bd::String, Auth*> ht_handle;
   static bd::HashTable<bd::String, Auth*> ht_host;
   static bd::HashTable<bd::String, Auth*> ht_host;
+  static bd::HashTable<bd::String, Auth*> ht_nick;
 
 
   private:
   private:
   int status;
   int status;

+ 2 - 0
src/chanprog.cc

@@ -187,6 +187,8 @@ void clear_chanlist_member(const char *nick)
       }
       }
     }
     }
   }
   }
+
+  Auth::NullUsers(nick);
 }
 }
 
 
 /* If this user@host is in a channel, set it (it was null)
 /* If this user@host is in a channel, set it (it was null)

+ 0 - 1
src/userrec.cc

@@ -191,7 +191,6 @@ void clear_cached_users()
   }
   }
 
 
   if (!conf.bot->hub) {
   if (!conf.bot->hub) {
-    Auth::NullUsers();
     clear_chanlist();           /* Remove all user references from the
     clear_chanlist();           /* Remove all user references from the
                                  * channel lists.                       */
                                  * channel lists.                       */
   }
   }