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);
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);
......
......@@ -53,11 +53,11 @@ SVNID("$Id$")
#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 @@ void
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 @@ EXP_Insert(struct object *o)
(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 @@ EXP_Touch(const struct object *o)
{
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 @@ exp_timer(struct sess *sp, void *priv)
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 @@ exp_timer(struct sess *sp, void *priv)
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 @@ exp_timer(struct sess *sp, void *priv)
*/
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 @@ EXP_NukeOne(struct sess *sp)
*
*/
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 @@ EXP_NukeOne(struct sess *sp)
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);
......
......@@ -64,3 +64,8 @@ struct choice {
const char *name;
void *ptr;
};
/* Sort of hack-ish... */
struct objcore;
VTAILQ_HEAD(objcore_head, objcore);
......@@ -40,6 +40,7 @@
-esym(458, VSL_stats)
-esym(458, heritage)
-esym(458, name_key)
-esym(528, svnid)
//////////////
-passes=3
......
......@@ -81,7 +81,7 @@ STV_alloc(struct sess *sp, size_t size)
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_add(const struct stevedore *stv2, int ac, char * const *av)
*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 @@ 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[] = {
{ "file", &smf_stevedore },
{ "malloc", &sma_stevedore },
......
......@@ -29,8 +29,6 @@
* $Id$
*/
#include "vqueue.h"
struct stevedore;
struct sess;
struct iovec;
......@@ -56,6 +54,8 @@ struct stevedore {
storage_object_f *object;
storage_close_f *close;
struct objcore_head lru;
/* private fields */
void *priv;
......@@ -68,6 +68,7 @@ void STV_free(struct storage *st);
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);
......
......@@ -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
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