r1401 - in branches/1.0: . bin/varnishd bin/varnishhist bin/varnishlog bin/varnishncsa bin/varnishstat bin/varnishtop include lib/libvarnishapi lib/libvcl man

des at projects.linpro.no des at projects.linpro.no
Thu May 10 13:58:14 CEST 2007


Author: des
Date: 2007-05-10 13:58:14 +0200 (Thu, 10 May 2007)
New Revision: 1401

Modified:
   branches/1.0/
   branches/1.0/autogen.des
   branches/1.0/autogen.sh
   branches/1.0/bin/varnishd/Makefile.am
   branches/1.0/bin/varnishd/cache.h
   branches/1.0/bin/varnishd/cache_acceptor_epoll.c
   branches/1.0/bin/varnishd/cache_backend.c
   branches/1.0/bin/varnishd/cache_center.c
   branches/1.0/bin/varnishd/cache_fetch.c
   branches/1.0/bin/varnishd/cache_hash.c
   branches/1.0/bin/varnishd/cache_http.c
   branches/1.0/bin/varnishd/cache_response.c
   branches/1.0/bin/varnishd/cache_vrt.c
   branches/1.0/bin/varnishd/heritage.h
   branches/1.0/bin/varnishd/mgt_child.c
   branches/1.0/bin/varnishd/mgt_param.c
   branches/1.0/bin/varnishd/mgt_vcc.c
   branches/1.0/bin/varnishd/rfc2616.c
   branches/1.0/bin/varnishd/storage_file.c
   branches/1.0/bin/varnishd/varnishd.1
   branches/1.0/bin/varnishhist/Makefile.am
   branches/1.0/bin/varnishhist/varnishhist.c
   branches/1.0/bin/varnishlog/varnishlog.1
   branches/1.0/bin/varnishlog/varnishlog.c
   branches/1.0/bin/varnishncsa/varnishncsa.1
   branches/1.0/bin/varnishncsa/varnishncsa.c
   branches/1.0/bin/varnishstat/Makefile.am
   branches/1.0/bin/varnishtop/Makefile.am
   branches/1.0/configure.ac
   branches/1.0/include/shmlog.h
   branches/1.0/include/varnishapi.h
   branches/1.0/lib/libvarnishapi/shmlog.c
   branches/1.0/lib/libvcl/vcc_priv.h
   branches/1.0/man/vcl.7
Log:
Merged revisions 1359-1387,1399 via svnmerge from 
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache

........
  r1359 | phk | 2007-04-19 17:17:35 +0200 (Thu, 19 Apr 2007) | 9 lines
  
  When we have some amount of a chunk header, but not all of it, we
  need to read more from the fd.  The semantics we _really_ want for
  that read operation is "wait until at least one char is available,
  then return as many as N to us".
  
  This can be done with a combination of system calls, but it is likely
  just as cheap to just read one char at a time, so we do that.
........
  r1360 | des | 2007-04-21 19:48:21 +0200 (Sat, 21 Apr 2007) | 2 lines
  
  Clarify synopsis / description
........
  r1361 | des | 2007-04-21 19:52:44 +0200 (Sat, 21 Apr 2007) | 2 lines
  
  Style and whitespace cleanup + clarify comment explaining the log format
........
  r1362 | des | 2007-04-21 23:48:56 +0200 (Sat, 21 Apr 2007) | 12 lines
  
  Major rewrite of the VSL handler for increased robustness and clarity:
  
   - Treat all request fields in a similar manner.
  
   - Mostly eliminate fixed-size buffers.
  
   - Don't print or format anything until we see ReqEnd.
  
   - If we saw a Host: header, use it to generate an absolute URI,
     resulting in far more useful output when processing logs from a
     server which handles multiple virtual hosts.
........
  r1363 | des | 2007-04-22 15:09:59 +0200 (Sun, 22 Apr 2007) | 2 lines
  
  Further eliminate fixed-size buffers.
........
  r1364 | des | 2007-04-24 11:39:12 +0200 (Tue, 24 Apr 2007) | 6 lines
  
  Correctly detect the presence and location of all external library we use
  (except for the C math library, which the C standard guarantees is always
  available as -lm) and more importantly, use them only where needed.
  
  This should fix the compilation issues on SuSE.
........
  r1365 | des | 2007-04-24 14:23:37 +0200 (Tue, 24 Apr 2007) | 3 lines
  
  Move CFLAGS configuration to the bottom so it doesn't affect other tests.
  This makes --enable-werror work again.
........
  r1366 | des | 2007-04-24 14:36:58 +0200 (Tue, 24 Apr 2007) | 3 lines
  
  Move CFLAGS configuration to the bottom so it doesn't affect other tests.
  This makes --enable-werror work again.
........
  r1367 | des | 2007-04-24 14:37:58 +0200 (Tue, 24 Apr 2007) | 2 lines
  
  Eliminate warnings.
........
  r1368 | phk | 2007-04-26 08:54:58 +0200 (Thu, 26 Apr 2007) | 5 lines
  
  Add compat trick for clock_gettime()
  
  Submitted by:	Pierre Queinnec <pierre.queinnec at zenika.com>
........
  r1369 | des | 2007-04-26 12:39:19 +0200 (Thu, 26 Apr 2007) | 2 lines
  
  Force CONFIG_SHELL to /bin/sh.
........
  r1370 | des | 2007-05-01 19:48:56 +0200 (Tue, 01 May 2007) | 2 lines
  
  Add protective #ifdef.
........
  r1371 | des | 2007-05-01 19:55:13 +0200 (Tue, 01 May 2007) | 2 lines
  
  Improve the readability and debuggability of our tag conversion tricks.
