r4102 - in trunk/varnish-cache: bin/varnishd include

phk at projects.linpro.no phk at projects.linpro.no
Wed Jun 10 11:45:20 CEST 2009


Author: phk
Date: 2009-06-10 11:45:20 +0200 (Wed, 10 Jun 2009)
New Revision: 4102

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_expire.c
   trunk/varnish-cache/bin/varnishd/common.h
   trunk/varnish-cache/bin/varnishd/flint.lnt
   trunk/varnish-cache/bin/varnishd/stevedore.c
   trunk/varnish-cache/bin/varnishd/stevedore.h
   trunk/varnish-cache/include/svnid.h
Log:
Properly constify svnid



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2009-06-10 09:20:20 UTC (rev 4101)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2009-06-10 09:45:20 UTC (rev 4102)
@@ -490,7 +490,7 @@
 void EXP_Init(void);
 void EXP_Rearm(const struct object *o);
 int EXP_Touch(const struct object *o);
-int EXP_NukeOne(struct sess *sp);
+int EXP_NukeOne(struct sess *sp, struct objcore_head *lru);
 
 /* cache_fetch.c */
 int FetchHdr(struct sess *sp);

Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c	2009-06-10 09:20:20 UTC (rev 4101)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c	2009-06-10 09:45:20 UTC (rev 4102)
@@ -53,11 +53,11 @@
 #include "cache.h"
 #include "vcl.h"
 #include "hash_slinger.h"
+#include "stevedore.h"
 
 static pthread_t exp_thread;
 static struct binheap *exp_heap;
 static struct lock exp_mtx;
-static VTAILQ_HEAD(,objcore) lru = VTAILQ_HEAD_INITIALIZER(lru);
 
 /*
  * This is a magic marker for the objects currently on the SIOP [look it up]
@@ -100,6 +100,7 @@
 EXP_Insert(struct object *o)
 {
 	struct objcore *oc;
+	struct objcore_head *lru;
 
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	AN(o->objhead);
@@ -116,8 +117,11 @@
 	(void)update_object_when(o);
 	binheap_insert(exp_heap, oc);
 	assert(oc->timer_idx != BINHEAP_NOIDX);
-	VTAILQ_INSERT_TAIL(&lru, oc, lru_list);
-	oc->flags |= OC_F_ONLRU;
+	lru = STV_lru(o->objstore);
+	if (lru != NULL) {
+		VTAILQ_INSERT_TAIL(lru, oc, lru_list);
+		oc->flags |= OC_F_ONLRU;
+	}
 	Lck_Unlock(&exp_mtx);
 	if (o->smp_object != NULL)
 		SMP_TTLchanged(o);
@@ -137,18 +141,22 @@
 {
 	struct objcore *oc;
 	int retval = 0;
+	struct objcore_head *lru;
 
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	oc = o->objcore;
 	if (oc == NULL)
 		return (retval);
+	lru = STV_lru(o->objstore);
+	if (lru == NULL)
+		return (retval);
 	AN(o->objhead);
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	if (Lck_Trylock(&exp_mtx))
 		return (retval);
 	if (oc->flags & OC_F_ONLRU) {
-		VTAILQ_REMOVE(&lru, oc, lru_list);
-		VTAILQ_INSERT_TAIL(&lru, oc, lru_list);
+		VTAILQ_REMOVE(lru, oc, lru_list);
+		VTAILQ_INSERT_TAIL(lru, oc, lru_list);
 		VSL_stats->n_lru_moved++;
 		retval = 1;
 	}
@@ -211,6 +219,7 @@
 	struct objcore *oc;
 	struct object *o;
 	double t;
+	struct objcore_head *lru;
 
 	(void)priv;
 	AZ(sleep(10));		/* XXX: Takes time for VCL to arrive */
@@ -237,7 +246,9 @@
 		assert(oc->timer_idx != BINHEAP_NOIDX);
 		binheap_delete(exp_heap, oc->timer_idx);
 		assert(oc->timer_idx == BINHEAP_NOIDX);
