r1818 - in branches/1.1: . bin/varnishadm bin/varnishd bin/varnishhist bin/varnishlog bin/varnishncsa bin/varnishreplay bin/varnishstat bin/varnishtop debian etc include include/compat lib lib/libvarnish lib/libvarnishcompat lib/libvcl man

des at projects.linpro.no des at projects.linpro.no
Thu Aug 9 14:12:12 CEST 2007


Author: des
Date: 2007-08-09 14:12:12 +0200 (Thu, 09 Aug 2007)
New Revision: 1818

Added:
   branches/1.1/debian/libvarnish-dev.dirs
   branches/1.1/debian/libvarnish-dev.install
   branches/1.1/debian/libvarnish.dirs
   branches/1.1/debian/libvarnish.install
   branches/1.1/debian/varnish.dirs
   branches/1.1/debian/varnish.install
   branches/1.1/lib/libvarnishcompat/
Removed:
   branches/1.1/lib/libcompat/
Modified:
   branches/1.1/
   branches/1.1/autogen.sh
   branches/1.1/bin/varnishadm/Makefile.am
   branches/1.1/bin/varnishd/Makefile.am
   branches/1.1/bin/varnishd/cache.h
   branches/1.1/bin/varnishd/cache_ban.c
   branches/1.1/bin/varnishd/cache_center.c
   branches/1.1/bin/varnishd/cache_hash.c
   branches/1.1/bin/varnishd/cache_http.c
   branches/1.1/bin/varnishd/cache_synthetic.c
   branches/1.1/bin/varnishd/cache_vrt.c
   branches/1.1/bin/varnishd/cache_ws.c
   branches/1.1/bin/varnishd/hash_classic.c
   branches/1.1/bin/varnishd/hash_simple_list.c
   branches/1.1/bin/varnishd/hash_slinger.h
   branches/1.1/bin/varnishd/mgt_child.c
   branches/1.1/bin/varnishd/mgt_param.c
   branches/1.1/bin/varnishd/mgt_vcc.c
   branches/1.1/bin/varnishd/varnishd.c
   branches/1.1/bin/varnishhist/Makefile.am
   branches/1.1/bin/varnishlog/Makefile.am
   branches/1.1/bin/varnishncsa/Makefile.am
   branches/1.1/bin/varnishreplay/Makefile.am
   branches/1.1/bin/varnishstat/Makefile.am
   branches/1.1/bin/varnishtop/Makefile.am
   branches/1.1/configure.ac
   branches/1.1/debian/changelog
   branches/1.1/debian/control
   branches/1.1/debian/dirs
   branches/1.1/debian/rules
   branches/1.1/debian/varnish.default
   branches/1.1/debian/varnish.varnishlog.init
   branches/1.1/etc/default.vcl
   branches/1.1/include/compat/vis.h
   branches/1.1/include/libvarnish.h
   branches/1.1/include/vcl.h
   branches/1.1/include/vrt.h
   branches/1.1/include/vsb.h
   branches/1.1/lib/Makefile.am
   branches/1.1/lib/libvarnish/crc32.c
   branches/1.1/lib/libvarnish/flopen.c
   branches/1.1/lib/libvarnish/time.c
   branches/1.1/lib/libvarnish/vpf.c
   branches/1.1/lib/libvcl/vcc_action.c
   branches/1.1/lib/libvcl/vcc_compile.c
   branches/1.1/lib/libvcl/vcc_compile.h
   branches/1.1/lib/libvcl/vcc_fixed_token.c
   branches/1.1/lib/libvcl/vcc_gen_fixed_token.tcl
   branches/1.1/lib/libvcl/vcc_parse.c
   branches/1.1/man/vcl.7
Log:
Merged revisions 1743-1744,1746-1749,1755-1775,1777,1779-1793,1795,1797-1798,1800-1808,1810-1815,1817 via svnmerge from 
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache

........
  r1743 | ssm | 2007-07-20 14:43:54 +0200 (Fri, 20 Jul 2007) | 1 line
  
  Split debian package into varnish, libvarnish and libvarnish-dev
........
  r1748 | des | 2007-07-24 15:51:58 +0200 (Tue, 24 Jul 2007) | 2 lines
  
  Correct a comment
........
  r1749 | des | 2007-07-24 15:52:40 +0200 (Tue, 24 Jul 2007) | 2 lines
  
  Use strlen() directly.
........
  r1761 | cecilihf | 2007-07-25 10:39:10 +0200 (Wed, 25 Jul 2007) | 9 lines
  
  Implemented http purge with regexp. Example vcl usage:
  sub vcl_recv {
  	if (req.request == "REPURGE") {
  		purge(req.url);
  		error 404 "Purged";
  	}
  }
........
  r1762 | cecilihf | 2007-07-25 10:53:16 +0200 (Wed, 25 Jul 2007) | 2 lines
  
  Updated man page
........
  r1765 | cecilihf | 2007-07-25 13:09:06 +0200 (Wed, 25 Jul 2007) | 2 lines
  
  Use purge in function names instead of repurge and move VRT_purge to cache_vrt.c.
........
  r1766 | cecilihf | 2007-07-25 13:10:59 +0200 (Wed, 25 Jul 2007) | 2 lines
  
  Style...
........
  r1780 | des | 2007-07-28 12:03:29 +0200 (Sat, 28 Jul 2007) | 5 lines
  
  Reverse the logic for sp->wantbody: assume it is always wanted unless
  req.request is "HEAD".  This is what broke the RePurge test case.
  
  Ideally, sp->wantbody would be controllable by VCL.
........
  r1783 | des | 2007-07-30 10:03:42 +0200 (Mon, 30 Jul 2007) | 4 lines
  
  Avoid referencing <sys/cdefs.h> and __{BEGIN,END}_DECLS.
  
  Based on Theo Schlossnagle's Solaris portability patch.
........
  r1784 | des | 2007-07-30 11:49:05 +0200 (Mon, 30 Jul 2007) | 2 lines
  
  Avoid using non-portable <err.h>.
........
  r1785 | des | 2007-07-30 15:50:16 +0200 (Mon, 30 Jul 2007) | 3 lines
  
  Use mktime() rather than the unportable timegm().  The downside is that we're
  at the mercy of the TZ environment variable.
........
  r1786 | des | 2007-07-30 15:54:48 +0200 (Mon, 30 Jul 2007) | 2 lines
  
  Explicitly set TZ to GMT.
........
  r1787 | des | 2007-07-30 16:16:23 +0200 (Mon, 30 Jul 2007) | 4 lines
  
  Use fcntl(2)-style locks instead of non-portable flock(2)-style locks.
  
  Based on Theo Schlossnagle's Solaris portability patch.
........
  r1788 | des | 2007-07-30 16:19:45 +0200 (Mon, 30 Jul 2007) | 2 lines
  
  pid_t is not necessarily compatible with int.
........
  r1789 | des | 2007-07-30 16:22:00 +0200 (Mon, 30 Jul 2007) | 2 lines
  
  Bogons in previous commit.  Pass me the pointy hat...
........
  r1790 | des | 2007-07-30 16:31:16 +0200 (Mon, 30 Jul 2007) | 3 lines
  
  I accidentally committed the wrong patch in r1787; this corrects the logic
  used to determine which lock type (shared or exclusive) to use.
........
  r1791 | des | 2007-07-30 16:39:03 +0200 (Mon, 30 Jul 2007) | 2 lines
  
  Note that MAX_IOVS is intentionally not equal to IOV_MAX.
........
  r1792 | des | 2007-07-31 08:06:28 +0200 (Tue, 31 Jul 2007) | 2 lines
  
  Fine-tune the vhost example.
........
  r1793 | des | 2007-08-03 20:46:43 +0200 (Fri, 03 Aug 2007) | 2 lines
  
  Synchronize these two files.
........
  r1795 | phk | 2007-08-05 21:37:44 +0200 (Sun, 05 Aug 2007) | 9 lines
  
  Synchronize the paramters after we call their accessor functions rather
  than when we don't find one.
  
  This makes changing runtime paramters work again, without the need to
  ask for a nonexistent parameter to trigger the update.
  
  Ticket: 136
