Commit c4b1e714 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Rename and move HSH_NewObject() to STV_NewObject(), this is a more

appropriate location for this code.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4227 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 6063e24b
......@@ -77,6 +77,7 @@ SVNID("$Id$")
#include "cli_priv.h"
#include "cache.h"
#include "hash_slinger.h"
#include "stevedore.h"
static unsigned xids;
......@@ -334,7 +335,7 @@ cnt_error(struct sess *sp)
if (sp->obj == NULL) {
HSH_Prealloc(sp);
sp->wrk->cacheable = 0;
sp->obj = HSH_NewObject(sp, 0);
sp->obj = STV_NewObject(sp, 0);
sp->obj->xid = sp->xid;
sp->obj->entered = sp->t_req;
} else {
......@@ -525,7 +526,7 @@ cnt_fetch(struct sess *sp)
* XXX: If we have a Length: header, we should allocate the body
* XXX: also.
*/
sp->obj = HSH_NewObject(sp, l);
sp->obj = STV_NewObject(sp, l);
if (sp->objhead != NULL) {
CHECK_OBJ_NOTNULL(sp->objhead, OBJHEAD_MAGIC);
......
......@@ -81,51 +81,6 @@ HSH_Grace(double g)
return (g);
}
struct object *
HSH_NewObject(struct sess *sp, unsigned l)
{
struct object *o;
struct storage *st;
void *p;
if (l == 0)
l = 1024;
if (params->obj_workspace > 0 && params->obj_workspace > l)
l = params->obj_workspace;
if (!sp->wrk->cacheable) {
p = malloc(sizeof *o + l);
XXXAN(p);
o = p;
p = o + 1;
memset(o, 0, sizeof *o);
o->magic = OBJECT_MAGIC;
WS_Init(o->ws_o, "obj", p, l);
} else {
st = STV_alloc(sp, sizeof *o + l);
XXXAN(st);
assert(st->space > sizeof *o);
o = (void *)st->ptr; /* XXX: align ? */
st->len = sizeof *o;
memset(o, 0, sizeof *o);
o->magic = OBJECT_MAGIC;
o->objstore = st;
WS_Init(o->ws_o, "obj",
st->ptr + st->len, st->space - st->len);
st->len = st->space;
}
WS_Assert(o->ws_o);
http_Setup(o->http, o->ws_o);
o->http->magic = HTTP_MAGIC;
o->refcnt = 1;
o->grace = NAN;
o->entered = NAN;
VTAILQ_INIT(&o->store);
VTAILQ_INIT(&o->esibits);
sp->wrk->stats.n_object++;
return (o);
}
/*
* XXX: this should vector through stevedore.c instead of calling the
* XXX: member function directly.
......
......@@ -50,7 +50,6 @@ struct hash_slinger {
};
/* cache_hash.c */
struct object *HSH_NewObject(struct sess *sp, unsigned len);
void HSH_Object(const struct sess *sp);
void HSH_Prealloc(const struct sess *sp);
void HSH_Cleanup(struct worker *w);
......
......@@ -34,6 +34,7 @@ SVNID("$Id$")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "cache.h"
#include "stevedore.h"
......@@ -66,6 +67,53 @@ LRU_Alloc(void)
/*********************************************************************/
struct object *
STV_NewObject(struct sess *sp, unsigned l)
{
struct object *o;
struct storage *st;
void *p;
if (l == 0)
l = 1024;
if (params->obj_workspace > 0 && params->obj_workspace > l)
l = params->obj_workspace;
if (!sp->wrk->cacheable) {
p = malloc(sizeof *o + l);
XXXAN(p);
o = p;
p = o + 1;
memset(o, 0, sizeof *o);
o->magic = OBJECT_MAGIC;
WS_Init(o->ws_o, "obj", p, l);
} else {
st = STV_alloc(sp, sizeof *o + l);
XXXAN(st);
assert(st->space > sizeof *o);
o = (void *)st->ptr; /* XXX: align ? */
st->len = sizeof *o;
memset(o, 0, sizeof *o);
o->magic = OBJECT_MAGIC;
o->objstore = st;
WS_Init(o->ws_o, "obj",
st->ptr + st->len, st->space - st->len);
st->len = st->space;
}
WS_Assert(o->ws_o);
http_Setup(o->http, o->ws_o);
o->http->magic = HTTP_MAGIC;
o->refcnt = 1;
o->grace = NAN;
o->entered = NAN;
VTAILQ_INIT(&o->store);
VTAILQ_INIT(&o->esibits);
sp->wrk->stats.n_object++;
return (o);
}
/*********************************************************************/
struct storage *
STV_alloc(struct sess *sp, size_t size)
{
......
......@@ -63,6 +63,7 @@ struct stevedore {
VTAILQ_ENTRY(stevedore) list;
};
struct object *STV_NewObject(struct sess *sp, unsigned len);
struct storage *STV_alloc(struct sess *sp, size_t size);
void STV_trim(struct storage *st, size_t size);
void STV_free(struct storage *st);
......
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