-		VTAILQ_REMOVE(&lru, o->objcore, lru_list);
+		lru = STV_lru(o->objstore);
+		AN(lru);
+		VTAILQ_REMOVE(lru, o->objcore, lru_list);
 		oc->flags &= ~OC_F_ONLRU;
 
 		{	/* Sanity checking */
@@ -263,7 +274,7 @@
  */
 
 int
-EXP_NukeOne(struct sess *sp)
+EXP_NukeOne(struct sess *sp, struct objcore_head *lru)
 {
 	struct objcore *oc;
 	struct object *o;
@@ -279,7 +290,7 @@
 	 *
 	 */
 	Lck_Lock(&exp_mtx);
-	VTAILQ_FOREACH(oc, &lru, lru_list) {
+	VTAILQ_FOREACH(oc, lru, lru_list) {
 		CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 		if (oc->timer_idx == BINHEAP_NOIDX)	/* exp_timer has it */
 			continue;
@@ -287,7 +298,7 @@
 			break;
 	}
 	if (oc != NULL) {
-		VTAILQ_REMOVE(&lru, oc, lru_list);
+		VTAILQ_REMOVE(lru, oc, lru_list);
 		oc->flags &= ~OC_F_ONLRU;
 		binheap_delete(exp_heap, oc->timer_idx);
 		assert(oc->timer_idx == BINHEAP_NOIDX);

Modified: trunk/varnish-cache/bin/varnishd/common.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/common.h	2009-06-10 09:20:20 UTC (rev 4101)
+++ trunk/varnish-cache/bin/varnishd/common.h	2009-06-10 09:45:20 UTC (rev 4102)
@@ -64,3 +64,8 @@
 	const char      *name;
 	void            *ptr;
 };
+
+/* Sort of hack-ish... */
+struct objcore;
+VTAILQ_HEAD(objcore_head, objcore);
+

Modified: trunk/varnish-cache/bin/varnishd/flint.lnt
===================================================================
--- trunk/varnish-cache/bin/varnishd/flint.lnt	2009-06-10 09:20:20 UTC (rev 4101)
+++ trunk/varnish-cache/bin/varnishd/flint.lnt	2009-06-10 09:45:20 UTC (rev 4102)
@@ -40,6 +40,7 @@
 -esym(458, VSL_stats)
 -esym(458, heritage)
 -esym(458, name_key)
+-esym(528, svnid)
 //////////////
 -passes=3
 

Modified: trunk/varnish-cache/bin/varnishd/stevedore.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.c	2009-06-10 09:20:20 UTC (rev 4101)
+++ trunk/varnish-cache/bin/varnishd/stevedore.c	2009-06-10 09:45:20 UTC (rev 4102)
@@ -81,7 +81,7 @@
 			break;
 
 		/* no luck; try to free some space and keep trying */
-		if (EXP_NukeOne(sp) == -1)
+		if (EXP_NukeOne(sp, &stv->lru) == -1)
 			break;
 
 		/* Enough is enough: try another if we have one */
@@ -124,6 +124,7 @@
 	*stv = *stv2;
 	AN(stv->name);
 	AN(stv->alloc);
+	VTAILQ_INIT(&stv->lru);
 
 	if (stv->init != NULL)
 		stv->init(stv, ac, av);
@@ -158,6 +159,16 @@
 	}
 }
 
+struct objcore_head *
+STV_lru(struct storage *st)
+{
+	if (st == NULL)
+		return (NULL);
+	CHECK_OBJ(st, STORAGE_MAGIC);
+
+	return (&st->stevedore->lru);
+}
+
 const struct choice STV_choice[] = {
 	{ "file",	&smf_stevedore },
 	{ "malloc",	&sma_stevedore },

Modified: trunk/varnish-cache/bin/varnishd/stevedore.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.h	2009-06-10 09:20:20 UTC (rev 4101)
+++ trunk/varnish-cache/bin/varnishd/stevedore.h	2009-06-10 09:45:20 UTC (rev 4102)
@@ -29,8 +29,6 @@
  * $Id$
  */
 
-#include "vqueue.h"
-
 struct stevedore;
 struct sess;
 struct iovec;
@@ -56,6 +54,8 @@
 	storage_object_f	*object;
 	storage_close_f		*close;
 
+	struct objcore_head	lru;
+
 	/* private fields */
 	void			*priv;
 
@@ -68,6 +68,7 @@
 void STV_add(const struct stevedore *stv, int ac, char * const *av);
 void STV_open(void);
 void STV_close(void);
+struct objcore_head *STV_lru(struct storage *st);
 
 int STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx);
 uintmax_t STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx);

Modified: trunk/varnish-cache/include/svnid.h
===================================================================
--- trunk/varnish-cache/include/svnid.h	2009-06-10 09:20:20 UTC (rev 4101)
+++ trunk/varnish-cache/include/svnid.h	2009-06-10 09:45:20 UTC (rev 4102)
@@ -31,6 +31,6 @@
 #define SVNID_H_INCLUDED
 
 #define SVNID(id) \
-	static const char *svnid __attribute__((__unused__)) = id;
+	static const char * const svnid __attribute__((__unused__)) = id;
 
 #endif



More information about the varnish-commit mailing list