........
  r1372 | des | 2007-05-01 19:55:31 +0200 (Tue, 01 May 2007) | 8 lines
  
  Two minor logging fixes:
   
   - change the type of vsl_handler()'s tag argument from unsigned int to
     enum shmlogtag to allow gcc to check switch statements and gdb to show
     its value by name rather than by number.
   
   - fix the "missing newline after VCL_call" bug in varnishlog (#95)
........
  r1373 | des | 2007-05-01 20:21:53 +0200 (Tue, 01 May 2007) | 4 lines
  
  Add and document a ping_interval parameter which controls the interval at
  which the parent pings the child.  Also document pipe_timeout, which was
  left out of the man page by accident.
........
  r1374 | des | 2007-05-02 14:20:43 +0200 (Wed, 02 May 2007) | 4 lines
  
  Try fixing #95 again.  The trick is that if we get a new SLT_VCL_call
  while the F_INVCL flag is set, we need to insert a newline before the
  entry for the new VCL_call.
........
  r1375 | des | 2007-05-02 15:56:24 +0200 (Wed, 02 May 2007) | 2 lines
  
  Correct the URL in the error page.
........
  r1376 | des | 2007-05-02 16:37:42 +0200 (Wed, 02 May 2007) | 6 lines
  
  Don't try to lock the objhead mutex if we don't have an objhead.  Doing so
  caused the Varnish child to die immediately after sending its 503 response
  if the backend didn't respond.
  
  Reviewed by:	phk
........
  r1377 | des | 2007-05-03 10:41:01 +0200 (Thu, 03 May 2007) | 2 lines
  
  s/expl/reason/ to circumvent a bug in gcc 3.
........
  r1378 | des | 2007-05-03 10:45:33 +0200 (Thu, 03 May 2007) | 2 lines
  
  s/expl/reason/ to circumvent a bug in gcc 3.
........
  r1379 | des | 2007-05-03 10:48:43 +0200 (Thu, 03 May 2007) | 2 lines
  
  s/expl/reason/ to circumvent a bug in gcc 3.
........
  r1380 | des | 2007-05-03 10:48:51 +0200 (Thu, 03 May 2007) | 2 lines
  
  s/expl/explicit/ to circumvent a bug in gcc 3.
........
  r1381 | phk | 2007-05-04 14:25:23 +0200 (Fri, 04 May 2007) | 2 lines
  
  Fix error reporting with -C
........
  r1382 | des | 2007-05-04 14:28:56 +0200 (Fri, 04 May 2007) | 2 lines
  
  Apply the workaround suggested in #102.
........
  r1383 | des | 2007-05-05 16:08:01 +0200 (Sat, 05 May 2007) | 2 lines
  
  Whitespace nits
........
  r1384 | des | 2007-05-05 16:09:23 +0200 (Sat, 05 May 2007) | 2 lines
  
  Typo in comment
........
  r1385 | des | 2007-05-05 16:35:58 +0200 (Sat, 05 May 2007) | 2 lines
  
  Remove superfluous vsb_printf() argument
........
  r1386 | des | 2007-05-05 16:44:37 +0200 (Sat, 05 May 2007) | 2 lines
  
  Look for s-maxage before max-age.  This may need to be revisited.
........
  r1387 | des | 2007-05-06 20:57:26 +0200 (Sun, 06 May 2007) | 2 lines
  
  Update the default configuration.
........
  r1399 | des | 2007-05-09 16:37:04 +0200 (Wed, 09 May 2007) | 2 lines
  
  Correctly detect more incompatible automake versions.
........



Property changes on: branches/1.0
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk/varnish-cache:1-1315
   + /trunk/varnish-cache:1-1315,1359-1387,1399

Modified: branches/1.0/autogen.des
===================================================================
--- branches/1.0/autogen.des	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/autogen.des	2007-05-10 11:58:14 UTC (rev 1401)
@@ -7,8 +7,10 @@
 
 ./autogen.sh
 
+CONFIG_SHELL=/bin/sh \
 ./configure \
     --enable-developer-warnings \
     --enable-debugging-symbols \
     --enable-dependency-tracking \
+    --enable-werror \
     --prefix=/opt/varnish

Modified: branches/1.0/autogen.sh
===================================================================
--- branches/1.0/autogen.sh	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/autogen.sh	2007-05-10 11:58:14 UTC (rev 1401)
@@ -15,7 +15,7 @@
     exit 1
 else
     case $automake_version in
-	0.*|1.[0-8])
+	0.*|1.[0-8]|1.[0-8][.-]*)
 	    echo "your version of automake ($automake_version) is too old;" \
 		"you need 1.9 or newer."
 	    exit 1

Modified: branches/1.0/bin/varnishd/Makefile.am
===================================================================
--- branches/1.0/bin/varnishd/Makefile.am	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/Makefile.am	2007-05-10 11:58:14 UTC (rev 1401)
@@ -61,4 +61,5 @@
 varnishd_LDADD = \
 	$(top_builddir)/lib/libcompat/libcompat.a \
 	$(top_builddir)/lib/libvarnish/libvarnish.la \
-	$(top_builddir)/lib/libvcl/libvcl.la
+	$(top_builddir)/lib/libvcl/libvcl.la \
+	${DL_LIBS} ${RT_LIBS} ${PTHREAD_LIBS}

Modified: branches/1.0/bin/varnishd/cache.h
===================================================================
--- branches/1.0/bin/varnishd/cache.h	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/cache.h	2007-05-10 11:58:14 UTC (rev 1401)
@@ -275,7 +275,7 @@
 	unsigned 		handling;
 	unsigned char		wantbody;
 	int			err_code;
-	const char		*err_expl;
+	const char		*err_reason;
 
 	TAILQ_ENTRY(sess)	list;
 
@@ -428,7 +428,7 @@
 #endif
 
 /* cache_response.c */
-void RES_Error(struct sess *sp, int code, const char *expl);
+void RES_Error(struct sess *sp, int code, const char *reason);
 void RES_WriteObj(struct sess *sp);
 
 /* cache_vcl.c */

Modified: branches/1.0/bin/varnishd/cache_acceptor_epoll.c
===================================================================
--- branches/1.0/bin/varnishd/cache_acceptor_epoll.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/cache_acceptor_epoll.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -70,13 +70,6 @@
 	AZ(epoll_ctl(epfd, EPOLL_CTL_DEL, fd, &ev));
 }
 
