]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Resolve assert in cacheCleanup
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 11 Apr 2010 11:29:02 +0000 (23:29 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 11 Apr 2010 11:29:02 +0000 (23:29 +1200)
src/auth/Gadgets.h
src/auth/User.cc

index 96da2c09a837421f6020d0400a3e0f4b65b8a8c1..bad1fe726d33437eed990411810a077a3109fd47 100644 (file)
@@ -46,19 +46,18 @@ class AuthUser;
  * This is used to link auth_users into the username cache.
  * Because some schemes may link in aliases to a user,
  * the link is not part of the AuthUser structure itself.
- *
- \todo Inheritance in a struct? this should be a class.
  */
-struct AuthUserHashPointer : public hash_link {
+class AuthUserHashPointer : public hash_link {
     /* first two items must be same as hash_link */
 
 public:
-    static void removeFromCache(void *anAuthUserHashPointer);
     MEMPROXY_CLASS(AuthUserHashPointer);
 
-    AuthUserHashPointer(AuthUser::Pointer );
+    AuthUserHashPointer(AuthUser::Pointer);
+    ~AuthUserHashPointer() { auth_user = NULL; };
 
     AuthUser::Pointer user() const;
+    static void removeFromCache(void *anAuthUserHashPointer);
 
 private:
     AuthUser::Pointer auth_user;
index 0b1a8d8e2aa9fea93d0aba29a0ac8646603154f5..d8732ea09f4b123a48a9e7208bf1aca4877102f9 100644 (file)
@@ -165,12 +165,9 @@ AuthUser::~AuthUser()
     assert(RefCountCount() == 0);
 
     /* were they linked in by username ? */
-
     if (usernamehash) {
-        assert(usernamehash->user() == this);
         debugs(29, 5, "AuthUser::~AuthUser: removing usernamehash entry '" << usernamehash << "'");
-        hash_remove_link(proxy_auth_username_cache,
-                         (hash_link *) usernamehash);
+        hash_remove_link(proxy_auth_username_cache, (hash_link *) usernamehash);
         /* don't free the key as we use the same user string as the auth_user
          * structure */
         delete usernamehash;
@@ -274,6 +271,9 @@ AuthUser::cacheCleanup(void *datanotused)
              * and re-using current valid credentials.
              */
             hash_remove_link(proxy_auth_username_cache, usernamehash);
+            /* resolve the circular references of AuthUserHashPointer<->AuthUser by cutting before deleting. */
+            if(auth_user->usernamehash == usernamehash)
+                auth_user->usernamehash = NULL;
             delete usernamehash;
         }
     }