........
  r1797 | phk | 2007-08-05 22:17:49 +0200 (Sun, 05 Aug 2007) | 4 lines
  
  Make the nonexistence of "nobody" and "nogroup" users and groups nonfatal
  
  Ticket: 140
........
  r1798 | phk | 2007-08-05 22:26:09 +0200 (Sun, 05 Aug 2007) | 5 lines
  
  We need the math library on some systems.
  
  Ticket 138
........
  r1800 | phk | 2007-08-05 22:57:20 +0200 (Sun, 05 Aug 2007) | 2 lines
  
  Add a missing return: we always return after detecting the first error.
........
  r1801 | phk | 2007-08-05 22:57:32 +0200 (Sun, 05 Aug 2007) | 2 lines
  
  vrt.h is not needed here.
........
  r1802 | phk | 2007-08-05 23:06:41 +0200 (Sun, 05 Aug 2007) | 2 lines
  
  Add comment to remind myself.
........
  r1803 | phk | 2007-08-06 10:07:18 +0200 (Mon, 06 Aug 2007) | 14 lines
  
  Have the VCL compiler provide a hint about the worst case number of
  operations on the req.hash variable.
  
  It is only a hint, because it merely counts how many times the parser
  saw something being added to the req.hash variable.  If the operation
  was in a subroutine which was called multiple times, the hint will not
  reflect the number of actual operations.
  
  For now we will deal with that at runtime, at the expense of a
  failed transaction every time we run short.  If this becomes an issue,
  an extensive topological analysis of the VCL program can give us
  a definitive count.
........
  r1804 | phk | 2007-08-06 11:19:20 +0200 (Mon, 06 Aug 2007) | 3 lines
  
  Add piecemal crc32 function back, we will need it for the scatter/gather
  hash string.
........
  r1805 | phk | 2007-08-06 11:25:20 +0200 (Mon, 06 Aug 2007) | 13 lines
  
  Rewrite the req.hash implmentation:
  
  Instead of assembling the entire hash-string in the workspace, use
  a scatter gather approach, hinted by the VCL compiler.
  
  This eliminates the workspace reservation which prevented regsub() from
  working in vcl_hash, and reduces the size of the necessary workspace a
  fair bit as well, at the cost of a little bit of complexity in the
  hash implmentations.
  
  Closes ticket 137 and possibly 141
........
  r1806 | phk | 2007-08-06 11:28:44 +0200 (Mon, 06 Aug 2007) | 4 lines
  
  Forgot an assert.
  
  WS_Return() is now unused, comment it out.
........
  r1807 | phk | 2007-08-07 08:55:52 +0200 (Tue, 07 Aug 2007) | 4 lines
  
  When vcl_miss() take error action, remember to discard backend request.
  
  Ticket: 139
........
  r1808 | phk | 2007-08-07 09:23:10 +0200 (Tue, 07 Aug 2007) | 3 lines
  
  Implement "error" action in vcl_fetch() and vcl_deliver()
........
  r1810 | phk | 2007-08-08 10:49:11 +0200 (Wed, 08 Aug 2007) | 5 lines
  
  Elminiate a spurious message when sigchild looses a race to popen(2).
  
  This fixed #143
........
  r1811 | des | 2007-08-08 12:01:50 +0200 (Wed, 08 Aug 2007) | 3 lines
  
  Remove FreeBSD workaround; the FreeBSD ports tree has had working autotools
  for two weeks now.  Also fix inconsistent indentation.
........
  r1817 | des | 2007-08-09 13:19:20 +0200 (Thu, 09 Aug 2007) | 2 lines
  
  Rename libcompat to libvarnishcompat, and make it dynamic.
........



Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk/varnish-cache:1-1722,1727-1729,1738,1745-1747,1750-1760,1763-1764,1767-1776
   + /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1793,1795,1797-1798,1800-1808,1810-1815,1817

Modified: branches/1.1/autogen.sh
===================================================================
--- branches/1.1/autogen.sh	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/autogen.sh	2007-08-09 12:12:12 UTC (rev 1818)
@@ -9,19 +9,17 @@
 
 case `uname -s` in
 Darwin)
-	LIBTOOLIZE=glibtoolize
-	;;
+    LIBTOOLIZE=glibtoolize
+    ;;
 FreeBSD)
-	LIBTOOLIZE=libtoolize
-	if [ -d /usr/local/gnu-autotools/bin ] ; then
-		PATH=/usr/local/gnu-autotools/bin:${PATH}
-		export PATH
-		FIX_BROKEN_FREEBSD_PORTS="-I /usr/local/share/aclocal"
-	fi
-	;;
+    LIBTOOLIZE=libtoolize
+    ;;
 Linux)
-	LIBTOOLIZE=libtoolize
-	;;
+    LIBTOOLIZE=libtoolize
+    ;;
+*)
+    warn "unrecognized platform:" `uname -s`
+    LIBTOOLIZE=libtoolize
 esac
 
 automake_version=$(automake --version | tr ' ' '\n' | egrep '^[0-9]\.[0-9a-z.-]+')
@@ -39,7 +37,7 @@
 
 set -ex
 
-aclocal ${FIX_BROKEN_FREEBSD_PORTS}
+aclocal
 $LIBTOOLIZE --copy --force
 autoheader
 automake --add-missing --copy --foreign

Modified: branches/1.1/bin/varnishadm/Makefile.am
===================================================================
--- branches/1.1/bin/varnishadm/Makefile.am	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishadm/Makefile.am	2007-08-09 12:12:12 UTC (rev 1818)
@@ -13,4 +13,4 @@
 
 varnishadm_LDADD = \
 	$(top_builddir)/lib/libvarnish/libvarnish.la \
-	$(top_builddir)/lib/libcompat/libcompat.a
+	$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la

Modified: branches/1.1/bin/varnishd/Makefile.am
===================================================================
--- branches/1.1/bin/varnishd/Makefile.am	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/Makefile.am	2007-08-09 12:12:12 UTC (rev 1818)
@@ -66,6 +66,6 @@
 
 varnishd_LDADD = \
 	$(top_builddir)/lib/libvarnish/libvarnish.la \
-	$(top_builddir)/lib/libcompat/libcompat.a \
+	$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
 	$(top_builddir)/lib/libvcl/libvcl.la \
-	${DL_LIBS} ${PTHREAD_LIBS}
+	${DL_LIBS} ${PTHREAD_LIBS} ${LIBM}

Modified: branches/1.1/bin/varnishd/cache.h
===================================================================
--- branches/1.1/bin/varnishd/cache.h	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/cache.h	2007-08-09 12:12:12 UTC (rev 1818)
@@ -56,6 +56,7 @@
 	HTTP_HDR_MAX = 32
 };
 
+/* Note: intentionally not IOV_MAX */
 #define MAX_IOVS	(HTTP_HDR_MAX * 2)
 
 /* Amount of per-worker logspace */
@@ -94,7 +95,6 @@
 void WS_Assert(struct ws *ws);
 void WS_Reset(struct ws *ws);
 char *WS_Alloc(struct ws *ws, unsigned bytes);
-void WS_Return(struct ws *ws, char *b, char *e);
 
 
 
@@ -325,8 +325,11 @@
 	struct workreq		workreq;
 	struct acct		acct;
 
