r3635 - branches/2.0/varnish-cache/bin/varnishd
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Fri Feb 6 10:08:01 CET 2009
Author: tfheen
Date: 2009-02-06 10:08:01 +0100 (Fri, 06 Feb 2009)
New Revision: 3635
Modified:
branches/2.0/varnish-cache/bin/varnishd/cache_center.c
branches/2.0/varnish-cache/bin/varnishd/cache_hash.c
branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c
branches/2.0/varnish-cache/bin/varnishd/hash_slinger.h
Log:
Merge r3434: Isolate some hash-string building nastyness in cache_hash.c
Modified: branches/2.0/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_center.c 2009-02-06 09:03:59 UTC (rev 3634)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_center.c 2009-02-06 09:08:01 UTC (rev 3635)
@@ -586,28 +586,12 @@
cnt_lookup(struct sess *sp)
{
struct object *o;
- char *p;
- uintptr_t u;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
if (sp->obj == NULL) {
-
- /* Allocate the pointers we need, align properly. */
- sp->lhashptr = 1; /* space for NUL */
- sp->ihashptr = 0;
- sp->nhashptr = sp->vcl->nhashcount * 2;
- p = WS_Alloc(sp->http->ws,
- sizeof(const char *) * (sp->nhashptr + 1));
- XXXAN(p);
- /* Align pointer properly (?) */
- u = (uintptr_t)p;
- u &= sizeof(const char *) - 1;
- if (u)
- p += sizeof(const char *) - u;
- sp->hashptr = (void*)p;
-
+ HSH_Prepare(sp, sp->vcl->nhashcount);
VCL_hash_method(sp);
assert(sp->handling == VCL_RET_HASH);
}
Modified: branches/2.0/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_hash.c 2009-02-06 09:03:59 UTC (rev 3634)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_hash.c 2009-02-06 09:08:01 UTC (rev 3635)
@@ -201,6 +201,48 @@
assert(b <= oh->hash + oh->hashlen);
}
+void
+HSH_Prepare(struct sess *sp, unsigned nhashcount)
+{
+ char *p;
+ unsigned u;
+
+ /* Allocate the pointers we need, align properly. */
+ sp->lhashptr = 1; /* space for NUL */
+ sp->ihashptr = 0;
+ sp->nhashptr = nhashcount * 2;
+ p = WS_Alloc(sp->http->ws, sizeof(const char *) * (sp->nhashptr + 1));
+ XXXAN(p);
+ /* Align pointer properly (?) */
+ u = (uintptr_t)p;
+ u &= sizeof(const char *) - 1;
+ if (u)
+ p += sizeof(const char *) - u;
+ sp->hashptr = (void*)p;
+}
+
+void
+HSH_AddString(struct sess *sp, const char *str)
+{
+ int l;
+
+ if (str == NULL)
+ str = "";
+ l = strlen(str);
+
+ /*
+ * XXX: handle this by bouncing sp->vcl->nhashcount when it fails
+ * XXX: and dispose of this request either by reallocating the
+ * XXX: hashptr (if possible) or restarting/error the request
+ */
+ xxxassert(sp->ihashptr < sp->nhashptr);
+
+ sp->hashptr[sp->ihashptr] = str;
+ sp->hashptr[sp->ihashptr + 1] = str + l;
+ sp->ihashptr += 2;
+ sp->lhashptr += l + 1;
+}
+
struct object *
HSH_Lookup(struct sess *sp)
{
Modified: branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c 2009-02-06 09:03:59 UTC (rev 3634)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c 2009-02-06 09:08:01 UTC (rev 3635)
@@ -585,23 +585,8 @@
void
VRT_l_req_hash(struct sess *sp, const char *str)
{
- int l;
- if (str == NULL)
- str = "";
- l = strlen(str);
-
- /*
- * XXX: handle this by bouncing sp->vcl->nhashcount when it fails
- * XXX: and dispose of this request either by reallocating the
- * XXX: hashptr (if possible) or restarting/error the request
- */
- xxxassert(sp->ihashptr < sp->nhashptr);
-
- sp->hashptr[sp->ihashptr] = str;
- sp->hashptr[sp->ihashptr + 1] = str + l;
- sp->ihashptr += 2;
- sp->lhashptr += l + 1;
+ HSH_AddString(sp, str);
}
/*--------------------------------------------------------------------*/
Modified: branches/2.0/varnish-cache/bin/varnishd/hash_slinger.h
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/hash_slinger.h 2009-02-06 09:03:59 UTC (rev 3634)
+++ branches/2.0/varnish-cache/bin/varnishd/hash_slinger.h 2009-02-06 09:08:01 UTC (rev 3635)
@@ -59,6 +59,8 @@
void HSH_Deref(struct object *o);
double HSH_Grace(double g);
void HSH_Init(void);
+void HSH_AddString(struct sess *sp, const char *str);
+void HSH_Prepare(struct sess *sp, unsigned hashcount);
#ifdef VARNISH_CACHE_CHILD
More information about the varnish-commit
mailing list