-static void
-vca_rcvhdev(struct sess *sp)
-{
-
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-}
-
 static void *
 vca_main(void *arg)
 {

Modified: branches/1.0/bin/varnishd/cache_backend.c
===================================================================
--- branches/1.0/bin/varnishd/cache_backend.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/cache_backend.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -48,6 +48,10 @@
 #include <sys/select.h>
 #include <sys/ioctl.h>
 
+#ifndef HAVE_CLOCK_GETTIME
+#include "compat/clock_gettime.h"
+#endif
+
 #include "heritage.h"
 #include "shmlog.h"
 #include "cache.h"

Modified: branches/1.0/bin/varnishd/cache_center.c
===================================================================
--- branches/1.0/bin/varnishd/cache_center.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/cache_center.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -74,6 +74,10 @@
 #include "compat/clock_gettime.h"
 #endif
 
+#ifndef HAVE_SRANDOMDEV
+#include "compat/srandomdev.h"
+#endif
+
 #include "shmlog.h"
 #include "vcl.h"
 #include "cache.h"
@@ -243,9 +247,9 @@
 cnt_error(struct sess *sp)
 {
 
-	RES_Error(sp, sp->err_code, sp->err_expl);
+	RES_Error(sp, sp->err_code, sp->err_reason);
 	sp->err_code = 0;
-	sp->err_expl = NULL;
+	sp->err_reason = NULL;
 	sp->step = STP_DONE;
 	return (0);
 }
@@ -653,7 +657,8 @@
 
 	VCL_recv_method(sp);
 
-	sp->wantbody = !strcmp(sp->http->hd[HTTP_HDR_REQ].b, "GET");
+	sp->wantbody = (!strcmp(sp->http->hd[HTTP_HDR_REQ].b, "GET") ||
+	    !strcmp(sp->http->hd[HTTP_HDR_REQ].b, "POST"));
 	switch(sp->handling) {
 	case VCL_RET_LOOKUP:
 		/* XXX: discard req body, if any */

Modified: branches/1.0/bin/varnishd/cache_fetch.c
===================================================================
--- branches/1.0/bin/varnishd/cache_fetch.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/cache_fetch.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -113,7 +113,22 @@
 		/* If we didn't succeed, add to buffer, try again */
 		if (q == NULL || q == buf || *q != '\n') {
 			xxxassert(be > bp);
-			i = http_Read(hp, fd, bp, be - bp);
+			/*
+			 * The sematics we need here is "read until you have
+			 * received at least one character, but feel free to
+			 * return up to (be-bp) if they are available, but do
+			 * not wait for those extra characters.
+			 *
+			 * The canonical way to do that is to do a blocking
+			 * read(2) of one char, then change to nonblocking,
+			 * read as many as we find, then change back to
+			 * blocking reads again.
+			 *
+			 * Hardly much more efficient and certainly a good
+			 * deal more complex than reading a single character
+			 * at a time.
+			 */
+			i = http_Read(hp, fd, bp, 1);
 			if (i <= 0)
 				return (-1);
 			bp += i;
@@ -296,13 +311,13 @@
 		/* XXX: cleanup */
 		return (1);
 	}
+
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
 
 	sp->obj->entered = time(NULL);
 
-
 	assert(sp->obj->busy != 0);
 
 	if (http_GetHdr(vc->http, H_Last_Modified, &b))

Modified: branches/1.0/bin/varnishd/cache_hash.c
===================================================================
--- branches/1.0/bin/varnishd/cache_hash.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/cache_hash.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -185,6 +185,7 @@
 void
 HSH_Unbusy(struct object *o)
 {
+	struct objhead *oh;
 	struct sess *sp;
 
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
@@ -192,9 +193,14 @@
 	assert(o->refcnt > 0);
 	if (o->cacheable)
 		EXP_Insert(o);
-	LOCK(&o->objhead->mtx);
+	oh = o->objhead;
+	if (oh != NULL) {
+		CHECK_OBJ(oh, OBJHEAD_MAGIC);
+		LOCK(&oh->mtx);
+	}
 	o->busy = 0;
-	UNLOCK(&o->objhead->mtx);
+	if (oh != NULL)
+		UNLOCK(&oh->mtx);
 	while (1) {
 		sp = TAILQ_FIRST(&o->waitinglist);
 		if (sp == NULL)

Modified: branches/1.0/bin/varnishd/cache_http.c
===================================================================
--- branches/1.0/bin/varnishd/cache_http.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/cache_http.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -77,7 +77,7 @@
 };
 
 static enum shmlogtag
-T(struct http *hp, enum httptag t)
+http2shmlog(struct http *hp, enum httptag t)
 {
 
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
@@ -86,9 +86,13 @@
 	return (logmtx[hp->logtag][t]);
 }
 
-#define WSLH(wx, ax, bx, cx, dx) \
-	WSLR(wx, T((cx), (ax)), (bx), (cx)->hd[(dx)].b, (cx)->hd[(dx)].e);
+static void
+WSLH(struct worker *w, enum httptag t, unsigned xid, struct http *hp, int hdr)
+{
 
+	WSLR(w, http2shmlog(hp, t), xid, hp->hd[hdr].b, hp->hd[hdr].e);
+}
+
 /*--------------------------------------------------------------------*/
 
 void
@@ -372,7 +376,7 @@
 			hp->nhd++;
 		} else {
 			VSL_stats->losthdr++;
-			WSLR(w, T(hp, HTTP_T_LostHeader), fd, p, q);
+			WSLR(w, http2shmlog(hp, HTTP_T_LostHeader), fd, p, q);
 		}
 	}
 	assert(hp->t <= hp->v);
@@ -803,7 +807,7 @@
 	CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
 	if (to->nhd >= HTTP_HDR_MAX) {
 		VSL_stats->losthdr++;
-		WSL(w, T(to, HTTP_T_LostHeader), fd, "%s", hdr);
+		WSL(w, http2shmlog(to, HTTP_T_LostHeader), fd, "%s", hdr);
 		return;
 	}
 	http_seth(w, fd, to, to->nhd++, HTTP_T_Header, hdr);
@@ -823,7 +827,7 @@
 	n = vsnprintf(to->f, l, fmt, ap);
 	if (n + 1 > l || to->nhd >= HTTP_HDR_MAX) {
 		VSL_stats->losthdr++;
-		WSL(w, T(to, HTTP_T_LostHeader), fd, "%s", to->f);
+		WSL(w, http2shmlog(to, HTTP_T_LostHeader), fd, "%s", to->f);
 	} else {
 		assert(to->f < to->e);
 		to->hd[to->nhd].b = to->f;

Modified: branches/1.0/bin/varnishd/cache_response.c
===================================================================
--- branches/1.0/bin/varnishd/cache_response.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/cache_response.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -48,7 +48,7 @@
 static struct http_msg {
 	unsigned	nbr;
 	const char	*txt;
-	const char	*expl;
+	const char	*reason;
 } http_msg[] = {
 	{ 101, "Switching Protocols" },
 	{ 200, "OK" },
@@ -96,7 +96,7 @@
 /*--------------------------------------------------------------------*/
 
 void
-RES_Error(struct sess *sp, int code, const char *expl)
+RES_Error(struct sess *sp, int code, const char *reason)
 {
 	char buf[40];
 	struct vsb *sb;
@@ -115,13 +115,13 @@
 		if (mp->nbr > code)
 			break;
 		msg = mp->txt;
-		if (expl == NULL)
-			expl = mp->expl;
+		if (reason == NULL)
+			reason = mp->reason;
 		break;
 	}
-	if (expl == NULL)
-		expl = msg;
-	AN(expl);
+	if (reason == NULL)
+		reason = msg;
+	AN(reason);
 	AN(msg);
 
 	sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
@@ -144,11 +144,11 @@
 		"  </HEAD>\r\n"
 		"  <BODY>\r\n");
 	vsb_printf(sb, "    <H1>Error %03d %s</H1>\r\n", code, msg);
-	vsb_printf(sb, "    <P>%s</P>\r\n", expl);
-	vsb_printf(sb, "    <H3>Guru Meditation:</H3>\r\n", expl);
+	vsb_printf(sb, "    <P>%s</P>\r\n", reason);
+	vsb_printf(sb, "    <H3>Guru Meditation:</H3>\r\n");
 	vsb_printf(sb, "    <P>XID: %u</P>\r\n", sp->xid);
 	vsb_cat(sb,
-		"    <I><A href=\"http://varnish.linpro.no/\">Varnish</A></I>\r\n"
+		"    <I><A href=\"http://www.varnish-cache.org/\">Varnish</A></I>\r\n"
 		"  </BODY>\r\n"
 		"</HTML>\r\n");
 	vsb_finish(sb);
@@ -158,7 +158,7 @@
 	WSL(sp->wrk, SLT_TxStatus, sp->id, "%d", code);
 	WSL(sp->wrk, SLT_TxProtocol, sp->id, "HTTP/1.1");
 	WSL(sp->wrk, SLT_TxResponse, sp->id, msg);
-	vca_close_session(sp, expl);
+	vca_close_session(sp, reason);
 	vsb_delete(sb);
 }
 
@@ -255,7 +255,7 @@
 			sp->wrk->acct.bodybytes += st->len;
 #ifdef HAVE_SENDFILE
 			/*
-			 * XXX: the overhead of setting up senddile is not
+			 * XXX: the overhead of setting up sendfile is not
 			 * XXX: epsilon and maybe not even delta, so avoid
 			 * XXX: engaging sendfile for small objects.
 			 * XXX: Should use getpagesize() ?

Modified: branches/1.0/bin/varnishd/cache_vrt.c
===================================================================
--- branches/1.0/bin/varnishd/cache_vrt.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/cache_vrt.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -47,13 +47,13 @@
 /*--------------------------------------------------------------------*/
 
 void
-VRT_error(struct sess *sp, unsigned code, const char *expl)
+VRT_error(struct sess *sp, unsigned code, const char *reason)
 {
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	WSL(sp->wrk, SLT_Debug, 0, "VCL_error(%u, %s)", code, expl);
+	WSL(sp->wrk, SLT_Debug, 0, "VCL_error(%u, %s)", code, reason);
 	sp->err_code = code;
-	sp->err_expl = expl;
+	sp->err_reason = reason;
 }
 
 /*--------------------------------------------------------------------*/

Modified: branches/1.0/bin/varnishd/heritage.h
===================================================================
--- branches/1.0/bin/varnishd/heritage.h	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/heritage.h	2007-05-10 11:58:14 UTC (rev 1401)
@@ -111,6 +111,9 @@
 	/* HTTP proto behaviour */
 	unsigned		backend_http11;
 	unsigned		client_http11;
+
+	/* Ping interval */
+	unsigned		ping_interval;
 };
 
 extern volatile struct params *params;

