Commit 56c66bb9 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Various minor cleanups while we wait...



git-svn-id: http://www.varnish-cache.org/svn/trunk@3450 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 0763b32a
...@@ -509,7 +509,7 @@ void Lck__Lock(struct lock *lck, const char *p, const char *f, int l); ...@@ -509,7 +509,7 @@ void Lck__Lock(struct lock *lck, const char *p, const char *f, int l);
void Lck__Unlock(struct lock *lck, const char *p, const char *f, int l); void Lck__Unlock(struct lock *lck, const char *p, const char *f, int l);
int Lck__Trylock(struct lock *lck, const char *p, const char *f, int l); int Lck__Trylock(struct lock *lck, const char *p, const char *f, int l);
void Lck__New(struct lock *lck, const char *w); void Lck__New(struct lock *lck, const char *w);
void Lck__Assert(struct lock *lck, int held); void Lck__Assert(const struct lock *lck, int held);
/* public interface: */ /* public interface: */
void LCK_Init(void); void LCK_Init(void);
......
...@@ -83,6 +83,8 @@ void ...@@ -83,6 +83,8 @@ void
HSH_Prealloc(struct sess *sp) HSH_Prealloc(struct sess *sp)
{ {
struct worker *w; struct worker *w;
struct objhead *oh;
struct object *o;
struct storage *st; struct storage *st;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
...@@ -90,47 +92,39 @@ HSH_Prealloc(struct sess *sp) ...@@ -90,47 +92,39 @@ HSH_Prealloc(struct sess *sp)
w = sp->wrk; w = sp->wrk;
if (w->nobjhead == NULL) { if (w->nobjhead == NULL) {
w->nobjhead = calloc(sizeof *w->nobjhead, 1); ALLOC_OBJ(oh, OBJHEAD_MAGIC);
XXXAN(w->nobjhead); XXXAN(oh);
w->nobjhead->magic = OBJHEAD_MAGIC; oh->refcnt = 1;
w->nobjhead->refcnt = 1; VTAILQ_INIT(&oh->objects);
VTAILQ_INIT(&w->nobjhead->objects); VTAILQ_INIT(&oh->waitinglist);
VTAILQ_INIT(&w->nobjhead->waitinglist); Lck_New(&oh->mtx);
Lck_New(&w->nobjhead->mtx); w->nobjhead = oh;
VSL_stats->n_objecthead++; VSL_stats->n_objecthead++;
} else } else
CHECK_OBJ_NOTNULL(w->nobjhead, OBJHEAD_MAGIC); CHECK_OBJ_NOTNULL(w->nobjhead, OBJHEAD_MAGIC);
#if 0
/* Make sure there is space enough for the hash-string */
if (w->nobjhead->hashlen < sp->lhashptr) {
w->objhead->hash = realloc(w->objhead->hash, sp->lhashptr);
w->objhead->hashlen = sp->lhashptr;
AN(w->objhead->hash);
}
#endif
if (w->nobj == NULL) { if (w->nobj == NULL) {
st = STV_alloc(sp, params->obj_workspace); st = STV_alloc(sp, params->obj_workspace);
XXXAN(st); XXXAN(st);
assert(st->space > sizeof *w->nobj); assert(st->space > sizeof *w->nobj);
w->nobj = (void *)st->ptr; /* XXX: align ? */ o = (void *)st->ptr; /* XXX: align ? */
st->len = sizeof *w->nobj; st->len = sizeof *o;
memset(w->nobj, 0, sizeof *w->nobj); memset(o, 0, sizeof *o);
w->nobj->objstore = st; o->objstore = st;
WS_Init(w->nobj->ws_o, "obj", WS_Init(o->ws_o, "obj",
st->ptr + st->len, st->space - st->len); st->ptr + st->len, st->space - st->len);
st->len = st->space; st->len = st->space;
WS_Assert(w->nobj->ws_o); WS_Assert(o->ws_o);
http_Setup(w->nobj->http, w->nobj->ws_o); http_Setup(o->http, o->ws_o);
w->nobj->magic = OBJECT_MAGIC; o->magic = OBJECT_MAGIC;
w->nobj->http->magic = HTTP_MAGIC; o->http->magic = HTTP_MAGIC;
w->nobj->busy = 1; o->busy = 1;
w->nobj->refcnt = 1; o->refcnt = 1;
w->nobj->grace = NAN; o->grace = NAN;
w->nobj->entered = NAN; o->entered = NAN;
VTAILQ_INIT(&w->nobj->store); VTAILQ_INIT(&o->store);
VTAILQ_INIT(&w->nobj->esibits); VTAILQ_INIT(&o->esibits);
w->nobj = o;
VSL_stats->n_object++; VSL_stats->n_object++;
} else } else
......
...@@ -125,7 +125,7 @@ Lck__Trylock(struct lock *lck, const char *p, const char *f, int l) ...@@ -125,7 +125,7 @@ Lck__Trylock(struct lock *lck, const char *p, const char *f, int l)
} }
void void
Lck__Assert(struct lock *lck, int held) Lck__Assert(const struct lock *lck, int held)
{ {
struct ilck *ilck; struct ilck *ilck;
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#include "shmlog.h" #include "shmlog.h"
#include "vrt.h" #include "vrt.h"
#include "vsb.h"
#include "vcl.h" #include "vcl.h"
#include "cache.h" #include "cache.h"
......
...@@ -124,7 +124,7 @@ hcl_lookup(const struct sess *sp, struct objhead *noh) ...@@ -124,7 +124,7 @@ hcl_lookup(const struct sess *sp, struct objhead *noh)
int i; int i;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_ORNULL(noh, OBJHEAD_MAGIC); CHECK_OBJ_NOTNULL(noh, OBJHEAD_MAGIC);
digest = ~0U; digest = ~0U;
for (u = 0; u < sp->ihashptr; u += 2) { for (u = 0; u < sp->ihashptr; u += 2) {
......
...@@ -71,6 +71,8 @@ hsl_lookup(const struct sess *sp, struct objhead *noh) ...@@ -71,6 +71,8 @@ hsl_lookup(const struct sess *sp, struct objhead *noh)
struct objhead *oh; struct objhead *oh;
int i; int i;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(noh, OBJHEAD_MAGIC);
Lck_Lock(&hsl_mtx); Lck_Lock(&hsl_mtx);
VTAILQ_FOREACH(oh, &hsl_head, hoh_list) { VTAILQ_FOREACH(oh, &hsl_head, hoh_list) {
i = HSH_Compare(sp, oh); i = HSH_Compare(sp, oh);
......
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