Commit 4cc41818 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Give workspaces an identifying string to aid debugging.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2183 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 4c56bf21
...@@ -90,6 +90,7 @@ enum step { ...@@ -90,6 +90,7 @@ enum step {
*/ */
struct ws { struct ws {
const char *id; /* identity */
char *s; /* (S)tart of buffer */ char *s; /* (S)tart of buffer */
char *f; /* (F)ree pointer */ char *f; /* (F)ree pointer */
char *r; /* (R)eserved length */ char *r; /* (R)eserved length */
...@@ -584,7 +585,7 @@ void ESI_Destroy(struct object *); ...@@ -584,7 +585,7 @@ void ESI_Destroy(struct object *);
/* cache_ws.c */ /* cache_ws.c */
void WS_Init(struct ws *ws, void *space, unsigned len); void WS_Init(struct ws *ws, const char *id, void *space, unsigned len);
unsigned WS_Reserve(struct ws *ws, unsigned bytes); unsigned WS_Reserve(struct ws *ws, unsigned bytes);
void WS_Release(struct ws *ws, unsigned bytes); void WS_Release(struct ws *ws, unsigned bytes);
void WS_ReleaseP(struct ws *ws, char *ptr); void WS_ReleaseP(struct ws *ws, char *ptr);
......
...@@ -147,7 +147,7 @@ VBE_new_bereq(void) ...@@ -147,7 +147,7 @@ VBE_new_bereq(void)
if (bereq == NULL) if (bereq == NULL)
return (NULL); return (NULL);
bereq->magic = BEREQ_MAGIC; bereq->magic = BEREQ_MAGIC;
WS_Init(bereq->ws, bereq + 1, len); WS_Init(bereq->ws, "bereq", bereq + 1, len);
} }
http_Setup(bereq->http, bereq->ws); http_Setup(bereq->http, bereq->ws);
return (bereq); return (bereq);
......
...@@ -278,7 +278,7 @@ Fetch(struct sess *sp) ...@@ -278,7 +278,7 @@ Fetch(struct sess *sp)
/* Set up obj's workspace */ /* Set up obj's workspace */
st = sp->obj->objstore; st = sp->obj->objstore;
WS_Init(sp->obj->ws_o, st->ptr + st->len, st->space - st->len); WS_Init(sp->obj->ws_o, "obj", st->ptr + st->len, st->space - st->len);
st->len = st->space; st->len = st->space;
WS_Assert(sp->obj->ws_o); WS_Assert(sp->obj->ws_o);
http_Setup(sp->obj->http, sp->obj->ws_o); http_Setup(sp->obj->http, sp->obj->ws_o);
......
...@@ -318,7 +318,7 @@ SES_New(const struct sockaddr *addr, unsigned len) ...@@ -318,7 +318,7 @@ SES_New(const struct sockaddr *addr, unsigned len)
sp->sockaddrlen = len; sp->sockaddrlen = len;
} }
WS_Init(sp->ws, (void *)(sm + 1), sm->workspace); WS_Init(sp->ws, "sess", (void *)(sm + 1), sm->workspace);
sp->http = &sm->http[0]; sp->http = &sm->http[0];
sp->http0 = &sm->http[1]; sp->http0 = &sm->http[1];
......
...@@ -73,7 +73,7 @@ SYN_ErrorPage(struct sess *sp, int status, const char *reason, int ttl) ...@@ -73,7 +73,7 @@ SYN_ErrorPage(struct sess *sp, int status, const char *reason, int ttl)
/* Set up obj's workspace */ /* Set up obj's workspace */
st = o->objstore; st = o->objstore;
WS_Init(o->ws_o, st->ptr + st->len, st->space - st->len); WS_Init(o->ws_o, "obj", st->ptr + st->len, st->space - st->len);
st->len = st->space; st->len = st->space;
WS_Assert(o->ws_o); WS_Assert(o->ws_o);
http_Setup(o->http, o->ws_o); http_Setup(o->http, o->ws_o);
...@@ -126,7 +126,7 @@ SYN_ErrorPage(struct sess *sp, int status, const char *reason, int ttl) ...@@ -126,7 +126,7 @@ SYN_ErrorPage(struct sess *sp, int status, const char *reason, int ttl)
/* allocate space for header */ /* allocate space for header */
WS_Init(h->ws, malloc(1024), 1024); WS_Init(h->ws, "error", malloc(1024), 1024);
/* generate header */ /* generate header */
http_ClrHeader(h); http_ClrHeader(h);
......
...@@ -57,8 +57,8 @@ WS_Assert(const struct ws *ws) ...@@ -57,8 +57,8 @@ WS_Assert(const struct ws *ws)
{ {
assert(ws != NULL); assert(ws != NULL);
WS_DEBUG((SLT_Debug, 0, "WS(%p = (%p %u %u %u)", WS_DEBUG((SLT_Debug, 0, "WS(%p = (%s, %p %u %u %u)",
ws, ws->s, pdiff(ws->s, ws->f), ws, ws->id, ws->s, pdiff(ws->s, ws->f),
ws->r == NULL ? 0 : pdiff(ws->f, ws->r), ws->r == NULL ? 0 : pdiff(ws->f, ws->r),
pdiff(ws->s, ws->e))); pdiff(ws->s, ws->e)));
assert(ws->s != NULL); assert(ws->s != NULL);
...@@ -73,15 +73,16 @@ WS_Assert(const struct ws *ws) ...@@ -73,15 +73,16 @@ WS_Assert(const struct ws *ws)
} }
void void
WS_Init(struct ws *ws, void *space, unsigned len) WS_Init(struct ws *ws, const char *id, void *space, unsigned len)
{ {
WS_DEBUG((SLT_Debug, 0, "WS_Init(%p, %p, %u)", ws, space, len)); WS_DEBUG((SLT_Debug, 0, "WS_Init(%p, \"%s\", %p, %u)", ws, id, space, len));
assert(space != NULL); assert(space != NULL);
memset(ws, 0, sizeof *ws); memset(ws, 0, sizeof *ws);
ws->s = space; ws->s = space;
ws->e = ws->s + len; ws->e = ws->s + len;
ws->f = ws->s; ws->f = ws->s;
ws->id = id;
WS_Assert(ws); WS_Assert(ws);
} }
......
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