Modified: branches/1.0/bin/varnishd/mgt_child.c
===================================================================
--- branches/1.0/bin/varnishd/mgt_child.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/mgt_child.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -214,13 +214,15 @@
 	ev_listen = e;
 
 	AZ(ev_poker);
-	e = ev_new();
-	XXXAN(e);
-	e->timeout = 3.0;
-	e->callback = child_poker;
-	e->name = "child poker";
-	AZ(ev_add(mgt_evb, e));
-	ev_poker = e;
+	if (params->ping_interval > 0) {
+		e = ev_new();
+		XXXAN(e);
+		e->timeout = params->ping_interval;
+		e->callback = child_poker;
+		e->name = "child poker";
+		AZ(ev_add(mgt_evb, e));
+		ev_poker = e;
+	}
 
 	mgt_cli_start_child(heritage.fds[0], heritage.fds[3]);
 	AZ(close(heritage.fds[1]));

Modified: branches/1.0/bin/varnishd/mgt_param.c
===================================================================
--- branches/1.0/bin/varnishd/mgt_param.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/mgt_param.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -50,7 +50,7 @@
 struct parspec {
 	const char	*name;
 	tweak_t		*func;
-	const char	*expl;
+	const char	*descr;
 	const char	*def;
 	const char	*units;
 };
@@ -407,6 +407,15 @@
 
 /*--------------------------------------------------------------------*/
 
+static void
+tweak_ping_interval(struct cli *cli, struct parspec *par, const char *arg)
+{
+	(void)par;
+	tweak_generic_uint(cli, &params->ping_interval, arg, 0, UINT_MAX);
+}
+
+/*--------------------------------------------------------------------*/
+
 /*
  * Make sure to end all lines with either a space or newline of the
  * formatting will go haywire.
@@ -566,6 +575,12 @@
 		"backend response."
 		EXPERIMENTAL,
 		"off", "bool" },
+	{ "ping_interval", tweak_ping_interval,
+		"Interval between pings from parent to child.\n"
+		"Zero will disable pinging entirely, which makes "
+		"it possible to attach a debugger to the child.\n"
+		MUST_RESTART,
+		"3", "seconds" },
 	{ NULL, NULL, NULL }
 };
 
@@ -602,7 +617,7 @@
 		if (av[2] != NULL) {
 			cli_out(cli, "%-20s Default is %s\n", "", pp->def);
 			/* Format text to 72 col width */
-			for (p = pp->expl; *p != '\0'; ) {
+			for (p = pp->descr; *p != '\0'; ) {
 				q = strchr(p, '\n');
 				if (q == NULL)
 					q = strchr(p, '\0');

Modified: branches/1.0/bin/varnishd/mgt_vcc.c
===================================================================
--- branches/1.0/bin/varnishd/mgt_vcc.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/mgt_vcc.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -314,15 +314,15 @@
 		AN(buf);
 		if (C_flag) {
 			csrc = VCC_Compile(sb, buf, NULL);
-			fputs(csrc, stdout);
-			return (0);
+			if (csrc != NULL)
+				fputs(csrc, stdout);
 		}
 		vf = mgt_VccCompile(sb, buf, NULL);
 		free(buf);
 	} else if (C_flag) {
 		csrc = VCC_CompileFile(sb, f_arg);
-		fputs(csrc, stdout);
-		return (0);
+		if (csrc != NULL)
+			fputs(csrc, stdout);
 	} else {
 		vf = mgt_VccCompileFile(sb, f_arg);
 	}
@@ -333,6 +333,8 @@
 		return (1);
 	}
 	vsb_delete(sb);
+	if (C_flag)
+		return (0);
 	vp = mgt_vcc_add("boot", vf);
 	vp->active = 1;
 	return (0);

Modified: branches/1.0/bin/varnishd/rfc2616.c
===================================================================
--- branches/1.0/bin/varnishd/rfc2616.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/rfc2616.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -109,7 +109,8 @@
 	retirement_age = INT_MAX;
 
 	u1 = u2 = 0;