-	char			*hash_b;	/* Start of hash string */
-	char			*hash_e;	/* End of hash string */
+	/* pointers to hash string components */
+	unsigned		nhashptr;
+	unsigned		ihashptr;
+	unsigned		lhashptr;
+	const char		**hashptr;
 };
 
 struct backend {
@@ -371,6 +374,7 @@
 void vbe_free_bereq(struct bereq *bereq);
 
 /* cache_ban.c */
+void AddBan(const char *);
 void BAN_Init(void);
 void cli_func_url_purge(struct cli *cli, char **av, void *priv);
 void BAN_NewObj(struct object *o);
@@ -394,6 +398,8 @@
 
 /* cache_hash.c */
 void HSH_Prealloc(struct sess *sp);
+int HSH_Compare(struct sess *sp, const char *b, const char *e);
+void HSH_Copy(struct sess *sp, char *b, const char *e);
 struct object *HSH_Lookup(struct sess *sp);
 void HSH_Unbusy(struct object *o);
 void HSH_Ref(struct object *o);

Modified: branches/1.1/bin/varnishd/cache_ban.c
===================================================================
--- branches/1.1/bin/varnishd/cache_ban.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/cache_ban.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -52,7 +52,7 @@
 static unsigned ban_next;
 static struct ban *ban_start;
 
-static void
+void
 AddBan(const char *regexp)
 {
 	struct ban *b;

Modified: branches/1.1/bin/varnishd/cache_center.c
===================================================================
--- branches/1.1/bin/varnishd/cache_center.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/cache_center.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -149,8 +149,17 @@
 	sp->t_resp = TIM_real();
 	RES_BuildHttp(sp);
 	VCL_deliver_method(sp);
-	if (sp->handling != VCL_RET_DELIVER) 
+	switch (sp->handling) {
+	case VCL_RET_DELIVER:
+		break;
+	case VCL_RET_ERROR:
+		HSH_Deref(sp->obj);
+		sp->obj = NULL;
+		sp->step = STP_ERROR;
+		return (0);
+	default:
 		INCOMPL();
+	}
 
 	RES_WriteObj(sp);
 	HSH_Deref(sp->obj);
@@ -298,11 +307,23 @@
 
 		VCL_fetch_method(sp);
 
-		if (sp->handling == VCL_RET_ERROR)
+		switch (sp->handling) {
+		case VCL_RET_ERROR:
+			sp->obj->ttl = 0;
+			sp->obj->cacheable = 0;
+			HSH_Unbusy(sp->obj);
+			HSH_Deref(sp->obj);
+			sp->obj = NULL;
+			sp->step = STP_ERROR;
+			return (0);
+		case VCL_RET_PASS:
+			sp->obj->pass = 1;
+			break;
+		case VCL_RET_INSERT:
+			break;
+		default:
 			INCOMPL();
-
-		if (sp->handling == VCL_RET_PASS)
-			sp->obj->pass = 1;
+		}
 	}
 
 	sp->obj->cacheable = 1;
@@ -433,15 +454,27 @@
 cnt_lookup(struct sess *sp)
 {
 	struct object *o;
+	char *p;
+	uintptr_t u;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 
 	if (sp->obj == NULL) {
-		WS_Reserve(sp->http->ws, 0);
-		sp->hash_b = sp->http->ws->f;
-		sp->hash_e = sp->hash_b;
+
+		/* 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);
+		u = (uintptr_t)p;
+		u &= sizeof(const char *) - 1;
+		if (u)
+			p += sizeof(const char *) - u;
+		sp->hashptr = (void*)p;
+
 		VCL_hash_method(sp);		/* XXX: no-op for now */
-		WS_ReleaseP(sp->http->ws, sp->hash_e);
 		/* XXX check error */
 	}
 
@@ -458,9 +491,6 @@
 		return (1);
 	}
 
-	WS_Return(sp->http->ws, sp->hash_b, sp->hash_e);
-	sp->hash_b = sp->hash_e = NULL;
-
 	sp->obj = o;
 
 	/* If we inserted a new object it's a miss */
@@ -522,6 +552,8 @@
 		HSH_Unbusy(sp->obj);
 		HSH_Deref(sp->obj);
 		sp->obj = NULL;
+		vbe_free_bereq(sp->bereq);
+		sp->bereq = NULL;
 		sp->step = STP_ERROR;
 		return (0);
 	}
@@ -690,8 +722,7 @@
 
 	VCL_recv_method(sp);
 
-	sp->wantbody = (!strcmp(sp->http->hd[HTTP_HDR_REQ].b, "GET") ||
-	    !strcmp(sp->http->hd[HTTP_HDR_REQ].b, "POST"));
+	sp->wantbody = (strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD") != 0);
 	switch(sp->handling) {
 	case VCL_RET_LOOKUP:
 		/* XXX: discard req body, if any */

Modified: branches/1.1/bin/varnishd/cache_hash.c
===================================================================
--- branches/1.1/bin/varnishd/cache_hash.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/cache_hash.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -108,6 +108,47 @@
 	}
 }
 
+int
+HSH_Compare(struct sess *sp, const char *b, const char *e)
+{
+	int i;
+	unsigned u, v;
+
+	i = sp->lhashptr - (e - b);
+	if (i)
+		return (i);
+	for (u = 0; u < sp->ihashptr; u += 2) {
+		v = sp->hashptr[u + 1] - sp->hashptr[u];
+		i = memcmp(sp->hashptr[u], b, v);
+		if (i)
+			return (i);
+		b += v;
+		i = '#' - *b++;
+		if (i)
+			return (i);
+	}
+	assert(*b == '\0');
+	b++;
+	assert(b == e);
+	return (0);
+}
+
+void
+HSH_Copy(struct sess *sp, char *b, const char *e)
+{
+	unsigned u, v;
+
+	assert((e - b) >= sp->lhashptr);
+	for (u = 0; u < sp->ihashptr; u += 2) {
+		v = sp->hashptr[u + 1] - sp->hashptr[u];
+		memcpy(b, sp->hashptr[u], v);
+		b += v;
+		*b++ = '#';
+	}
+	*b++ = '\0';
+	assert(b <= e);
+}
+
 struct object *
 HSH_Lookup(struct sess *sp)
 {
@@ -132,9 +173,8 @@
 		LOCK(&oh->mtx);
 		goto were_back;
 	}
-VSLR(SLT_Debug, sp->fd, sp->hash_b, sp->hash_e);
 
-	oh = hash->lookup(sp->hash_b, sp->hash_e, w->nobjhead);
+	oh = hash->lookup(sp, w->nobjhead);
 	CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
 	if (oh == w->nobjhead)
 		w->nobjhead = NULL;

Modified: branches/1.1/bin/varnishd/cache_http.c
===================================================================
--- branches/1.1/bin/varnishd/cache_http.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/cache_http.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -884,13 +884,11 @@
 static void
 http_PutField(struct worker *w, int fd, struct http *to, int field, const char *string)
 {
-	const char *e;
 	char *p;
 	int l;
 
 	CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
-	e = strchr(string, '\0');
-	l = (e - string);
+	l = strlen(string);
 	p = WS_Alloc(to->ws, l + 1);
 	if (p == NULL) {
 		WSL(w, SLT_LostHeader, fd, "%s", string);

Modified: branches/1.1/bin/varnishd/cache_synthetic.c
===================================================================
--- branches/1.1/bin/varnishd/cache_synthetic.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/cache_synthetic.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -131,5 +131,5 @@
 	http_PrintfHeader(w, fd, h, "Retry-After: %ju", (uintmax_t)ttl);
 	http_PrintfHeader(w, fd, h, "Content-Type: text/html; charset=utf-8");
 	http_PrintfHeader(w, fd, h, "Content-Length: %u", o->len);
-	/* DO NOT generate X-Varnish header, RES_WriteObj will */
+	/* DO NOT generate X-Varnish header, RES_BuildHttp will */
 }

Modified: branches/1.1/bin/varnishd/cache_vrt.c
===================================================================
--- branches/1.1/bin/varnishd/cache_vrt.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/cache_vrt.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -452,7 +452,9 @@
 	return (sp->mysockaddr);
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Add an element to the array/list of hash bits.
+ */
 
 void
 VRT_l_req_hash(struct sess *sp, const char *str)
@@ -462,10 +464,18 @@
 	if (str == NULL)
 		str = "";
 	l = strlen(str);
-	xxxassert (sp->hash_e + l + 1 <= sp->http->ws->e);
-	memcpy(sp->hash_e, str, l);
-	sp->hash_e[l] = '#';
-	sp->hash_e += l + 1;
+
+	/*
+	 * 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;
 }
 
 /*--------------------------------------------------------------------*/
@@ -513,3 +523,12 @@
 	strcat(q, p);
 	return (q);
 }
+
+/*--------------------------------------------------------------------*/
+
+void
+VRT_purge(const char *regexp)
+{
+	
+	AddBan(regexp);
+}

