Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Varnish: Commits

[master] 59c6ae4 Join struct vbo and struct busyobj

 

 

Varnish commits RSS feed   Index | Next | Previous | View Threaded


phk at varnish-cache

Mar 12, 2012, 1:58 AM

Post #1 of 1 (78 views)
Permalink
[master] 59c6ae4 Join struct vbo and struct busyobj

commit 59c6ae45f801a0f447d9f9647f2963950083c696
Author: Poul-Henning Kamp <phk [at] FreeBSD>
Date: Mon Mar 12 08:57:38 2012 +0000

Join struct vbo and struct busyobj

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 2bae6b4..48bdac0 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -108,7 +108,6 @@ struct poolparam;
struct sess;
struct sesspool;
struct vbc;
-struct vbo;
struct vef_priv;
struct vrt_backend;
struct vsb;
@@ -298,7 +297,7 @@ struct worker {
struct objhead *nobjhead;
struct objcore *nobjcore;
struct waitinglist *nwaitinglist;
- struct vbo *nvbo;
+ struct busyobj *nbo;
void *nhashpriv;
struct dstat stats;

@@ -459,7 +458,14 @@ enum busyobj_state_e {
struct busyobj {
unsigned magic;
#define BUSYOBJ_MAGIC 0x23b95567
- struct vbo *vbo;
+ struct lock mtx;
+ char *end;
+
+ /*
+ * All fields from refcount and down are zeroed when the busyobj
+ * is recycled.
+ */
+ unsigned refcount;

uint8_t *vary;
unsigned is_gzip;
@@ -479,7 +485,7 @@ struct busyobj {
struct http_conn htc;

enum body_status body_status;
- struct pool_task task;
+ struct pool_task fetch_task;

struct vef_priv *vef_priv;

@@ -721,7 +727,7 @@ void VBO_Init(void);
struct busyobj *VBO_GetBusyObj(struct worker *wrk);
void VBO_RefBusyObj(const struct busyobj *busyobj);
void VBO_DerefBusyObj(struct worker *wrk, struct busyobj **busyobj);
-void VBO_Free(struct vbo **vbo);
+void VBO_Free(struct busyobj **vbo);

/* cache_center.c [CNT] */
void CNT_Session(struct sess *sp);
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index 32ae7c8..601272f 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -40,15 +40,6 @@

static struct mempool *vbopool;

-struct vbo {
- unsigned magic;
-#define VBO_MAGIC 0xde3d8223
- struct lock mtx;
- unsigned refcount;
- char *end;
- struct busyobj bo;
-};
-
/*--------------------------------------------------------------------
*/

@@ -56,7 +47,7 @@ void
VBO_Init(void)
{

- vbopool = MPL_New("vbo", &cache_param->vbo_pool,
+ vbopool = MPL_New("busyobj", &cache_param->vbo_pool,
&cache_param->workspace_backend);
AN(vbopool);
}
@@ -65,88 +56,86 @@ VBO_Init(void)
* BusyObj handling
*/

-static struct vbo *
+static struct busyobj *
vbo_New(void)
{
- struct vbo *vbo;
+ struct busyobj *bo;
unsigned sz;

- vbo = MPL_Get(vbopool, &sz);
- AN(vbo);
- vbo->magic = VBO_MAGIC;
- vbo->end = (char *)vbo + sz;
- Lck_New(&vbo->mtx, lck_busyobj);
- return (vbo);
+ bo = MPL_Get(vbopool, &sz);
+ XXXAN(bo);
+ bo->magic = BUSYOBJ_MAGIC;
+ bo->end = (char *)bo + sz;
+ Lck_New(&bo->mtx, lck_busyobj);
+ return (bo);
}

void
-VBO_Free(struct vbo **vbop)
+VBO_Free(struct busyobj **bop)
{
- struct vbo *vbo;
+ struct busyobj *bo;

- AN(vbop);
- vbo = *vbop;
- *vbop = NULL;
- CHECK_OBJ_NOTNULL(vbo, VBO_MAGIC);
- AZ(vbo->refcount);
- Lck_Delete(&vbo->mtx);
- MPL_Free(vbopool, vbo);
+ AN(bop);
+ bo = *bop;
+ *bop = NULL;
+ CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+ AZ(bo->refcount);
+ Lck_Delete(&bo->mtx);
+ MPL_Free(vbopool, bo);
}

struct busyobj *
VBO_GetBusyObj(struct worker *wrk)
{
- struct vbo *vbo = NULL;
+ struct busyobj *bo = NULL;
uint16_t nhttp;
unsigned sz;
char *p;

CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);

- if (wrk->nvbo != NULL) {
- vbo = wrk->nvbo;
- wrk->nvbo = NULL;
+ if (wrk->nbo != NULL) {
+ bo = wrk->nbo;
+ wrk->nbo = NULL;
}

- if (vbo == NULL)
- vbo = vbo_New();
+ if (bo == NULL)
+ bo = vbo_New();

- CHECK_OBJ_NOTNULL(vbo, VBO_MAGIC);
- AZ(vbo->refcount);
+ CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+ AZ(bo->refcount);

- AZ(vbo->bo.magic);
- vbo->refcount = 1;
- vbo->bo.magic = BUSYOBJ_MAGIC;
- vbo->bo.vbo = vbo;
+ bo->refcount = 1;

- p = (void*)(vbo + 1);
+ p = (void*)(bo + 1);
p = (void*)PRNDUP(p);
- assert(p < vbo->end);
+ assert(p < bo->end);

nhttp = (uint16_t)cache_param->http_max_hdr;
sz = HTTP_estimate(nhttp);

- vbo->bo.bereq = HTTP_create(p, nhttp);
+ bo->bereq = HTTP_create(p, nhttp);
p += sz;
p = (void*)PRNDUP(p);
- assert(p < vbo->end);
+ assert(p < bo->end);

- vbo->bo.beresp = HTTP_create(p, nhttp);
+ bo->beresp = HTTP_create(p, nhttp);
p += sz;
p = (void*)PRNDUP(p);
- assert(p < vbo->end);
+ assert(p < bo->end);

sz = cache_param->vsl_buffer;
- VSL_Setup(vbo->bo.vsl, p, sz);
+ VSL_Setup(bo->vsl, p, sz);
p += sz;
p = (void*)PRNDUP(p);
- assert(p < vbo->end);
+ assert(p < bo->end);

- WS_Init(vbo->bo.ws, "bo", p, vbo->end - p);
+ WS_Init(bo->ws, "bo", p, bo->end - p);

- return (&vbo->bo);
+ return (bo);
}

+#if 0
void
VBO_RefBusyObj(const struct busyobj *busyobj)
{
@@ -160,12 +149,12 @@ VBO_RefBusyObj(const struct busyobj *busyobj)
vbo->refcount++;
Lck_Unlock(&vbo->mtx);
}
+#endif

void
VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo)
{
struct busyobj *bo;
- struct vbo *vbo;
unsigned r;

CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
@@ -173,22 +162,21 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo)
bo = *pbo;
*pbo = NULL;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
- vbo = bo->vbo;
- CHECK_OBJ_NOTNULL(vbo, VBO_MAGIC);
- Lck_Lock(&vbo->mtx);
- assert(vbo->refcount > 0);
- r = --vbo->refcount;
- Lck_Unlock(&vbo->mtx);
+ Lck_Lock(&bo->mtx);
+ assert(bo->refcount > 0);
+ r = --bo->refcount;
+ Lck_Unlock(&bo->mtx);

if (r)
return;

- VSL_Flush(vbo->bo.vsl, 0);
- /* XXX: Sanity checks & cleanup */
- memset(&vbo->bo, 0, sizeof vbo->bo);
+ VSL_Flush(bo->vsl, 0);
+
+ memset(&bo->refcount, 0,
+ sizeof *bo - offsetof(struct busyobj, refcount));

- if (cache_param->bo_cache && wrk->nvbo == NULL)
- wrk->nvbo = vbo;
+ if (cache_param->bo_cache && wrk->nbo == NULL)
+ wrk->nbo = bo;
else
- VBO_Free(&vbo);
+ VBO_Free(&bo);
}
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index ecea4b5..1ae5dd7 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -906,9 +906,9 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
#if 1
FetchBody(wrk, bo);
#else
- bo->task.func = FetchBody;
- bo->task.priv = bo;
- if (Pool_Task(wrk->pool, &bo->task, POOL_NO_QUEUE)) {
+ bo->fetch_task.func = FetchBody;
+ bo->fetch_task.priv = bo;
+ if (Pool_Task(wrk->pool, &bo->fetch_task, POOL_NO_QUEUE)) {
FetchBody(wrk, bo);
} else {
while (bo->state < BOS_FAILED)
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 1e21214..951cef9 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -131,8 +131,6 @@ HSH_Cleanup(struct worker *wrk)
free(wrk->nhashpriv);
wrk->nhashpriv = NULL;
}
- if (wrk->nvbo != NULL)
- VBO_Free(&wrk->nvbo);
}

void
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index cc3a061..7b65479 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -147,8 +147,8 @@ wrk_thread_real(void *priv, unsigned thread_workspace)
if (w->vcl != NULL)
VCL_Rel(&w->vcl);
AZ(pthread_cond_destroy(&w->cond));
- if (w->nvbo != NULL)
- VBO_Free(&w->nvbo);
+ if (w->nbo != NULL)
+ VBO_Free(&w->nbo);
HSH_Cleanup(w);
WRK_SumStat(w);
return (NULL);

_______________________________________________
varnish-commit mailing list
varnish-commit [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit

Varnish commits RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.