From: phk Date: Sat, 24 Jun 2006 22:11:55 +0000 (+0000) Subject: A little bit more work on the expiry/prefetch thing. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3e442bae36cb2bee6763acde3ae4482846fda4c;p=varnish A little bit more work on the expiry/prefetch thing. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@232 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_expire.c b/varnish-cache/bin/varnishd/cache_expire.c index ab43a137..733bd611 100644 --- a/varnish-cache/bin/varnishd/cache_expire.c +++ b/varnish-cache/bin/varnishd/cache_expire.c @@ -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");