Modified: branches/1.1/bin/varnishd/cache_ws.c
===================================================================
--- branches/1.1/bin/varnishd/cache_ws.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/cache_ws.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -129,6 +129,8 @@
 	ws->r = NULL;
 }
 
+#if 0
+/* XXX: not used anywhere (yet) */
 void
 WS_Return(struct ws *ws, char *s, char *e)
 {
@@ -137,3 +139,4 @@
 	if (e == ws->f)
 		ws->f = s;
 }
+#endif

Modified: branches/1.1/bin/varnishd/hash_classic.c
===================================================================
--- branches/1.1/bin/varnishd/hash_classic.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/hash_classic.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -121,36 +121,44 @@
  */
 
 static struct objhead *
-hcl_lookup(const char *b, const char *e, struct objhead *noh)
+hcl_lookup(struct sess *sp, struct objhead *noh)
 {
 	struct hcl_entry *he, *he2;
 	struct hcl_hd *hp;
-	unsigned u1, digest, kl, r;
+	unsigned u1, digest, r;
+	unsigned u, v;
 	int i;
 
 	CHECK_OBJ_NOTNULL(noh, OBJHEAD_MAGIC);
 
-	digest = crc32_l(b, e - b);
+	digest = ~0U;
+	for (u = 0; u < sp->ihashptr; u += 2) {
+		v = sp->hashptr[u + 1] - sp->hashptr[u];
+		digest = crc32(digest, sp->hashptr[u], v);
+	}
+	digest ^= ~0U;
 
 	u1 = digest % hcl_nhash;
 	hp = &hcl_head[u1];
-	kl = e - b;
 	he2 = NULL;
 
 	for (r = 0; r < 2; r++ ) {
 		LOCK(&hp->mtx);
 		TAILQ_FOREACH(he, &hp->head, list) {
 			CHECK_OBJ_NOTNULL(he, HCL_ENTRY_MAGIC);
-			if (kl < he->klen)
+			if (sp->lhashptr < he->klen)
 				continue;
-			if (kl > he->klen)
+			if (sp->lhashptr > he->klen)
 				break;
 			if (he->digest < digest)
 				continue;
 			if (he->digest > digest)
 				break;
-			if (memcmp(he->key, b, kl))
+			i = HSH_Compare(sp, he->key, he->key + he->klen);
+			if (i < 0)
 				continue;
+			if (i > 0)
+				break;
 			he->refcnt++;
 			noh = he->oh;
 			UNLOCK(&hp->mtx);
@@ -174,7 +182,7 @@
 		}
 		UNLOCK(&hp->mtx);
 
-		i = sizeof *he2 + kl;
+		i = sizeof *he2 + sp->lhashptr;
 		he2 = calloc(i, 1);
 		XXXAN(he2);
 		he2->magic = HCL_ENTRY_MAGIC;
@@ -182,11 +190,11 @@
 		he2->digest = digest;
 		he2->hash = u1;
 		he2->head = hp;
-		he2->klen = kl;
+		he2->klen = sp->lhashptr;
 		noh->hashpriv = he2;
 
 		he2->key = (void*)(he2 + 1);
-		memcpy(he2->key, b, kl);
+		HSH_Copy(sp, he2->key, he2->key + sp->lhashptr);
 	}
 	assert(he2 == NULL);		/* FlexeLint */
 	INCOMPL();

Modified: branches/1.1/bin/varnishd/hash_simple_list.c
===================================================================
--- branches/1.1/bin/varnishd/hash_simple_list.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/hash_simple_list.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -73,26 +73,20 @@
  */
 
 static struct objhead *
-hsl_lookup(const char *b, const char *e, struct objhead *nobj)
+hsl_lookup(struct sess *sp, struct objhead *nobj)
 {
 	struct hsl_entry *he, *he2;
-	int i, l;
+	int i;
 
-	l = e - b;
 	LOCK(&hsl_mutex);
 	TAILQ_FOREACH(he, &hsl_head, list) {
-		if (l > he->keylen)
-			continue;
-		if (l < he->keylen)
-			break;;
-		i = memcmp(b, he->key, l);
+		i = HSH_Compare(sp, he->key, he->key + he->keylen);
 		if (i < 0)
 			continue;
 		if (i > 0)
 			break;
 		he->refcnt++;
 		nobj = he->obj;
-		nobj->hashpriv = he;
 		UNLOCK(&hsl_mutex);
 		return (nobj);
 	}
@@ -100,13 +94,13 @@
 		UNLOCK(&hsl_mutex);
 		return (NULL);
 	}
-	he2 = calloc(sizeof *he2 + l, 1);
+	he2 = calloc(sizeof *he2 + sp->lhashptr, 1);
 	XXXAN(he2);
 	he2->obj = nobj;
 	he2->refcnt = 1;
 	he2->key = (void*)(he2 + 1);
-	he2->keylen = l;
-	memcpy(he2->key, b, l);
+	he2->keylen = sp->lhashptr;
+	HSH_Copy(sp, he2->key, he2->key + he2->keylen);
 	nobj->hashpriv = he2;
 	if (he != NULL)
 		TAILQ_INSERT_BEFORE(he, he2, list);

Modified: branches/1.1/bin/varnishd/hash_slinger.h
===================================================================
--- branches/1.1/bin/varnishd/hash_slinger.h	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/hash_slinger.h	2007-08-09 12:12:12 UTC (rev 1818)
@@ -29,9 +29,11 @@
  * $Id$
  */
 
+struct sess;
+
 typedef int hash_init_f(const char *);
 typedef void hash_start_f(void);
-typedef struct objhead *hash_lookup_f(const char *key1, const char *key2, struct objhead *nobj);
+typedef struct objhead *hash_lookup_f(struct sess *sp, struct objhead *nobj);
 typedef int hash_deref_f(struct objhead *obj);
 
 struct hash_slinger {

Modified: branches/1.1/bin/varnishd/mgt_child.c
===================================================================
--- branches/1.1/bin/varnishd/mgt_child.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/mgt_child.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -42,8 +42,6 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
-#include <err.h>		/* XXX */
-
 #ifndef HAVE_SETPROCTITLE
 #include "compat/setproctitle.h"
 #endif
@@ -168,7 +166,7 @@
 static void
 start_child(void)
 {
-	int i;
+	pid_t pid;
 	unsigned u;
 	char *p;
 	struct ev *e;
@@ -187,10 +185,11 @@
 	AZ(pipe(&heritage.fds[2]));
 	AZ(pipe(child_fds));
 	MCF_ParamSync();
-	i = fork();
-	if (i < 0)
-		errx(1, "Could not fork child");
-	if (i == 0) {
+	if ((pid = fork()) < 0) {
+		perror("Could not fork child");
+		exit(1);
+	}
+	if (pid == 0) {
 		if (geteuid() == 0) {
 			XXXAZ(setgid(params->gid));
 			XXXAZ(setuid(params->uid));
@@ -198,8 +197,7 @@
 
 		/* Redirect stdin/out/err */
 		AZ(close(0));
-		i = open("/dev/null", O_RDONLY);
-		xxxassert(i == 0);
+		assert(open("/dev/null", O_RDONLY) == 0);
 		assert(dup2(child_fds[1], 1) == 1);
 		assert(dup2(child_fds[1], 2) == 2);
 		AZ(close(child_fds[0]));
@@ -214,10 +212,10 @@
 		signal(SIGTERM, SIG_DFL);
 		child_main();
 
-		exit (1);
+		exit(1);
 	}
 
-	fprintf(stderr, "start child pid %d\n", i);
+	fprintf(stderr, "start child pid %jd\n", (intmax_t)pid);
 
 	AZ(close(child_fds[1]));
 	child_fds[1] = -1;
@@ -248,7 +246,7 @@
 	heritage.fds[1] = -1;
 	AZ(close(heritage.fds[2]));
 	heritage.fds[2] = -1;
-	child_pid = i;
+	child_pid = pid;
 	if (mgt_push_vcls_and_start(&u, &p)) {
 		fprintf(stderr, "Pushing vcls failed:\n%s\n", p);
 		free(p);
@@ -307,6 +305,8 @@
 	ev_poker = NULL;
 
 	r = wait4(-1, &status, WNOHANG, NULL);
+	if (r == 0)
+		return (0);
 	if (r != child_pid || r == -1) {
 		fprintf(stderr, "Unknown child died pid=%d status=0x%x\n",
 		    r, status);

Modified: branches/1.1/bin/varnishd/mgt_param.c
===================================================================
--- branches/1.1/bin/varnishd/mgt_param.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/mgt_param.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -51,6 +51,8 @@
 
 #include "vss.h"
 
+#define MAGIC_INIT_STRING	"\001"
+
 struct parspec;
 
 typedef void tweak_t(struct cli *, struct parspec *, const char *arg);
@@ -141,7 +143,13 @@
 	}
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * XXX: slightly magic.  We want to initialize to "nobody" (XXX: shouldn't
+ * XXX: that be something autocrap found for us ?) but we don't want to
+ * XXX: fail initialization if that user doesn't exists, even though we
+ * XXX: do want to fail it, in subsequent sets.
+ * XXX: The magic init string is a hack for this.
+ */
 
 static void
 tweak_user(struct cli *cli, struct parspec *par, const char *arg)
@@ -151,7 +159,15 @@
 
 	(void)par;
 	if (arg != NULL) {
-		if ((pw = getpwnam(arg)) == NULL) {
+		if (!strcmp(arg, MAGIC_INIT_STRING)) {
+			pw = getpwnam("nobody");
+			if (pw == NULL) {
+				master.uid = getuid();
+				return;
+			}
+		} else 
+			pw = getpwnam(arg);
+		if (pw == NULL) {
 			cli_out(cli, "Unknown user");
 			cli_result(cli, CLIS_PARAM);
 			return;
@@ -161,6 +177,7 @@
 		master.user = strdup(pw->pw_name);
 		AN(master.user);
 		master.uid = pw->pw_uid;
+		master.gid = pw->pw_gid;
 
 		/* set group to user's primary group */
 		if (master.group)
@@ -171,7 +188,6 @@
 			master.group = strdup(gr->gr_name);
 			AN(master.group);
 		}
-		master.gid = pw->pw_gid;
 	} else if (master.user) {
 		cli_out(cli, "%s (%d)", master.user, (int)master.uid);
 	} else {
@@ -179,7 +195,9 @@
 	}
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * XXX: see comment for tweak_user, same thing here.
+ */
 
 static void
 tweak_group(struct cli *cli, struct parspec *par, const char *arg)
@@ -188,7 +206,17 @@
 
 	(void)par;
 	if (arg != NULL) {
-		if ((gr = getgrnam(arg)) == NULL) {
+		if (!strcmp(arg, MAGIC_INIT_STRING)) {
+			gr = getgrnam("nogroup");
+			if (gr == NULL) {
+				/* Only replace if tweak_user didn't */
+				if (master.gid == 0)
+					master.gid = getgid();
+				return;
+			}
+		} else
+			gr = getgrnam(arg);
+		if (gr == NULL) {
 			cli_out(cli, "Unknown group");
 			cli_result(cli, CLIS_PARAM);
 			return;
@@ -524,11 +552,11 @@
 		"The unprivileged user to run as.  Setting this will "
 		"also set \"group\" to the specified user's primary group.\n"
 		MUST_RESTART,
-		"nobody" },
+		MAGIC_INIT_STRING },
 	{ "group", tweak_group,
 		"The unprivileged group to run as.\n"
 		MUST_RESTART,
-		"nogroup" },
+		MAGIC_INIT_STRING },
 	{ "default_ttl", tweak_default_ttl,
 		"The TTL assigned to objects if neither the backend nor "
 		"the VCL code assigns one.\n"
@@ -754,12 +782,12 @@
 	for (pp = parspec; pp->name != NULL; pp++) {
 		if (!strcmp(pp->name, param)) {
 			pp->func(cli, pp, val);
+			MCF_ParamSync();
 			return;
 		}
 	}
 	cli_result(cli, CLIS_PARAM);
 	cli_out(cli, "Unknown paramter \"%s\".", param);
-	MCF_ParamSync();
 }
 
 

Modified: branches/1.1/bin/varnishd/mgt_vcc.c
===================================================================
--- branches/1.1/bin/varnishd/mgt_vcc.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/mgt_vcc.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -98,7 +98,7 @@
     "    if (req.http.host) {\n"
     "        set req.hash += req.http.host;\n"
     "    } else {\n"
-    "        set req.hash += server.ip;\n"
+    "        set req.hash += server.ip;\n"	/* XXX: see ticket 137 */
     "    }\n"
 #endif
     "    hash;\n"

Modified: branches/1.1/bin/varnishd/varnishd.c
===================================================================
--- branches/1.1/bin/varnishd/varnishd.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishd/varnishd.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -31,7 +31,8 @@
  * The management process and CLI handling
  */
 
-#include <err.h>
+#include <sys/stat.h>
+
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -44,7 +45,6 @@
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
-#include <sys/stat.h>
 
 #ifndef HAVE_DAEMON
 #include "compat/daemon.h"
@@ -425,6 +425,9 @@
 	setbuf(stdout, NULL);
 	setbuf(stderr, NULL);
 
+	setenv("TZ", "GMT", 1);
+	tzset();
+
 	memset(cli, 0, sizeof cli);
 	cli[0].sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
 	XXXAN(cli[0].sb);

Modified: branches/1.1/bin/varnishhist/Makefile.am
===================================================================
--- branches/1.1/bin/varnishhist/Makefile.am	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishhist/Makefile.am	2007-08-09 12:12:12 UTC (rev 1818)
@@ -12,7 +12,7 @@
 
 varnishhist_LDADD = \
 	$(top_builddir)/lib/libvarnish/libvarnish.la \
-	$(top_builddir)/lib/libcompat/libcompat.a \
+	$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
 	$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
 	-lm \
 	${CURSES_LIBS} ${PTHREAD_LIBS}

Modified: branches/1.1/bin/varnishlog/Makefile.am
===================================================================
--- branches/1.1/bin/varnishlog/Makefile.am	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishlog/Makefile.am	2007-08-09 12:12:12 UTC (rev 1818)
@@ -12,5 +12,5 @@
 
 varnishlog_LDADD = \
 	$(top_builddir)/lib/libvarnish/libvarnish.la \
-	$(top_builddir)/lib/libcompat/libcompat.a \
+	$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
 	$(top_builddir)/lib/libvarnishapi/libvarnishapi.la

Modified: branches/1.1/bin/varnishncsa/Makefile.am
===================================================================
--- branches/1.1/bin/varnishncsa/Makefile.am	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishncsa/Makefile.am	2007-08-09 12:12:12 UTC (rev 1818)
@@ -12,5 +12,5 @@
 
 varnishncsa_LDADD = \
 	$(top_builddir)/lib/libvarnish/libvarnish.la \
-	$(top_builddir)/lib/libcompat/libcompat.a \
+	$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
 	$(top_builddir)/lib/libvarnishapi/libvarnishapi.la

Modified: branches/1.1/bin/varnishreplay/Makefile.am
===================================================================
--- branches/1.1/bin/varnishreplay/Makefile.am	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishreplay/Makefile.am	2007-08-09 12:12:12 UTC (rev 1818)
@@ -13,7 +13,7 @@
 
 varnishreplay_LDADD = \
 	$(top_builddir)/lib/libvarnish/libvarnish.la \
-	$(top_builddir)/lib/libcompat/libcompat.a \
+	$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
 	$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
 	${PTHREAD_LIBS}
 

Modified: branches/1.1/bin/varnishstat/Makefile.am
===================================================================
--- branches/1.1/bin/varnishstat/Makefile.am	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishstat/Makefile.am	2007-08-09 12:12:12 UTC (rev 1818)
@@ -12,6 +12,6 @@
 
 varnishstat_LDADD = \
 	$(top_builddir)/lib/libvarnish/libvarnish.la \
-	$(top_builddir)/lib/libcompat/libcompat.a \
+	$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
 	$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
 	${CURSES_LIBS} ${RT_LIBS}

Modified: branches/1.1/bin/varnishtop/Makefile.am
===================================================================
--- branches/1.1/bin/varnishtop/Makefile.am	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/bin/varnishtop/Makefile.am	2007-08-09 12:12:12 UTC (rev 1818)
@@ -12,6 +12,6 @@
 
 varnishtop_LDADD = \
 	$(top_builddir)/lib/libvarnish/libvarnish.la \
-	$(top_builddir)/lib/libcompat/libcompat.a \
+	$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
 	$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
 	${CURSES_LIBS} ${PTHREAD_LIBS}

Modified: branches/1.1/configure.ac
===================================================================
--- branches/1.1/configure.ac	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/configure.ac	2007-08-09 12:12:12 UTC (rev 1818)
@@ -50,6 +50,9 @@
 LIBS="${save_LIBS}"
 AC_SUBST(PTHREAD_LIBS)
 
+AC_CHECK_LIBM
+AC_SUBST(LIBM)
+
 # Checks for header files.
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
@@ -148,9 +151,9 @@
     etc/Makefile
     include/Makefile
     lib/Makefile
-    lib/libcompat/Makefile
     lib/libvarnish/Makefile
     lib/libvarnishapi/Makefile
+    lib/libvarnishcompat/Makefile
     lib/libvcl/Makefile
     man/Makefile
     debian/Makefile

Modified: branches/1.1/debian/changelog
===================================================================
--- branches/1.1/debian/changelog	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/debian/changelog	2007-08-09 12:12:12 UTC (rev 1818)
@@ -1,8 +1,9 @@
-varnish (1.1-1) unstable; urgency=low
+varnish (1.1) unstable; urgency=low
 
-  * New upstream version
+  * New upstream release
+  * Split package into varnish, libvarnish and libvarnish-dev
 
- -- des <des at linpro.no>  Thu,  5 Jul 2007 13:13:54 +0200
+ -- Stig Sandbeck Mathisen <ssm at linpro.no>  Fri, 20 Jul 2007 14:37:36 +0200
 
 varnish (1.0.4-1) unstable; urgency=low
 

Modified: branches/1.1/debian/control
===================================================================
--- branches/1.1/debian/control	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/debian/control	2007-08-09 12:12:12 UTC (rev 1818)
@@ -8,7 +8,7 @@
 
 Package: varnish
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, gcc ( >= 3.3)
+Depends: ${shlibs:Depends}, ${misc:Depends}, gcc ( >= 3.3), libvarnish
 Description: A state-of-the-art, high-performance HTTP accelerator
  varnish is the server-side alternative to Squid, written primarily with
  speed in mind, and with a look to implementing full ESI-support in
@@ -20,3 +20,27 @@
  Varnish is targeted primarily at the FreeBSD 6 and Linux 2.6 platforms, and
  will take full advantage of the advanced I/O features offered by these
  operating systems. 
+
+Package: libvarnish
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Shared library for Varnish
+ Shared library for Varnish.
+ .
+ Varnish is the server-side alternative to Squid, written primarily
+ with speed in mind.
+ .
+ The goal of the Varnish project is to develop a state-of-the-art,
+ high-performance HTTP accelerator.
+
+Package: libvarnish-dev
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libvarnish
+Description: Shared library for Varnish
+ Development files for the Varnish library.
+ .
+ Varnish is the server-side alternative to Squid, written primarily
+ with speed in mind.
+ .
+ The goal of the Varnish project is to develop a state-of-the-art,
+ high-performance HTTP accelerator.

Modified: branches/1.1/debian/dirs
===================================================================
--- branches/1.1/debian/dirs	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/debian/dirs	2007-08-09 12:12:12 UTC (rev 1818)
@@ -1,9 +0,0 @@
-etc/varnish
-etc/logrotate.d
-usr/bin
-usr/lib
-usr/sbin
-var/log
-var/log/varnish
-var/lib/varnish
-usr/share/lintian/overrides/

Copied: branches/1.1/debian/libvarnish-dev.dirs (from rev 1743, trunk/varnish-cache/debian/libvarnish-dev.dirs)
===================================================================
--- branches/1.1/debian/libvarnish-dev.dirs	                        (rev 0)
+++ branches/1.1/debian/libvarnish-dev.dirs	2007-08-09 12:12:12 UTC (rev 1818)
@@ -0,0 +1 @@
+usr/lib

Copied: branches/1.1/debian/libvarnish-dev.install (from rev 1743, trunk/varnish-cache/debian/libvarnish-dev.install)
===================================================================
--- branches/1.1/debian/libvarnish-dev.install	                        (rev 0)
+++ branches/1.1/debian/libvarnish-dev.install	2007-08-09 12:12:12 UTC (rev 1818)
@@ -0,0 +1,3 @@
+usr/include
+usr/lib/*.a
+usr/lib/*.la

Copied: branches/1.1/debian/libvarnish.dirs (from rev 1743, trunk/varnish-cache/debian/libvarnish.dirs)
===================================================================
--- branches/1.1/debian/libvarnish.dirs	                        (rev 0)
+++ branches/1.1/debian/libvarnish.dirs	2007-08-09 12:12:12 UTC (rev 1818)
@@ -0,0 +1 @@
+usr/lib

Copied: branches/1.1/debian/libvarnish.install (from rev 1743, trunk/varnish-cache/debian/libvarnish.install)
===================================================================
--- branches/1.1/debian/libvarnish.install	                        (rev 0)
+++ branches/1.1/debian/libvarnish.install	2007-08-09 12:12:12 UTC (rev 1818)
@@ -0,0 +1 @@
+usr/lib/lib*.so.*

Modified: branches/1.1/debian/rules
===================================================================
--- branches/1.1/debian/rules	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/debian/rules	2007-08-09 12:12:12 UTC (rev 1818)
@@ -66,7 +66,9 @@
 	dh_clean -k 
 	dh_installdirs
 
-	$(MAKE) install DESTDIR=$(CURDIR)/debian/varnish
+	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
+	dh_install --sourcedir=$(CURDIR)/debian/tmp
+
 	install -m 644 $(CURDIR)/etc/default.vcl $(CURDIR)/debian/varnish/etc/varnish/
 	install -m 644 $(CURDIR)/debian/lintian-override $(CURDIR)/debian/varnish/usr/share/lintian/overrides/varnish
 	install -m 644 $(CURDIR)/debian/varnish.logrotate $(CURDIR)/debian/varnish/etc/logrotate.d/varnish


Property changes on: branches/1.1/debian/rules
___________________________________________________________________
Name: svn
   + executable

Modified: branches/1.1/debian/varnish.default
===================================================================
--- branches/1.1/debian/varnish.default	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/debian/varnish.default	2007-08-09 12:12:12 UTC (rev 1818)
@@ -17,6 +17,7 @@
 DAEMON_OPTS="-a :6081 \
              -T localhost:6082 \
 	     -b localhost:8080 \
+	     -n /var/lib/varnish \
 	     -s file,/var/lib/varnish/varnish_storage.bin,1G"
 
 
@@ -29,6 +30,7 @@
 # DAEMON_OPTS="-a :6081 \
 #              -T localhost:6082 \
 #              -f /etc/varnish/default.vcl \
+#              -n /var/lib/varnish \
 #              -s file,/var/lib/varnish/varnish_storage.bin,1G"
 
 
@@ -58,6 +60,9 @@
 # # Idle timeout for worker threads
 # VARNISH_THREAD_TIMEOUT=120
 #
+# # Home dir for this varnish instance
+# VARNISH_HOMEDIR=/var/lib/varnish
+#
 # # Cache file location
 # VARNISH_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin
 #
@@ -78,6 +83,7 @@
 #              -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
 #              -t ${VARNISH_TTL} \
 #              -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \
+#              -n ${VARNISH_HOMEDIR} \
 #              -s ${VARNISH_STORAGE}"
 #
 

Copied: branches/1.1/debian/varnish.dirs (from rev 1743, trunk/varnish-cache/debian/varnish.dirs)
===================================================================
--- branches/1.1/debian/varnish.dirs	                        (rev 0)
+++ branches/1.1/debian/varnish.dirs	2007-08-09 12:12:12 UTC (rev 1818)
@@ -0,0 +1,8 @@
+etc/varnish
+etc/logrotate.d
+usr/bin
+usr/sbin
+var/log
+var/log/varnish
+var/lib/varnish
+usr/share/lintian/overrides/

Copied: branches/1.1/debian/varnish.install (from rev 1743, trunk/varnish-cache/debian/varnish.install)
===================================================================
--- branches/1.1/debian/varnish.install	                        (rev 0)
+++ branches/1.1/debian/varnish.install	2007-08-09 12:12:12 UTC (rev 1818)
@@ -0,0 +1,2 @@
+usr/bin
+usr/sbin

Modified: branches/1.1/debian/varnish.varnishlog.init
===================================================================
--- branches/1.1/debian/varnish.varnishlog.init	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/debian/varnish.varnishlog.init	2007-08-09 12:12:12 UTC (rev 1818)
@@ -24,7 +24,7 @@
 
 test -x $DAEMON || exit 0
 
-DAEMON_OPTS="-a -w ${LOGFILE} -D -P $PIDFILE"
+DAEMON_OPTS="-a -n /var/lib/varnish -w ${LOGFILE} -D -P $PIDFILE"
 
 case "$1" in
 	start)

Modified: branches/1.1/etc/default.vcl
===================================================================
--- branches/1.1/etc/default.vcl	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/etc/default.vcl	2007-08-09 12:12:12 UTC (rev 1818)
@@ -75,14 +75,27 @@
 #	if (!obj.cacheable) {
 #		pass;
 #	}
-#	if (resp.http.Set-Cookie) {
+#	if (obj.http.Set-Cookie) {
 #		pass;
 #	}
 #	insert;
 #}
 #
+#
+## Called before a cached object is delivered to the client
+#
+#sub vcl_deliver {
+#    deliver;
+#}
+#
 ## Called when an object nears its expiry time
 #
 #sub vcl_timeout {
 #	discard;
 #}
+#
+## Called when an object is about to be discarded
+#
+#sub vcl_discard {
+#    discard;
+#}

Modified: branches/1.1/include/compat/vis.h
===================================================================
--- branches/1.1/include/compat/vis.h	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/include/compat/vis.h	2007-08-09 12:12:12 UTC (rev 1818)
@@ -71,15 +71,17 @@
  */
 #define	UNVIS_END	1	/* no more characters */
 
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
 char	*vis(char *, int, int, int);
 int	strvis(char *, const char *, int);
 int	strvisx(char *, const char *, size_t, int);
 int	strunvis(char *, const char *);
 int	strunvisx(char *, const char *, int);
 int	unvis(char *, int, int *, int);
-__END_DECLS
+#ifdef __cplusplus
+};
+#endif
 
 #endif /* !_VIS_H_ */

Modified: branches/1.1/include/libvarnish.h
===================================================================
--- branches/1.1/include/libvarnish.h	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/include/libvarnish.h	2007-08-09 12:12:12 UTC (rev 1818)
@@ -42,6 +42,7 @@
 char **ParseArgv(const char *s, int comment);
 
 /* from libvarnish/crc32.c */
+uint32_t crc32(uint32_t crc, const void *p1, unsigned l);
 uint32_t crc32_l(const void *p1, unsigned l);
 
 /* from libvarnish/time.c */

Modified: branches/1.1/include/vcl.h
===================================================================
--- branches/1.1/include/vcl.h	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/include/vcl.h	2007-08-09 12:12:12 UTC (rev 1818)
@@ -26,6 +26,8 @@
 	const char	**srcname;
 	const char	**srcbody;
 
+	unsigned	nhashcount;
+
         void            *priv;
 
         vcl_init_f      *init_func;

Modified: branches/1.1/include/vrt.h
===================================================================
--- branches/1.1/include/vrt.h	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/include/vrt.h	2007-08-09 12:12:12 UTC (rev 1818)
@@ -70,6 +70,8 @@
 int VRT_re_test(struct vsb *, const char *, int sub);
 const char *VRT_regsub(struct sess *sp, const char *, void *, const char *);
 
+void VRT_purge(const char *);
+
 void VRT_count(struct sess *, unsigned);
 int VRT_rewrite(const char *, const char *);
 void VRT_error(struct sess *, unsigned, const char *);

Modified: branches/1.1/include/vsb.h
===================================================================
--- branches/1.1/include/vsb.h	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/include/vsb.h	2007-08-09 12:12:12 UTC (rev 1818)
@@ -50,7 +50,9 @@
 	int		 s_flags;	/* flags */
 };
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
 /*
  * API functions
  */
@@ -73,6 +75,8 @@
 int		 vsb_len(struct vsb *);
 int		 vsb_done(struct vsb *);
 void		 vsb_delete(struct vsb *);
-__END_DECLS
+#ifdef __cplusplus
+};
+#endif
 
 #endif

Modified: branches/1.1/lib/Makefile.am
===================================================================
--- branches/1.1/lib/Makefile.am	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/lib/Makefile.am	2007-08-09 12:12:12 UTC (rev 1818)
@@ -1,7 +1,7 @@
 # $Id$
 
 SUBDIRS = \
-	libcompat \
 	libvarnish \
 	libvarnishapi \
+	libvarnishcompat \
 	libvcl

Modified: branches/1.1/lib/libvarnish/crc32.c
===================================================================
--- branches/1.1/lib/libvarnish/crc32.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/lib/libvarnish/crc32.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -82,14 +82,21 @@
 };
 
 uint32_t
-crc32_l(const void *p1, unsigned l)
+crc32(uint32_t crc, const void *p1, unsigned l)
 {
 	const unsigned char *p;
-	uint32_t crc;
 
-	crc = ~0U;
-
 	for (p = (const unsigned char*)p1; l-- > 0; p++)
 		crc = (crc >> 8) ^ crc32bits[(crc ^ *p) & 0xff];
+	return (crc);
+}
+
+uint32_t
+crc32_l(const void *p1, unsigned l)
+{
+	uint32_t crc;
+
+	crc = crc32(~0U, p1, l);
 	return (crc ^ ~0U);
 }
+

Modified: branches/1.1/lib/libvarnish/flopen.c
===================================================================
--- branches/1.1/lib/libvarnish/flopen.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/lib/libvarnish/flopen.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -44,6 +44,7 @@
 {
 	int fd, operation, serrno, trunc;
 	struct stat sb, fsb;
+	struct flock lock;
 	mode_t mode;
 
 #ifdef O_EXLOCK
@@ -59,9 +60,11 @@
 		va_end(ap);
 	}
 
-	operation = LOCK_EX;
-	if (flags & O_NONBLOCK)
-		operation |= LOCK_NB;
+	lock.l_type = (flags & O_RDONLY) ? F_RDLCK : F_WRLCK;
+	lock.l_start = 0;
+	lock.l_whence = SEEK_SET;
+	lock.l_len = 0;
+	operation = (flags & O_NONBLOCK) ? F_SETLK : F_SETLKW;
 
 	trunc = (flags & O_TRUNC);
 	flags &= ~O_TRUNC;
@@ -70,7 +73,7 @@
 		if ((fd = open(path, flags, mode)) == -1)
 			/* non-existent or no access */
 			return (-1);
-		if (flock(fd, operation) == -1) {
+		if (fcntl(fd, operation, &lock) == -1) {
 			/* unsupported or interrupted */
 			serrno = errno;
 			close(fd);

Modified: branches/1.1/lib/libvarnish/time.c
===================================================================
--- branches/1.1/lib/libvarnish/time.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/lib/libvarnish/time.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -113,7 +113,7 @@
 	for (r = fmts; *r != NULL; r++) {
 		memset(&tm, 0, sizeof tm);
 		if (strptime(p, *r, &tm) != NULL)
-			return(timegm(&tm));
+			return (mktime(&tm));
 	}
 	return (0);
 }

Modified: branches/1.1/lib/libvarnish/vpf.c
===================================================================
--- branches/1.1/lib/libvarnish/vpf.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/lib/libvarnish/vpf.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -32,13 +32,12 @@
 #include <sys/file.h>
 #include <sys/stat.h>
 
+#include <errno.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <err.h>
-#include <errno.h>
 
 #ifndef HAVE_STRLCPY
 #include "compat/strlcpy.h"
@@ -223,8 +222,14 @@
 static int
 _vpf_remove(struct pidfh *pfh, int freeit)
 {
+	struct flock lock;
 	int error;
 
+	lock.l_type = F_UNLCK;
+	lock.l_start = 0;
+	lock.l_whence = SEEK_SET;
+	lock.l_len = 0;
+
 	error = vpf_verify(pfh);
 	if (error != 0) {
 		errno = error;
@@ -233,7 +238,7 @@
 
 	if (unlink(pfh->pf_path) == -1)
 		error = errno;
-	if (flock(pfh->pf_fd, LOCK_UN) == -1) {
+	if (fcntl(pfh->pf_fd, F_SETLK, &lock) == -1) {
 		if (error == 0)
 			error = errno;
 	}

Copied: branches/1.1/lib/libvarnishcompat (from rev 1817, trunk/varnish-cache/lib/libvarnishcompat)


Property changes on: branches/1.1/lib/libvarnishcompat
___________________________________________________________________
Name: svn:ignore
   + .deps
.libs
Makefile
Makefile.in
libcompat.a

Modified: branches/1.1/lib/libvcl/vcc_action.c
===================================================================
--- branches/1.1/lib/libvcl/vcc_action.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/lib/libvcl/vcc_action.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -206,6 +206,12 @@
 			return;
 		}
 		Fb(tl, 0, ");\n");
+		/*
+		 * We count the number of operations on the req.hash
+		 * variable, so that varnishd can preallocate the worst case
+		 * number of slots for composing the hash string.
+		 */
+		tl->nhashcount++;
 		break;
 	case STRING:
 		if (tl->t->tok != '=') {
@@ -263,6 +269,30 @@
 
 /*--------------------------------------------------------------------*/
 
+static void
+parse_purge(struct tokenlist *tl)
+{
+
+	vcc_NextToken(tl);
+	
+	Fb(tl, 0, "VRT_purge(");
+	
+	Expect(tl, '(');
+	vcc_NextToken(tl);
+	
+	if (!vcc_StringVal(tl)) {
+		vcc_ExpectedStringval(tl);
+		return;
+	}
+	
+	Expect(tl, ')');
+	vcc_NextToken(tl);
+	Fb(tl, 0, ");");
+}
+
+
+/*--------------------------------------------------------------------*/
+
 typedef void action_f(struct tokenlist *tl);
 
 static struct action_table {
@@ -277,6 +307,7 @@
 	{ "call", 	parse_call },
 	{ "set", 	parse_set },
 	{ "remove", 	parse_remove },
+	{ "purge",	parse_purge },
 	{ NULL,		NULL }
 };
 

Modified: branches/1.1/lib/libvcl/vcc_compile.c
===================================================================
--- branches/1.1/lib/libvcl/vcc_compile.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/lib/libvcl/vcc_compile.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -348,6 +348,7 @@
 	Fc(tl, 0, "\t.nsrc = %u,\n", tl->nsources);
 	Fc(tl, 0, "\t.srcname = srcname,\n");
 	Fc(tl, 0, "\t.srcbody = srcbody,\n");
+	Fc(tl, 0, "\t.nhashcount = %u,\n", tl->nhashcount);
 #define VCL_RET_MAC(l,u,b,n)
 #define VCL_MET_MAC(l,u,b) \
 	Fc(tl, 0, "\t." #l "_func = VGC_function_vcl_" #l ",\n"); 

Modified: branches/1.1/lib/libvcl/vcc_compile.h
===================================================================
--- branches/1.1/lib/libvcl/vcc_compile.h	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/lib/libvcl/vcc_compile.h	2007-08-09 12:12:12 UTC (rev 1818)
@@ -83,6 +83,7 @@
 	struct proc		*mprocs[N_METHODS];
 
 	unsigned		recnt;
+	unsigned		nhashcount;
 };
 
 enum var_type {

Modified: branches/1.1/lib/libvcl/vcc_fixed_token.c
===================================================================
--- branches/1.1/lib/libvcl/vcc_fixed_token.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/lib/libvcl/vcc_fixed_token.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -338,6 +338,8 @@
 	vsb_cat(sb, "	const char	**srcname;\n");
 	vsb_cat(sb, "	const char	**srcbody;\n");
 	vsb_cat(sb, "\n");
+	vsb_cat(sb, "	unsigned	nhashcount;\n");
+	vsb_cat(sb, "\n");
 	vsb_cat(sb, "        void            *priv;\n");
 	vsb_cat(sb, "\n");
 	vsb_cat(sb, "        vcl_init_f      *init_func;\n");
@@ -426,6 +428,8 @@
 	vsb_cat(sb, "int VRT_re_test(struct vsb *, const char *, int sub);\n");
 	vsb_cat(sb, "const char *VRT_regsub(struct sess *sp, const char *, void *, const char *);\n");
 	vsb_cat(sb, "\n");
+	vsb_cat(sb, "void VRT_purge(const char *);\n");
+	vsb_cat(sb, "\n");
 	vsb_cat(sb, "void VRT_count(struct sess *, unsigned);\n");
 	vsb_cat(sb, "int VRT_rewrite(const char *, const char *);\n");
 	vsb_cat(sb, "void VRT_error(struct sess *, unsigned, const char *);\n");

Modified: branches/1.1/lib/libvcl/vcc_gen_fixed_token.tcl
===================================================================
--- branches/1.1/lib/libvcl/vcc_gen_fixed_token.tcl	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/lib/libvcl/vcc_gen_fixed_token.tcl	2007-08-09 12:12:12 UTC (rev 1818)
@@ -142,6 +142,8 @@
 	const char	**srcname;
 	const char	**srcbody;
 
+	unsigned	nhashcount;
+
         void            *priv;
 
         vcl_init_f      *init_func;

Modified: branches/1.1/lib/libvcl/vcc_parse.c
===================================================================
--- branches/1.1/lib/libvcl/vcc_parse.c	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/lib/libvcl/vcc_parse.c	2007-08-09 12:12:12 UTC (rev 1818)
@@ -38,8 +38,6 @@
 #include "vcc_compile.h"
 #include "libvarnish.h"
 
-#include "vrt.h"
-
 /*--------------------------------------------------------------------*/
 
 static void Compound(struct tokenlist *tl);

Modified: branches/1.1/man/vcl.7
===================================================================
--- branches/1.1/man/vcl.7	2007-08-09 11:19:20 UTC (rev 1817)
+++ branches/1.1/man/vcl.7	2007-08-09 12:12:12 UTC (rev 1818)
@@ -28,7 +28,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd July 13, 2007
+.Dd August 3, 2007
 .Dt VCL 7
 .Os
 .Sh NAME
@@ -136,6 +136,9 @@
 is replaced with the contents of subgroup
 .Ar n
 in the matched string.
+.It Fn purge "regex"
+Purge all objects in cache matching 
+.Fa regex .
 .El
 .Ss Subroutines
 A subroutine is used to group code for legibility or reusability:
@@ -471,7 +474,7 @@
 The following code is the equivalent of the default configuration with
 the backend address set to "backend.example.com" and no backend port
 specified.
-.\" Keep this in synch with bin/varnishd/mgt_vcc.c
+.\" Keep this in synch with bin/varnishd/mgt_vcc.c and etc/default.vcl
 .Bd -literal -offset 4n
 backend default {
     set backend.host = "backend.example.com";
@@ -531,11 +534,11 @@
     deliver;
 }
 
-sub vcl_discard {
+sub vcl_timeout {
     discard;
 }
 
-sub vcl_timeout {
+sub vcl_discard {
     discard;
 }
 .Ed
@@ -556,8 +559,9 @@
 
 sub vcl_recv {
     if (req.http.host ~ "^(www\.)?example\.com$") {
+        set req.http.host = "www.example.com";
         set req.backend = www;
-    } elsif (req.http.host ~ "^images\.example\.com") {
+    } elsif (req.http.host ~ "^images\.example\.com$") {
         set req.backend = images;
     } else {
         error 404 "Unknown virtual host";




More information about the varnish-commit mailing list