r4227 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Fri Sep 4 11:07:27 CEST 2009
Author: phk
Date: 2009-09-04 11:07:27 +0200 (Fri, 04 Sep 2009)
New Revision: 4227
Modified:
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/hash_slinger.h
trunk/varnish-cache/bin/varnishd/stevedore.c
trunk/varnish-cache/bin/varnishd/stevedore.h
Log:
Rename and move HSH_NewObject() to STV_NewObject(), this is a more
appropriate location for this code.
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2009-09-03 10:48:15 UTC (rev 4226)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2009-09-04 09:07:27 UTC (rev 4227)
@@ -77,6 +77,7 @@
#include "cli_priv.h"
#include "cache.h"
#include "hash_slinger.h"
+#include "stevedore.h"
static unsigned xids;
@@ -334,7 +335,7 @@
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 @@
* 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);
Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2009-09-03 10:48:15 UTC (rev 4226)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2009-09-04 09:07:27 UTC (rev 4227)
@@ -81,51 +81,6 @@
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.
Modified: trunk/varnish-cache/bin/varnishd/hash_slinger.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_slinger.h 2009-09-03 10:48:15 UTC (rev 4226)
+++ trunk/varnish-cache/bin/varnishd/hash_slinger.h 2009-09-04 09:07:27 UTC (rev 4227)
@@ -50,7 +50,6 @@
};
/* 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);
Modified: trunk/varnish-cache/bin/varnishd/stevedore.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.c 2009-09-03 10:48:15 UTC (rev 4226)
+++ trunk/varnish-cache/bin/varnishd/stevedore.c 2009-09-04 09:07:27 UTC (rev 4227)
@@ -34,6 +34,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include "cache.h"
#include "stevedore.h"
@@ -66,6 +67,53 @@
/*********************************************************************/
+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)
{
Modified: trunk/varnish-cache/bin/varnishd/stevedore.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.h 2009-09-03 10:48:15 UTC (rev 4226)
+++ trunk/varnish-cache/bin/varnishd/stevedore.h 2009-09-04 09:07:27 UTC (rev 4227)
@@ -63,6 +63,7 @@
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);
More information about the varnish-commit
mailing list