]> err.no Git - varnish/commitdiff
Resolve the remove/lookup race the simple way.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 3 Dec 2008 16:40:45 +0000 (16:40 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 3 Dec 2008 16:40:45 +0000 (16:40 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3456 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/hash_critbit.c

index f798649271e4835fcbf788e0203c077de1233e4c..a328dc268754f7b629bbece947992f490e48a377 100644 (file)
@@ -364,6 +364,7 @@ static struct objhead *
 hcb_lookup(const struct sess *sp, struct objhead *noh)
 {
        struct objhead *oh;
+       unsigned u;
        
        assert(params->hash_sha256);
        oh =  hcb_insert(&hcb_root, noh, 0);
@@ -371,14 +372,14 @@ hcb_lookup(const struct sess *sp, struct objhead *noh)
                /* Assert that we didn't muck with the tree without lock */
                assert(oh != noh);
                Lck_Lock(&oh->mtx);
-               oh->refcnt++;
+               u = oh->refcnt;
+               if (u)
+                       oh->refcnt++;
                Lck_Unlock(&oh->mtx);
-               VSL_stats->hcb_nolock++;
-               if (0) {
-                       fprintf(stderr, "%s %d\n", __func__, __LINE__);
-                       dump(&hcb_root, stderr);
+               if (u) {
+                       VSL_stats->hcb_nolock++;
+                       return (oh);
                }
-               return (oh);
        }
 
        /*