-	if (http_GetHdrField(hp, H_Cache_Control, "max-age", &p)) {
+	if (http_GetHdrField(hp, H_Cache_Control, "s-maxage", &p) ||
+	    http_GetHdrField(hp, H_Cache_Control, "max-age", &p)) {
 		u1 = strtoul(p, NULL, 0);
 		u2 = 0;
 		if (http_GetHdr(hp, H_Age, &p)) {

Modified: branches/1.0/bin/varnishd/storage_file.c
===================================================================
--- branches/1.0/bin/varnishd/storage_file.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/storage_file.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -119,7 +119,7 @@
 	uintmax_t l;
 	unsigned bs;
 	char suff[2];
-	int i, expl;
+	int i, explicit;
 	off_t o;
 	struct stat st;
 
@@ -140,7 +140,7 @@
 
 	i = sscanf(size, "%ju%1s", &l, suff); /* can return -1, 0, 1 or 2 */
 
-	expl = i;
+	explicit = i;
 	if (i == 0) {
 		fprintf(stderr,
 		    "Error: (-sfile) size \"%s\" not understood\n", size);
@@ -215,7 +215,7 @@
 		exit (2);
 	}
 
-	if (expl < 3 && sizeof(void *) == 4 && l > INT32_MAX) {
+	if (explicit < 3 && sizeof(void *) == 4 && l > INT32_MAX) {
 		fprintf(stderr,
 		    "NB: Limiting size to 2GB on 32 bit architecture to"
 		    " prevent running out of\naddress space."

Modified: branches/1.0/bin/varnishd/varnishd.1
===================================================================
--- branches/1.0/bin/varnishd/varnishd.1	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishd/varnishd.1	2007-05-10 11:58:14 UTC (rev 1401)
@@ -28,7 +28,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd October 6, 2006
+.Dd May 1, 2007
 .Dt VARNISHD 1
 .Os
 .Sh NAME
@@ -351,7 +351,15 @@
 will start dropping new connections.
 .Pp
 The default is 100%.
+.It Va ping_interval
+The interval at which the parent process will ping the child process
+to ascertain that it is still present and functioning.
+.Pp
+The default is 3 seconds.
 .It Va pipe_timeout
+The time to wait before dropping an idle pipe mode connection.
+.Pp
+The default is 60 seconds.
 .It Va sendfile_threshold
 The size threshold beyond which documents are sent to the client using
 .Xr sendfile 2

Modified: branches/1.0/bin/varnishhist/Makefile.am
===================================================================
--- branches/1.0/bin/varnishhist/Makefile.am	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishhist/Makefile.am	2007-05-10 11:58:14 UTC (rev 1401)
@@ -14,4 +14,5 @@
 	$(top_builddir)/lib/libcompat/libcompat.a \
 	$(top_builddir)/lib/libvarnish/libvarnish.la \
 	$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
-	-lm -lcurses
+	-lm \
+	${CURSES_LIBS}

Modified: branches/1.0/bin/varnishhist/varnishhist.c
===================================================================
--- branches/1.0/bin/varnishhist/varnishhist.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishhist/varnishhist.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -112,7 +112,7 @@
 }
 
 static int
-h_hist(void *priv, unsigned tag, unsigned fd, unsigned len, unsigned spec, const char *ptr)
+h_hist(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned spec, const char *ptr)
 {
 	double b;
 	int i, j;

Modified: branches/1.0/bin/varnishlog/varnishlog.1
===================================================================
--- branches/1.0/bin/varnishlog/varnishlog.1	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishlog/varnishlog.1	2007-05-10 11:58:14 UTC (rev 1401)
@@ -28,12 +28,12 @@
 .\"
 .\" $Id$
 .\"
-.Dd October 5, 2006
+.Dd April 21, 2007
 .Dt VARNISHLOG 1
 .Os
 .Sh NAME
 .Nm varnishlog
-.Nd HTTP accelerator log watcher
+.Nd Display Varnish logs
 .Sh SYNOPSIS
 .Nm
 .Op Fl a

Modified: branches/1.0/bin/varnishlog/varnishlog.c
===================================================================
--- branches/1.0/bin/varnishlog/varnishlog.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishlog/varnishlog.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -94,7 +94,7 @@
 }
 
 static int
-h_order(void *priv, unsigned tag, unsigned fd, unsigned len, unsigned spec, const char *ptr)
+h_order(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned spec, const char *ptr)
 {
 
 	(void)priv;
@@ -113,7 +113,10 @@
 		flg[fd] |= F_MATCH;
 	switch (tag) {
 	case SLT_VCL_call:
-		flg[fd] |= F_INVCL;
+		if (flg[fd] & F_INVCL)
+			vsb_cat(ob[fd], "\n");
+		else
+			flg[fd] |= F_INVCL;
 		vsb_printf(ob[fd], "%5d %-12s %c %.*s",
 		    fd, VSL_tags[tag],
 		    ((spec & VSL_S_CLIENT) ? 'c' : \

Modified: branches/1.0/bin/varnishncsa/varnishncsa.1
===================================================================
--- branches/1.0/bin/varnishncsa/varnishncsa.1	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishncsa/varnishncsa.1	2007-05-10 11:58:14 UTC (rev 1401)
@@ -28,12 +28,12 @@
 .\"
 .\" $Id$
 .\"
-.Dd October 5, 2006
+.Dd April 21, 2007
 .Dt VARNISHNCSA 1
 .Os
 .Sh NAME
 .Nm varnishncsa
-.Nd Generate NCSA logs
+.Nd Display Varnish logs in Apache / NCSA combined log format
 .Sh SYNOPSIS
 .Nm
 .Op Fl a
@@ -53,7 +53,7 @@
 .Nm
 utility reads
 .Xr varnishd 1
-shared memory logs and presents them in the NCSA "common" or
+shared memory logs and presents them in the Apache / NCSA
 "combined" log format.
 .Pp
 The following options are available:

Modified: branches/1.0/bin/varnishncsa/varnishncsa.c
===================================================================
--- branches/1.0/bin/varnishncsa/varnishncsa.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishncsa/varnishncsa.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -29,193 +29,319 @@
  *
  * $Id$
  *
- * Program that will get data from the shared memory log. When it has the data
- * it will order the data based on the sessionid. When the data is ordered
- * and session is finished it will write the data into disk. Logging will be
- * in NCSA extended/combined access log format.
+ * Obtain log data from the shared memory log, order it by session ID, and
+ * display it in Apache / NCSA combined log format:
  *
- *	"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
+ *	%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i"
  *
+ * where the fields are defined as follows:
+ *
+ *	%h		Client host name or IP address (always the latter)
+ *	%l		Client user ID as reported by identd (always "-")
+ *	%u		User ID if using HTTP authentication, or "-"
+ *	%t		Date and time of request
+ *	%r		Request line
+ *	%s		Status code
+ *	%b		Length of reply body, or "-"
+ *	%{Referer}i	Contents of "Referer" request header
+ *	%{User-agent}i	Contents of "User-agent" request header
+ *
+ * Actually, we cheat a little and replace "%r" with something close to
+ * "%m http://%{Host}i%U%q %H", where the additional fields are:
+ *
+ *	%m		Request method
+ *	%{Host}i	Contents of "Host" request header
+ *	%U		URL path
+ *	%q		Query string
+ *	%H		Protocol version
+ *
  * TODO:	- Log in any format one wants
  *		- Maybe rotate/compress log
  */
 
-#include <stdio.h>
+#include <ctype.h>
 #include <errno.h>
 #include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <stdlib.h>
+#include <time.h>
 #include <unistd.h>
-#include <time.h>
 
-#include "compat/vis.h"
-
-#include "vsb.h"
-
 #include "libvarnish.h"
 #include "shmlog.h"
 #include "varnishapi.h"
+#include "vsb.h"
 
 static struct logline {
-	char df_h[4 * (3 + 1)];		/* Datafield for %h (IP adress)	*/
-	char df_s[4]; 			/* Datafield for %s, Status	*/
-	char df_b[12];			/* Datafield for %b, Bytes	*/
-	char *df_R; 			/* Datafield for %{Referer}	*/
-	char *df_U; 			/* Datafield for %{User-agent}	*/
-	char *df_RU;				/* Datafield for %l, Remote user */
-	int bogus_req; 			/* bogus request		*/
-	struct vsb *sb;
-} *ll[65536];
+	char *df_H;			/* %H, Protocol version */
+	char *df_Host;			/* %{Host}i */
+	char *df_Referer;		/* %{Referer}i */
+	char *df_Uq;			/* %U%q, URL path and query string */
+	char *df_User_agent;		/* %{User-agent}i */
+	char *df_b;			/* %b, Bytes */
+	char *df_h;			/* %h (host name / IP adress)*/
+	char *df_m;			/* %m, Request method*/
+	char *df_s;			/* %s, Status */
+	char *df_u;			/* %u, Remote user */
+	int bogus;			/* bogus request */
+} **ll;
 
-/* Check if string starts with pfx */
+static size_t nll;
+
 static int
-ispfx(const char *ptr, unsigned len, const char *pfx)
+isprefix(const char *str, const char *prefix, const char *end, const char **next)
 {
-	unsigned l;
 
-	l = strlen(pfx);
-	if (l > len)
+	while (str < end && *str && *prefix &&
+	    tolower((int)*str) == tolower((int)*prefix))
+		++str, ++prefix;
+	if (*str && *str != ' ')
 		return (0);
-	if (strncasecmp(ptr, pfx, l))
-		return (0);
+	if (next) {
+		while (str < end && *str && *str == ' ')
+			++str;
+		*next = str;
+	}
 	return (1);
 }
 
+/*
+ * Returns a copy of the first consecutive sequence of non-space
+ * characters in the string.
+ */
+static char *
+trimfield(const char *str, const char *end)
+{
+	size_t len;
+	char *p;
+
+	/* skip leading space */
+	while (str < end && *str && *str == ' ')
+		++str;
+
+	/* seek to end of field */
+	for (len = 0; &str[len] < end && str[len]; ++len)
+		if (str[len] == ' ')
+			break;
+
+	/* copy and return */
+	p = malloc(len + 1);
+	assert(p != NULL);
+	memcpy(p, str, len);
+	p[len] = '\0';
+	return (p);
+}
+
+/*
+ * Returns a copy of the entire string with leading and trailing spaces
+ * trimmed.
+ */
+static char *
+trimline(const char *str, const char *end)
+{
+	size_t len;
+	char *p;
+
+	/* skip leading space */
+	while (str < end && *str && *str == ' ')
+		++str;
+
+	/* seek to end of string */
+	for (len = 0; &str[len] < end && str[len]; ++len)
+		 /* nothing */ ;
+
+	/* trim trailing space */
+	while (str[len - 1] == ' ')
+		--len;
+
+	/* copy and return */
+	p = malloc(len + 1);
+	assert(p != NULL);
+	memcpy(p, str, len);
+	p[len] = '\0';
+	return (p);
+}
+
 static int
-extended_log_format(void *priv, unsigned tag, unsigned fd, unsigned len, unsigned spec, const char *ptr)
+h_ncsa(void *priv, enum shmlogtag tag, unsigned fd,
+    unsigned len, unsigned spec, const char *ptr)
 {
-	const char *p;
+	const char *end, *next;
 	char *q;
 	FILE *fo;
 	time_t t;
 	long l;
-	unsigned lu;
 	struct tm tm;
 	char tbuf[40];
-	char rubuf[128];
 	struct logline *lp;
 
+	end = ptr + len;
+
 	if (!(spec &VSL_S_CLIENT))
 		return (0);
 
+	if (fd >= nll) {
+		struct logline **newll = ll;
+		size_t newnll = nll;
+
+		while (fd >= newnll)
+			newnll += newnll + 1;
+		newll = realloc(newll, newnll * sizeof *newll);
+		assert(newll != NULL);
+		memset(newll + nll, 0, (newnll - nll) * sizeof *newll);
+		ll = newll;
+		nll = newnll;
+	}
 	if (ll[fd] == NULL) {
 		ll[fd] = calloc(sizeof *ll[fd], 1);
 		assert(ll[fd] != NULL);
-		ll[fd]->sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
-		assert(ll[fd]->sb != NULL);
-		strcpy(ll[fd]->df_h, "-");
 	}
 	lp = ll[fd];
 
 	switch (tag) {
-
-	case SLT_SessionOpen:
 	case SLT_ReqStart:
-		for (p = ptr, q = lp->df_h; *p && *p != ' ';)
-			*q++ = *p++;
-		*q = '\0';
-		vsb_clear(lp->sb);
+		if (lp->df_h != NULL)
+			lp->bogus = 1;
+		else
+			lp->df_h = trimfield(ptr, end);
 		break;
 
 	case SLT_RxRequest:
-		if (ispfx(ptr, len, "HEAD")) {
-			vsb_bcat(lp->sb, ptr, len);
-		} else if (ispfx(ptr, len, "POST")) {
-			vsb_bcat(lp->sb, ptr, len);
-		} else if (ispfx(ptr, len, "GET")) {
-			vsb_bcat(lp->sb, ptr, len);
-		} else if (ispfx(ptr, len, "PURGE")) {
-			vsb_bcat(lp->sb, ptr, len);
-		} else {
-			lp->bogus_req = 1;
-		}
+		if (lp->df_m != NULL)
+			lp->bogus = 1;
+		else
+			lp->df_m = trimline(ptr, end);
 		break;
 
 	case SLT_RxURL:
-		vsb_cat(lp->sb, " ");
-		vsb_bcat(lp->sb, ptr, len);
+		if (lp->df_Uq != NULL)
+			lp->bogus = 1;
+		else
+			lp->df_Uq = trimline(ptr, end);
 		break;
 
 	case SLT_RxProtocol:
-		vsb_cat(lp->sb, " ");
-		vsb_bcat(lp->sb, ptr, len);
+		if (lp->df_H != NULL)
+			lp->bogus = 1;
+		else
+			lp->df_H = trimline(ptr, end);
 		break;
 
 	case SLT_TxStatus:
-		strcpy(lp->df_s, ptr);
+		if (lp->df_s != NULL)
+			lp->bogus = 1;
+		else
+			lp->df_s = trimline(ptr, end);
 		break;
 
 	case SLT_RxHeader:
-		if (ispfx(ptr, len, "user-agent:"))
-			lp->df_U = strdup(ptr + 12);
-		else if (ispfx(ptr, len, "referer:"))
-			lp->df_R = strdup(ptr + 9);
-		else if (ispfx(ptr, len, "authorization:"))
-			lp->df_RU = strdup(ptr + 21);
+		if (isprefix(ptr, "user-agent:", end, &next))
+			lp->df_User_agent = trimline(next, end);
+		else if (isprefix(ptr, "referer:", end, &next))
+			lp->df_Referer = trimline(next, end);
+		else if (isprefix(ptr, "authorization:", end, &next) &&
+		    isprefix(next, "basic", end, &next))
+			lp->df_u = trimline(next, end);
+		else if (isprefix(ptr, "host:", end, &next))
+			lp->df_Host = trimline(next, end);
 		break;
 
 	case SLT_Length:
-		if (strcmp(ptr, "0"))
-			strcpy(lp->df_b, ptr);
+		if (lp->df_b != NULL)
+			lp->bogus = 1;
 		else
-			strcpy(lp->df_b, "-");
+			lp->df_b = trimline(ptr, end);
 		break;
 
 	default:
 		break;
 	}
+
 	if (tag != SLT_ReqEnd)
 		return (0);
 
-	fo = priv;
-	assert(1 == sscanf(ptr, "%*u %*u.%*u %ld.", &l));
-	t = l;
-	localtime_r(&t, &tm);
-	
+	if (sscanf(ptr, "%*u %*u.%*u %ld.", &l) != 1)
+		lp->bogus = 1;
+	else
+		t = l;
 
-	
-	strftime(tbuf, sizeof tbuf, "%d/%b/%Y:%T %z", &tm);
-	fprintf(fo, "%s", lp->df_h);
-	
-	if (lp->df_RU != NULL){
-		base64_init();
-		lu = sizeof rubuf;
-		base64_decode(rubuf, lu, lp->df_RU);
-		q = strchr(rubuf, ':');
-		if (q != NULL){
-			*q = '\0';
+	if (!lp->bogus) {
+		fo = priv;
+
+		/* %h */
+		fprintf(fo, "%s ", lp->df_h ? lp->df_h : "-");
+
+		/* %l */
+		fprintf(fo, "- ");
+
+		/* %u: decode authorization string */
+		if (lp->df_u != NULL) {
+			char *rubuf;
+			size_t rulen;
+
+			base64_init();
+			rulen = ((strlen(lp->df_u) + 3) * 4) / 3;
+			rubuf = malloc(rulen);
+			assert(rubuf != NULL);
+			base64_decode(rubuf, rulen, lp->df_u);
+			q = strchr(rubuf, ':');
+			if (q != NULL)
+				*q = '\0';
+			fprintf(fo, "%s ", rubuf);
+			free(rubuf);
+		} else {
+			fprintf(fo, "- ");
 		}
-		fprintf(fo, " %s", rubuf);
-		free(lp->df_RU);
-		lp->df_RU = NULL;
-	}
-	else{
-		fprintf(fo, " -");
-	}
-	fprintf(fo, " - [%s]", tbuf);
-	vsb_finish(lp->sb);
-	fprintf(fo, " \"%s\"", vsb_data(lp->sb));
-	fprintf(fo, " %s", lp->df_s);
-	fprintf(fo, " %s", lp->df_b);
-	if (lp->df_R != NULL) {
-		fprintf(fo, " \"%s\"", lp->df_R);
-		free(lp->df_R);
-		lp->df_R = NULL;
-	}
-	else {
-	        fprintf(fo, " \"-\"");
-				        }
 
-	if (lp->df_U != NULL) {
-		fprintf(fo, " \"%s\"", lp->df_U);
-		free(lp->df_U);
-		lp->df_U = NULL;
+		/* %t */
+		localtime_r(&t, &tm);
+		strftime(tbuf, sizeof tbuf, "[%d/%b/%Y:%T %z]", &tm);
+		fprintf(fo, "%s ", tbuf);
+
+		/*
+		 * Fake "%r".  This would be a lot easier if Varnish
+		 * normalized the request URL.
+		 */
+		fprintf(fo, "\"%s ", lp->df_m);
+		if (lp->df_Host) {
+			if (strncmp(lp->df_Host, "http://", 7) != 0)
+				fprintf(fo, "http://");
+			fprintf(fo, lp->df_Host);
+		}
+		fprintf(fo, "%s ", lp->df_Uq);
+		fprintf(fo, "%s\" ", lp->df_H);
+
+		/* %s */
+		fprintf(fo, "%s ", lp->df_s);
+
+		/* %b */
+		fprintf(fo, "%s ", lp->df_b);
+
+		/* %{Referer}i */
+		fprintf(fo, "\"%s\" ",
+		    lp->df_Referer ? lp->df_Referer : "-");
+
+		/* %{User-agent}i */
+		fprintf(fo, "\"%s\"\n",
+		    lp->df_User_agent ? lp->df_User_agent : "-");
 	}
-	else {
-		fprintf(fo, " \"-\"");
-	}
-	fprintf(fo, "\n");
 
+	/* clean up */
+#define freez(x) do { if (x) free(x); x = NULL; } while (0);
+	freez(lp->df_H);
+	freez(lp->df_Host);
+	freez(lp->df_Referer);
+	freez(lp->df_Uq);
+	freez(lp->df_User_agent);
+	freez(lp->df_b);
+	freez(lp->df_h);
+	freez(lp->df_m);
+	freez(lp->df_s);
+	freez(lp->df_u);
+#undef freez
+	lp->bogus = 0;
+
 	return (0);
 }
 
@@ -248,12 +374,13 @@
 static void
 usage(void)
 {
+
 	fprintf(stderr, "usage: varnishncsa %s [-aV] [-w file]\n", VSL_ARGS);
 	exit(1);
 }
 
 int
-main(int argc, char **argv)
+main(int argc, char *argv[])
 {
 	int i, c;
 	struct VSL_data *vd;
@@ -297,7 +424,7 @@
 		of = stdout;
 	}
 
-	while (VSL_Dispatch(vd, extended_log_format, of) == 0) {
+	while (VSL_Dispatch(vd, h_ncsa, of) == 0) {
 		if (fflush(of) != 0) {
 			perror(ofn);
 			exit(1);
@@ -311,4 +438,3 @@
 
 	exit(0);
 }
-

Modified: branches/1.0/bin/varnishstat/Makefile.am
===================================================================
--- branches/1.0/bin/varnishstat/Makefile.am	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishstat/Makefile.am	2007-05-10 11:58:14 UTC (rev 1401)
@@ -14,4 +14,4 @@
 	$(top_builddir)/lib/libcompat/libcompat.a \
 	$(top_builddir)/lib/libvarnish/libvarnish.la \
 	$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
-	-lcurses
+	${CURSES_LIBS} ${RT_LIBS}

Modified: branches/1.0/bin/varnishtop/Makefile.am
===================================================================
--- branches/1.0/bin/varnishtop/Makefile.am	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/bin/varnishtop/Makefile.am	2007-05-10 11:58:14 UTC (rev 1401)
@@ -14,4 +14,4 @@
 	$(top_builddir)/lib/libcompat/libcompat.a \
 	$(top_builddir)/lib/libvarnish/libvarnish.la \
 	$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
-	-lcurses
+	${CURSES_LIBS}

Modified: branches/1.0/configure.ac
===================================================================
--- branches/1.0/configure.ac	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/configure.ac	2007-05-10 11:58:14 UTC (rev 1401)
@@ -12,20 +12,6 @@
 
 AM_INIT_AUTOMAKE
 
-# Compiler flags (assume GCC).
-# This section *must* come before AC_PROG_CC / AC_PROG_CPP.
-CFLAGS="${CFLAGS:--O2 -pipe}"
-DEVELOPER_CFLAGS="-Wall -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wformat"
-AC_ARG_ENABLE(developer-warnings,
-	AS_HELP_STRING([--enable-developer-warnings],[enable strict warnings (default is NO)]),
-	CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}")
-AC_ARG_ENABLE(debugging-symbols,
-	AS_HELP_STRING([--enable-debugging-symbols],[enable debugging symbols (default is NO)]),
-	CFLAGS="${CFLAGS} -O0 -g -fno-inline")
-AC_ARG_ENABLE(werror,
-	AS_HELP_STRING([--enable-werror],[use -Werror (default is NO)]),
-	CFLAGS="${CFLAGS} -Werror")
-
 # Checks for programs.
 AC_GNU_SOURCE
 AC_PROG_CC
@@ -35,10 +21,33 @@
 AC_PROG_MAKE_SET
 
 # Checks for libraries.
+save_LIBS="${LIBS}"
+LIBS=""
 AC_CHECK_LIB(rt, clock_gettime)
+RT_LIBS="${LIBS}"
+LIBS="${save_LIBS}"
+AC_SUBST(RT_LIBS)
+
+save_LIBS="${LIBS}"
+LIBS=""
 AC_CHECK_LIB(dl, dlopen)
-#AC_SEARCH_LIBS(initscr, [curses ncurses])
+DL_LIBS="${LIBS}"
+LIBS="${save_LIBS}"
+AC_SUBST(DL_LIBS)
+
+save_LIBS="${LIBS}"
+LIBS=""
+AC_SEARCH_LIBS(initscr, [curses ncurses])
+CURSES_LIBS="${LIBS}"
+LIBS="${save_LIBS}"
+AC_SUBST(CURSES_LIBS)
+
+save_LIBS="${LIBS}"
+LIBS=""
 AC_SEARCH_LIBS(pthread_create, [thr pthread c_r])
+PTHREAD_LIBS="${LIBS}"
+LIBS="${save_LIBS}"
+AC_SUBST(PTHREAD_LIBS)
 
 # Checks for header files.
 AC_HEADER_STDC
@@ -79,13 +88,31 @@
 AC_CHECK_FUNCS([strlcat strlcpy])
 AC_CHECK_FUNCS([strndup])
 AC_CHECK_FUNCS([vis strvis strvisx])
+
+save_LIBS="${LIBS}"
+LIBS="${LIBS} ${RT_LIBS}"
 AC_CHECK_FUNCS([clock_gettime])
+LIBS="${save_LIBS}"
 
 # Check which mechanism to use for the acceptor
 AC_CHECK_FUNCS([kqueue])
 AC_CHECK_FUNCS([epoll_ctl])
 AC_CHECK_FUNCS([poll])
 
+# Now that we're done using the compiler to look for functions and
+# libraries, set CFLAGS to what we want them to be for our own code
+DEVELOPER_CFLAGS="-Wall -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wformat"
+AC_ARG_ENABLE(developer-warnings,
+	AS_HELP_STRING([--enable-developer-warnings],[enable strict warnings (default is NO)]),
+	CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}")
+AC_ARG_ENABLE(debugging-symbols,
+	AS_HELP_STRING([--enable-debugging-symbols],[enable debugging symbols (default is NO)]),
+	CFLAGS="${CFLAGS} -O0 -g -fno-inline")
+AC_ARG_ENABLE(werror,
+	AS_HELP_STRING([--enable-werror],[use -Werror (default is NO)]),
+	CFLAGS="${CFLAGS} -Werror")
+
+# Generate output
 AC_CONFIG_FILES([
     Makefile
     bin/Makefile

Modified: branches/1.0/include/shmlog.h
===================================================================
--- branches/1.0/include/shmlog.h	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/include/shmlog.h	2007-05-10 11:58:14 UTC (rev 1401)
@@ -33,6 +33,9 @@
  * NB: THIS IS NOT A PUBLIC API TO VARNISH!
  */
 
+#ifndef SHMLOG_H_INCLUDED
+#define SHMLOG_H_INCLUDED
+
 #define SHMLOG_FILENAME		"/tmp/_.vsl"
 
 #include <time.h>
@@ -82,3 +85,5 @@
 #undef SLTM
 	SLT_WRAPMARKER = 255
 };
+
+#endif

Modified: branches/1.0/include/varnishapi.h
===================================================================
--- branches/1.0/include/varnishapi.h	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/include/varnishapi.h	2007-05-10 11:58:14 UTC (rev 1401)
@@ -32,6 +32,8 @@
 #ifndef VARNISHAPI_H_INCLUDED
 #define VARNISHAPI_H_INCLUDED
 
+#include "shmlog.h"
+
 #define V_DEAD __attribute__ ((noreturn))
 
 /* base64.c */
@@ -39,7 +41,7 @@
 int base64_decode(char *d, unsigned dlen, const char *s);
 
 /* shmlog.c */
-typedef int vsl_handler(void *priv, unsigned tag, unsigned fd, unsigned len, unsigned spec, const char *ptr);
+typedef int vsl_handler(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned spec, const char *ptr);
 #define VSL_S_CLIENT	(1 << 0)
 #define VSL_S_BACKEND	(1 << 1)
 #define VSL_ARGS	"bCcdI:i:r:X:x:"

Modified: branches/1.0/lib/libvarnishapi/shmlog.c
===================================================================
--- branches/1.0/lib/libvarnishapi/shmlog.c	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/lib/libvarnishapi/shmlog.c	2007-05-10 11:58:14 UTC (rev 1401)
@@ -284,14 +284,14 @@
 		if (vd->regincl != NULL) {
 			rm.rm_so = 0;
 			rm.rm_eo = p[1];
-			i = regexec(vd->regincl, p + 4, 1, &rm, 0);
+			i = regexec(vd->regincl, (char *)p + 4, 1, &rm, 0);
 			if (i == REG_NOMATCH)
 				continue;
 		}
 		if (vd->regexcl != NULL) {
 			rm.rm_so = 0;
 			rm.rm_eo = p[1];
-			i = regexec(vd->regexcl, p + 4, 1, &rm, 0);
+			i = regexec(vd->regexcl, (char *)p + 4, 1, &rm, 0);
 			if (i != REG_NOMATCH)
 				continue;
 		}
@@ -318,7 +318,7 @@
 		if (func(priv,
 		    p[0], u, p[1],
 		    vd->map[u] & (VSL_S_CLIENT|VSL_S_BACKEND),
-		    p + 4))
+		    (char *)p + 4))
 			return (1);
 	}
 }
@@ -326,7 +326,7 @@
 /*--------------------------------------------------------------------*/
 
 int
-VSL_H_Print(void *priv, unsigned tag, unsigned fd, unsigned len, unsigned spec, const char *ptr)
+VSL_H_Print(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned spec, const char *ptr)
 {
 	FILE *fo = priv;
 

Modified: branches/1.0/lib/libvcl/vcc_priv.h
===================================================================
--- branches/1.0/lib/libvcl/vcc_priv.h	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/lib/libvcl/vcc_priv.h	2007-05-10 11:58:14 UTC (rev 1401)
@@ -43,4 +43,4 @@
 void vcl_init_tnames(void);
 void vcl_output_lang_h(struct vsb *sb);
 
-#define PF(t)	((t)->e - (t)->b), (t)->b
+#define PF(t)	(int)((t)->e - (t)->b), (t)->b

Modified: branches/1.0/man/vcl.7
===================================================================
--- branches/1.0/man/vcl.7	2007-05-10 11:38:32 UTC (rev 1400)
+++ branches/1.0/man/vcl.7	2007-05-10 11:58:14 UTC (rev 1401)
@@ -400,17 +400,17 @@
         error;
     }
     if (!obj.cacheable) {
-        insert_pass;
+        pass;
     }
     if (resp.http.Set-Cookie) {
-        insert_pass;
+        pass;
     }
     insert;
 }
 
 sub vcl_timeout {
     discard;
-};
+}
 .Ed
 .Pp
 The following example shows how to support multiple sites running on




More information about the varnish-commit mailing list