]> err.no Git - varnish/commitdiff
A little bit more work on the expiry/prefetch thing.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 24 Jun 2006 22:11:55 +0000 (22:11 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 24 Jun 2006 22:11:55 +0000 (22:11 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@232 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_expire.c

index ab43a137b97d8baecc03d007e067784faea84801..733bd611a841c14f457f5f6d66b6f99eec538d2c 100644 (file)
@@ -16,6 +16,7 @@
 static pthread_t exp_thread;
 static struct binheap *exp_heap;
 static pthread_mutex_t expmtx;
+static unsigned expearly = 30;
 
 /*--------------------------------------------------------------------*/
 
@@ -40,12 +41,17 @@ exp_main(void *arg)
                time(&t);
                AZ(pthread_mutex_lock(&expmtx));
                o = binheap_root(exp_heap);
-               AZ(pthread_mutex_unlock(&expmtx));
-               if (o != NULL) {
-                       printf("Root: %p %d (%d)\n",
-                           (void*)o, o->ttl, o->ttl - t);
+               if (o == NULL || o->ttl - t > expearly) {
+                       AZ(pthread_mutex_unlock(&expmtx));
+                       if (o != NULL)
+                               printf("Root: %p %d (%d)\n",
+                                   (void*)o, o->ttl, o->ttl - t);
+                       sleep(1);
+                       continue;
                }
-               sleep(1);
+               printf("Root: %p %d (%d)\n", (void*)o, o->ttl, o->ttl - t);
+               binheap_delete(exp_heap, 0);
+               AZ(pthread_mutex_unlock(&expmtx));
        }
 
        return ("FOOBAR");