Commit 0357f361 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Properly constify svnid



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4102 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 64948654
...@@ -490,7 +490,7 @@ void EXP_Insert(struct object *o); ...@@ -490,7 +490,7 @@ void EXP_Insert(struct object *o);
void EXP_Init(void); void EXP_Init(void);
void EXP_Rearm(const struct object *o); void EXP_Rearm(const struct object *o);
int EXP_Touch(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 */ /* cache_fetch.c */
int FetchHdr(struct sess *sp); int FetchHdr(struct sess *sp);
......
...@@ -53,11 +53,11 @@ SVNID("$Id$") ...@@ -53,11 +53,11 @@ SVNID("$Id$")
#include "cache.h" #include "cache.h"
#include "vcl.h" #include "vcl.h"
#include "hash_slinger.h" #include "hash_slinger.h"
#include "stevedore.h"
static pthread_t exp_thread; static pthread_t exp_thread;
static struct binheap *exp_heap; static struct binheap *exp_heap;
static struct lock exp_mtx; 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] * This is a magic marker for the objects currently on the SIOP [look it up]
...@@ -100,6 +100,7 @@ void ...@@ -100,6 +100,7 @@ void
EXP_Insert(struct object *o) EXP_Insert(struct object *o)
{ {
struct objcore *oc; struct objcore *oc;
struct objcore_head *lru;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
AN(o->objhead); AN(o->objhead);
...@@ -116,8 +117,11 @@ EXP_Insert(struct object *o) ...@@ -116,8 +117,11 @@ EXP_Insert(struct object *o)
(void)update_object_when(o); (void)update_object_when(o);
binheap_insert(exp_heap, oc); binheap_insert(exp_heap, oc);
assert(oc->timer_idx != BINHEAP_NOIDX); assert(oc->timer_idx != BINHEAP_NOIDX);
VTAILQ_INSERT_TAIL(&lru, oc, lru_list); lru = STV_lru(o->objstore);
oc->flags |= OC_F_ONLRU; if (lru != NULL) {
VTAILQ_INSERT_TAIL(lru, oc, lru_list);
oc->flags |= OC_F_ONLRU;
}
Lck_Unlock(&exp_mtx); Lck_Unlock(&exp_mtx);
if (o->smp_object != NULL) if (o->smp_object != NULL)
SMP_TTLchanged(o); SMP_TTLchanged(o);
...@@ -137,18 +141,22 @@ EXP_Touch(const struct object *o) ...@@ -137,18 +141,22 @@ EXP_Touch(const struct object *o)
{ {
struct objcore *oc; struct objcore *oc;
int retval = 0; int retval = 0;
struct objcore_head *lru;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
oc = o->objcore; oc = o->objcore;
if (oc == NULL) if (oc == NULL)
return (retval); return (retval);
lru = STV_lru(o->objstore);
if (lru == NULL)
return (retval);
AN(o->objhead); AN(o->objhead);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
if (Lck_Trylock(&exp_mtx)) if (Lck_Trylock(&exp_mtx))
return (retval); return (retval);
if (oc->flags & OC_F_ONLRU) { if (oc->flags & OC_F_ONLRU) {
VTAILQ_REMOVE(&lru, oc, lru_list); VTAILQ_REMOVE(lru, oc, lru_list);
VTAILQ_INSERT_TAIL(&lru, oc, lru_list); VTAILQ_INSERT_TAIL(lru, oc, lru_list);
VSL_stats->n_lru_moved++; VSL_stats->n_lru_moved++;
retval = 1; retval = 1;
} }
...@@ -211,6 +219,7 @@ exp_timer(struct sess *sp, void *priv) ...@@ -211,6 +219,7 @@ exp_timer(struct sess *sp, void *priv)
struct objcore *oc; struct objcore *oc;
struct object *o; struct object *o;
double t; double t;
struct objcore_head *lru;
(void)priv; (void)priv;
AZ(sleep(10)); /* XXX: Takes time for VCL to arrive */ AZ(sleep(10)); /* XXX: Takes time for VCL to arrive */
...@@ -237,7 +246,9 @@ exp_timer(struct sess *sp, void *priv) ...@@ -237,7 +246,9 @@ exp_timer(struct sess *sp, void *priv)
assert(oc->timer_idx != BINHEAP_NOIDX); assert(oc->timer_idx != BINHEAP_NOIDX);
binheap_delete(exp_heap, oc->timer_idx); binheap_delete(exp_heap, oc->timer_idx);
assert(oc->timer_idx == BINHEAP_NOIDX); 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; oc->flags &= ~OC_F_ONLRU;
{ /* Sanity checking */ { /* Sanity checking */
...@@ -263,7 +274,7 @@ exp_timer(struct sess *sp, void *priv) ...@@ -263,7 +274,7 @@ exp_timer(struct sess *sp, void *priv)
*/ */
int int
EXP_NukeOne(struct sess *sp) EXP_NukeOne(struct sess *sp, struct objcore_head *lru)
{ {
struct objcore *oc; struct objcore *oc;
struct object *o; struct object *o;
...@@ -279,7 +290,7 @@ EXP_NukeOne(struct sess *sp) ...@@ -279,7 +290,7 @@ EXP_NukeOne(struct sess *sp)
* *
*/ */
Lck_Lock(&exp_mtx); Lck_Lock(&exp_mtx);
VTAILQ_FOREACH(oc, &lru, lru_list) { VTAILQ_FOREACH(oc, lru, lru_list) {
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
if (oc->timer_idx == BINHEAP_NOIDX) /* exp_timer has it */ if (oc->timer_idx == BINHEAP_NOIDX) /* exp_timer has it */
continue; continue;
...@@ -287,7 +298,7 @@ EXP_NukeOne(struct sess *sp) ...@@ -287,7 +298,7 @@ EXP_NukeOne(struct sess *sp)
break; break;
} }
if (oc != NULL) { if (oc != NULL) {
VTAILQ_REMOVE(&lru, oc, lru_list); VTAILQ_REMOVE(lru, oc, lru_list);
oc->flags &= ~OC_F_ONLRU; oc->flags &= ~OC_F_ONLRU;
binheap_delete(exp_heap, oc->timer_idx); binheap_delete(exp_heap, oc->timer_idx);
assert(oc->timer_idx == BINHEAP_NOIDX); assert(oc->timer_idx == BINHEAP_NOIDX);
......
...@@ -64,3 +64,8 @@ struct choice { ...@@ -64,3 +64,8 @@ struct choice {
const char *name; const char *name;
void *ptr; void *ptr;
}; };
/* Sort of hack-ish... */
struct objcore;
VTAILQ_HEAD(objcore_head, objcore);
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
-esym(458, VSL_stats) -esym(458, VSL_stats)
-esym(458, heritage) -esym(458, heritage)
-esym(458, name_key) -esym(458, name_key)
-esym(528, svnid)
////////////// //////////////
-passes=3 -passes=3
......
...@@ -81,7 +81,7 @@ STV_alloc(struct sess *sp, size_t size) ...@@ -81,7 +81,7 @@ STV_alloc(struct sess *sp, size_t size)
break; break;
/* no luck; try to free some space and keep trying */ /* no luck; try to free some space and keep trying */
if (EXP_NukeOne(sp) == -1) if (EXP_NukeOne(sp, &stv->lru) == -1)
break; break;
/* Enough is enough: try another if we have one */ /* Enough is enough: try another if we have one */
...@@ -124,6 +124,7 @@ STV_add(const struct stevedore *stv2, int ac, char * const *av) ...@@ -124,6 +124,7 @@ STV_add(const struct stevedore *stv2, int ac, char * const *av)
*stv = *stv2; *stv = *stv2;
AN(stv->name); AN(stv->name);
AN(stv->alloc); AN(stv->alloc);
VTAILQ_INIT(&stv->lru);
if (stv->init != NULL) if (stv->init != NULL)
stv->init(stv, ac, av); stv->init(stv, ac, av);
...@@ -158,6 +159,16 @@ STV_close(void) ...@@ -158,6 +159,16 @@ STV_close(void)
} }
} }
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[] = { const struct choice STV_choice[] = {
{ "file", &smf_stevedore }, { "file", &smf_stevedore },
{ "malloc", &sma_stevedore }, { "malloc", &sma_stevedore },
......
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
* $Id$ * $Id$
*/ */
#include "vqueue.h"
struct stevedore; struct stevedore;
struct sess; struct sess;
struct iovec; struct iovec;
...@@ -56,6 +54,8 @@ struct stevedore { ...@@ -56,6 +54,8 @@ struct stevedore {
storage_object_f *object; storage_object_f *object;
storage_close_f *close; storage_close_f *close;
struct objcore_head lru;
/* private fields */ /* private fields */
void *priv; void *priv;
...@@ -68,6 +68,7 @@ void STV_free(struct storage *st); ...@@ -68,6 +68,7 @@ void STV_free(struct storage *st);
void STV_add(const struct stevedore *stv, int ac, char * const *av); void STV_add(const struct stevedore *stv, int ac, char * const *av);
void STV_open(void); void STV_open(void);
void STV_close(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); 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); uintmax_t STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx);
......
...@@ -31,6 +31,6 @@ ...@@ -31,6 +31,6 @@
#define SVNID_H_INCLUDED #define SVNID_H_INCLUDED
#define SVNID(id) \ #define SVNID(id) \
static const char *svnid __attribute__((__unused__)) = id; static const char * const svnid __attribute__((__unused__)) = id;
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment