r1419 - branches/1.0 branches/1.0/bin/varnishd branches/1.0/bin/varnishhist branches/1.0/bin/varnishlog branches/1.0/bin/varnishstat branches/1.0/bin/varnishtop branches/1.0/include branches/1.0/lib/libvarnish branches/1.0/redhat trunk/varnish-cache/bin/varnishd trunk/varnish-cache/bin/varnishtop

des at projects.linpro.no des at projects.linpro.no
Mon May 14 11:42:16 CEST 2007


Author: des
Date: 2007-05-14 11:42:16 +0200 (Mon, 14 May 2007)
New Revision: 1419

Added:
   branches/1.0/include/flopen.h
   branches/1.0/include/vpf.h
   branches/1.0/lib/libvarnish/flopen.c
   branches/1.0/lib/libvarnish/vpf.c
Modified:
   branches/1.0/
   branches/1.0/bin/varnishd/cache_http.c
   branches/1.0/bin/varnishd/mgt_param.c
   branches/1.0/bin/varnishd/mgt_vcc.c
   branches/1.0/bin/varnishd/varnishd.1
   branches/1.0/bin/varnishd/varnishd.c
   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/varnishstat/varnishstat.c
   branches/1.0/bin/varnishtop/varnishtop.c
   branches/1.0/configure.ac
   branches/1.0/include/Makefile.am
   branches/1.0/lib/libvarnish/Makefile.am
   branches/1.0/redhat/varnish.spec
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_backend.c
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_response.c
   trunk/varnish-cache/bin/varnishtop/varnishtop.c
Log:
Merged revisions 1394,1400-1418 via svnmerge from 
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache

........
  r1394 | phk | 2007-05-09 12:55:33 +0200 (Wed, 09 May 2007) | 8 lines
  
  After compilation of a VCL program, do a test-load into the management
  process to catch any implementation-discrepancies between symbols used
  by the compiler and those implemented in the runtime.
  
  The situation will happen from time to time and there is no need to
  issue a panic when we can test sensibly for it.
........
  r1403 | ingvar | 2007-05-11 09:51:11 +0200 (Fri, 11 May 2007) | 5 lines
  
  * Fri May 11 2007 Ingvar Hagelund <ingvar at linpro.no> - 1.0.svn-20070511
  - Threw latest changes into svn trunk
  - Removed the conversion of manpages into utf8. They are all utf8 in trunk
........
  r1404 | ingvar | 2007-05-11 10:13:03 +0200 (Fri, 11 May 2007) | 1 line
........
  r1406 | des | 2007-05-11 13:06:03 +0200 (Fri, 11 May 2007) | 2 lines
  
  Comment out comparisons which are always true (unsigned >= 0)
........
  r1407 | des | 2007-05-11 13:06:38 +0200 (Fri, 11 May 2007) | 2 lines
  
  Tweak DEVELOPER_CFLAGS.
........
  r1408 | des | 2007-05-11 13:14:32 +0200 (Fri, 11 May 2007) | 2 lines
  
  Pull flopen() and pidfile_*() (renamed to vpf_*()) from FreeBSD.
........
  r1409 | des | 2007-05-11 13:15:46 +0200 (Fri, 11 May 2007) | 2 lines
  
  Expand tags.
........
  r1410 | des | 2007-05-11 13:17:09 +0200 (Fri, 11 May 2007) | 2 lines
  
  No use expanding tags unless there *are* tags...
........
  r1411 | des | 2007-05-11 13:34:42 +0200 (Fri, 11 May 2007) | 2 lines
  
  Add -D (daemonize) and -P (pid file) options.
........
  r1412 | des | 2007-05-11 13:35:59 +0200 (Fri, 11 May 2007) | 2 lines
  
  Remove unused header.
........
  r1413 | des | 2007-05-11 14:01:47 +0200 (Fri, 11 May 2007) | 2 lines
  
  Avoid gcc4-specific compiler options.
........
  r1414 | des | 2007-05-11 14:05:02 +0200 (Fri, 11 May 2007) | 2 lines
  
  Forgotten commit: check for <vis.h> and daemon(3) availability.
........
  r1415 | des | 2007-05-11 14:17:26 +0200 (Fri, 11 May 2007) | 2 lines
  
  Add -P (pid file) option.
........
  r1416 | des | 2007-05-11 14:19:48 +0200 (Fri, 11 May 2007) | 2 lines
  
  Minor style issues.
........
  r1417 | phk | 2007-05-11 15:15:16 +0200 (Fri, 11 May 2007) | 7 lines
  
  Make the sendfile threshold inifinity for now, we have evidence of
  sendfile not doing it's job in a number of operating system (-versions ?)
  
  This change is unlikely to cause a performance hit anywhere, because
  writev() is pretty effective in the first place.
........
  r1418 | des | 2007-05-14 11:02:23 +0200 (Mon, 14 May 2007) | 2 lines
  
  Document the inadvisability of enabling sendfile.
........



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

Modified: branches/1.0/bin/varnishd/cache_http.c
===================================================================
--- branches/1.0/bin/varnishd/cache_http.c	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/bin/varnishd/cache_http.c	2007-05-14 09:42:16 UTC (rev 1419)
@@ -81,8 +81,8 @@
 {
 
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
-	assert(hp->logtag >= HTTP_Rx && hp->logtag <= HTTP_Obj);
-	assert(t >= HTTP_T_Request && t <= HTTP_T_LostHeader);
+	assert(/* hp->logtag >= HTTP_Rx && */hp->logtag <= HTTP_Obj);
+	assert(/* t >= HTTP_T_Request && */t <= HTTP_T_LostHeader);
 	return (logmtx[hp->logtag][t]);
 }
 

Modified: branches/1.0/bin/varnishd/mgt_param.c
===================================================================
--- branches/1.0/bin/varnishd/mgt_param.c	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/bin/varnishd/mgt_param.c	2007-05-14 09:42:16 UTC (rev 1419)
@@ -529,7 +529,7 @@
 		"may make sense to set this to \"unlimited\".\n"
 #endif
 		EXPERIMENTAL,
-		"8192", "bytes" },
+		"-1", "bytes" },
 #endif /* HAVE_SENDFILE */
 	{ "vcl_trace", tweak_vcl_trace,
 		"Trace VCL execution in the shmlog.\n"

Modified: branches/1.0/bin/varnishd/mgt_vcc.c
===================================================================
--- branches/1.0/bin/varnishd/mgt_vcc.c	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/bin/varnishd/mgt_vcc.c	2007-05-14 09:42:16 UTC (rev 1419)
@@ -33,6 +33,7 @@
 
 #include <sys/types.h>
 
+#include <dlfcn.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -59,7 +60,6 @@
 	int			active;
 };
 
-
 static TAILQ_HEAD(, vclprog) vclhead = TAILQ_HEAD_INITIALIZER(vclhead);
 
 /*--------------------------------------------------------------------*/
@@ -129,6 +129,7 @@
 	FILE *fo, *fs;
 	char *of, *sf, buf[BUFSIZ];
 	int i, j, sfd;
+	void *p;
 
 	/* Create temporary C source file */
 	sf = strdup("/tmp/vcl.XXXXXXXX");
@@ -201,6 +202,17 @@
 		of = NULL;
 	}
 
+	/* Next, try to load the object into the management process */
+	p = dlopen(of, RTLD_NOW | RTLD_LOCAL);
+	if (p == NULL) {
+		vsb_printf(sb, "Problem loading compiled VCL program:\n\t%s\n",
+		    dlerror());
+		unlink(of);
+		free(of);
+		of = NULL;
+	} else
+		AZ(dlclose(p));
+
 	/* clean up and return */
 	unlink(sf);
 	free(sf);

Modified: branches/1.0/bin/varnishd/varnishd.1
===================================================================
--- branches/1.0/bin/varnishd/varnishd.1	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/bin/varnishd/varnishd.1	2007-05-14 09:42:16 UTC (rev 1419)
@@ -28,7 +28,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd May 1, 2007
+.Dd May 14, 2007
 .Dt VARNISHD 1
 .Os
 .Sh NAME
@@ -41,6 +41,7 @@
 .Op Fl d
 .Op Fl f Ar config
 .Op Fl h Ar type Ns Op , Ns Ar options
+.Op Fl P Ar file
 .Op Fl p Ar param Ns = Ns Ar value
 .Op Fl s Ar type Ns Op , Ns Ar options
 .Op Fl T Ar address Ns Op : Ns Ar port
@@ -111,6 +112,9 @@
 See
 .Sx Hash Algorithms
 for a list of supported algorithms.
+.It Fl P Ar file
+Write the process's PID to the specified
+.Ar file .
 .It Fl p Ar param Ns = Ns Ar value
 Set the parameter specified by
 .Ar param
@@ -368,7 +372,10 @@
 This is not likely to have any effect unless the working set is too
 large to fit in physical memory.
 .Pp
-The default is 8192 bytes, which is probably too low.
+Note that several operating systems have known bugs which make it
+inadvisable to use this.
+.Pp
+The default is -1, which disables the use of sendfile altogether.
 .It Va send_timeout
 The time to wait before dropping the connection to a client which is
 not accepting data sent to it.

Modified: branches/1.0/bin/varnishd/varnishd.c
===================================================================
--- branches/1.0/bin/varnishd/varnishd.c	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/bin/varnishd/varnishd.c	2007-05-14 09:42:16 UTC (rev 1419)
@@ -45,7 +45,12 @@
 #include <time.h>
 #include <unistd.h>
 
+#ifndef HAVE_DAEMON
+#include "compat/daemon.h"
+#endif
+
 #include "vsb.h"
+#include "vpf.h"
 
 #include "cli.h"
 #include "cli_priv.h"
@@ -163,7 +168,7 @@
 	fprintf(stderr, "    %-28s # %s\n", "",
 	    "   -b '<hostname_or_IP>:<port_or_service>'");
 	fprintf(stderr, "    %-28s # %s\n", "-d", "debug");
-	fprintf(stderr, "    %-28s # %s\n", "-f file", "VCL_file");
+	fprintf(stderr, "    %-28s # %s\n", "-f file", "VCL script");
 	fprintf(stderr, "    %-28s # %s\n",
 	    "-h kind[,hashoptions]", "Hash specification");
 	fprintf(stderr, "    %-28s # %s\n", "",
@@ -172,6 +177,7 @@
 	    "  -h classic  [default]");
 	fprintf(stderr, "    %-28s # %s\n", "",
 	    "  -h classic,<buckets>");
+	fprintf(stderr, "    %-28s # %s\n", "-P file", "PID file");
 	fprintf(stderr, "    %-28s # %s\n", "-p param=value",
 	    "set parameter");
 	fprintf(stderr, "    %-28s # %s\n",
@@ -396,12 +402,14 @@
 	const char *b_arg = NULL;
 	const char *f_arg = NULL;
 	const char *h_flag = "classic";
+	const char *P_arg = NULL;
 	const char *s_arg = "file";
 	const char *T_arg = NULL;
 	unsigned C_flag = 0;
 	char *p;
 	struct params param;
 	struct cli cli[1];
+	struct pidfh *pfh = NULL;
 
 	setbuf(stdout, NULL);
 	setbuf(stderr, NULL);
@@ -420,8 +428,8 @@
 	 * XXX: block in shared memory.  It would give us the advantage
 	 * XXX: of having the CLI thread be able to take action on the
 	 * XXX: change.
-	 * XXX: For now live with the harmless flexelint warning this causes: 
-	 * XXX: varnishd.c 393 Info 789: Assigning address of auto variable 
+	 * XXX: For now live with the harmless flexelint warning this causes:
+	 * XXX: varnishd.c 393 Info 789: Assigning address of auto variable
 	 * XXX:    'param' to static
 	 */
 
@@ -433,7 +441,7 @@
 	MCF_ParamInit(cli);
 	cli_check(cli);
 
-	while ((o = getopt(argc, argv, "a:b:Cdf:h:p:s:T:t:Vw:")) != -1)
+	while ((o = getopt(argc, argv, "a:b:Cdf:h:P:p:s:T:t:Vw:")) != -1)
 		switch (o) {
 		case 'a':
 			MCF_ParamSet(cli, "listen_address", optarg);
@@ -454,6 +462,9 @@
 		case 'h':
 			h_flag = optarg;
 			break;
+		case 'P':
+			P_arg = optarg;
+			break;
 		case 'p':
 			p = strchr(optarg, '=');
 			if (p == NULL)
@@ -499,6 +510,11 @@
 		usage();
 	}
 
+	if (P_arg && (pfh = vpf_open(P_arg, 0600, NULL)) == NULL) {
+		perror(P_arg);
+		exit(1);
+	}
+
 	if (mgt_vcc_default(b_arg, f_arg, C_flag))
 		exit (2);
 	if (C_flag)
@@ -516,9 +532,14 @@
 	if (d_flag == 1)
 		printf("%d\n", getpid());
 
+	if (pfh != NULL)
+		vpf_write(pfh);
+
 	mgt_cli_init();
 
 	mgt_run(d_flag, T_arg);
 
+	if (pfh != NULL)
+		vpf_remove(pfh);
 	exit(0);
 }

Modified: branches/1.0/bin/varnishhist/varnishhist.c
===================================================================
--- branches/1.0/bin/varnishhist/varnishhist.c	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/bin/varnishhist/varnishhist.c	2007-05-14 09:42:16 UTC (rev 1419)
@@ -41,8 +41,6 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "compat/vis.h"
-
 #include "libvarnish.h"
 #include "shmlog.h"
 #include "varnishapi.h"
@@ -226,5 +224,5 @@
 			break;
 	}
 
-	return (0);
+	exit(0);
 }

Modified: branches/1.0/bin/varnishlog/varnishlog.1
===================================================================
--- branches/1.0/bin/varnishlog/varnishlog.1	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/bin/varnishlog/varnishlog.1	2007-05-14 09:42:16 UTC (rev 1419)
@@ -28,7 +28,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd April 21, 2007
+.Dd May 11, 2007
 .Dt VARNISHLOG 1
 .Os
 .Sh NAME
@@ -40,10 +40,12 @@
 .Op Fl b
 .Op Fl C
 .Op Fl c
+.Op Fl D
 .Op Fl d
 .Op Fl I Ar regex
 .Op Fl i Ar tag
 .Op Fl o
+.Op Fl P Ar file
 .Op Fl r Ar file
 .Op Fl V
 .Op Fl w Ar file
@@ -82,6 +84,8 @@
 is specified,
 .Nm
 acts as if they both were.
+.It Fl D
+Daemonize.
 .It Fl d
 Process old log entries on startup.
 Normally,
@@ -107,6 +111,9 @@
 This has no effect when writing to a file using the
 .Fl w
 option.
+.It Fl P Ar file
+Write the process's PID to the specified
+.Ar file .
 .It Fl r Ar file
 Read log entries from
 .Ar file

Modified: branches/1.0/bin/varnishlog/varnishlog.c
===================================================================
--- branches/1.0/bin/varnishlog/varnishlog.c	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/bin/varnishlog/varnishlog.c	2007-05-14 09:42:16 UTC (rev 1419)
@@ -40,15 +40,24 @@
 #include <string.h>
 #include <unistd.h>
 
+#ifndef HAVE_DAEMON
+#include "compat/daemon.h"
+#endif
+
+#ifdef HAVE_VIS_H
+#include <vis.h>
+#else
 #include "compat/vis.h"
+#endif
 
 #include "vsb.h"
+#include "vpf.h"
 
 #include "libvarnish.h"
 #include "shmlog.h"
 #include "varnishapi.h"
 
-static int	bflag, cflag;
+static int	b_flag, c_flag;
 
 /* -------------------------------------------------------------------*/
 
@@ -100,7 +109,7 @@
 	(void)priv;
 
 	if (!(spec & (VSL_S_CLIENT|VSL_S_BACKEND))) {
-		if (!bflag && !cflag)
+		if (!b_flag && !c_flag)
 			VSL_H_Print(stdout, tag, fd, len, spec, ptr);
 		return (0);
 	}
@@ -179,12 +188,12 @@
 			exit (2);
 		}
 	}
-	if (!bflag) {
+	if (!b_flag) {
 		VSL_Select(vd, SLT_SessionOpen);
 		VSL_Select(vd, SLT_SessionClose);
 		VSL_Select(vd, SLT_ReqEnd);
 	}
-	if (!cflag) {
+	if (!c_flag) {
 		VSL_Select(vd, SLT_BackendOpen);
 		VSL_Select(vd, SLT_BackendClose);
 		VSL_Select(vd, SLT_BackendReuse);
@@ -214,29 +223,29 @@
 }
 
 static int
-open_log(const char *w_opt, int a_flag)
+open_log(const char *w_arg, int a_flag)
 {
 	int fd, flags;
 
 	flags = (a_flag ? O_APPEND : O_TRUNC) | O_WRONLY | O_CREAT;
-	if (!strcmp(w_opt, "-"))
+	if (!strcmp(w_arg, "-"))
 		fd = STDOUT_FILENO;
 	else
-		fd = open(w_opt, flags, 0644);
+		fd = open(w_arg, flags, 0644);
 	if (fd < 0) {
-		perror(w_opt);
+		perror(w_arg);
 		exit (1);
 	}
 	return (fd);
 }
 
 static void
-do_write(struct VSL_data *vd, const char *w_opt, int a_flag)
+do_write(struct VSL_data *vd, const char *w_arg, int a_flag)
 {
 	int fd, i;
 	unsigned char *p;
 
-	fd = open_log(w_opt, a_flag);
+	fd = open_log(w_arg, a_flag);
 	signal(SIGHUP, sighup);
 	while (1) {
 		i = VSL_NextLog(vd, &p);
@@ -245,13 +254,13 @@
 		if (i > 0) {
 			i = write(fd, p, 5 + p[1]);
 			if (i < 0) {
-				perror(w_opt);
+				perror(w_arg);
 				exit(1);
 			}
 		}
 		if (reopen) {
 			close(fd);
-			fd = open_log(w_opt, a_flag);
+			fd = open_log(w_arg, a_flag);
 			reopen = 0;
 		}
 	}
@@ -264,7 +273,7 @@
 usage(void)
 {
 	fprintf(stderr,
-	    "usage: varnishlog %s [-aoV] [-w file]\n", VSL_USAGE);
+	    "usage: varnishlog %s [-aDoV] [-P file] [-w file]\n", VSL_USAGE);
 	exit(1);
 }
 
@@ -272,33 +281,41 @@
 main(int argc, char **argv)
 {
 	int i, c;
-	int a_flag = 0, o_flag = 0;
-	char *w_opt = NULL;
+	int a_flag = 0, D_flag = 0, o_flag = 0;
+	const char *P_arg = NULL;
+	const char *w_arg = NULL;
+	struct pidfh *pfh = NULL;
 	struct VSL_data *vd;
 
 	vd = VSL_New();
 
-	while ((c = getopt(argc, argv, VSL_ARGS "aoVw:")) != -1) {
+	while ((c = getopt(argc, argv, VSL_ARGS "aDoP:Vw:")) != -1) {
 		switch (c) {
 		case 'a':
 			a_flag = 1;
 			break;
+		case 'D':
+			D_flag = 1;
+			break;
 		case 'o':
 			o_flag = 1;
 			break;
+		case 'P':
+			P_arg = optarg;
+			break;
 		case 'V':
 			varnish_version("varnishlog");
 			exit(0);
 		case 'w':
-			w_opt = optarg;
+			w_arg = optarg;
 			break;
 		case 'c':
-			cflag = 1;
+			c_flag = 1;
 			if (VSL_Arg(vd, c, optarg) > 0)
 				break;
 			usage();
 		case 'b':
-			bflag = 1;
+			b_flag = 1;
 			if (VSL_Arg(vd, c, optarg) > 0)
 				break;
 			usage();
@@ -309,15 +326,30 @@
 		}
 	}
 
-	if (o_flag && w_opt != NULL)
+	if (o_flag && w_arg != NULL)
 		usage();
 
 	if (VSL_OpenLog(vd))
-		exit (1);
+		exit(1);
 
-	if (w_opt != NULL)
-		do_write(vd, w_opt, a_flag);
+	if (P_arg && (pfh = vpf_open(P_arg, 0600, NULL)) == NULL) {
+		perror(P_arg);
+		exit(1);
+	}
 
+	if (D_flag && daemon(0, 0) == -1) {
+		perror("daemon()");
+		if (pfh != NULL)
+			vpf_remove(pfh);
+		exit(1);
+	}
+
+	if (pfh != NULL)
+		vpf_write(pfh);
+
+	if (w_arg != NULL)
+		do_write(vd, w_arg, a_flag);
+
 	if (o_flag)
 		do_order(vd, argc - optind, argv + optind);
 
@@ -329,5 +361,7 @@
 			break;
 	}
 
-	return (0);
+	if (pfh != NULL)
+		vpf_remove(pfh);
+	exit(0);
 }

Modified: branches/1.0/bin/varnishstat/varnishstat.c
===================================================================
--- branches/1.0/bin/varnishstat/varnishstat.c	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/bin/varnishstat/varnishstat.c	2007-05-14 09:42:16 UTC (rev 1419)
@@ -169,6 +169,5 @@
 #undef MAC_STAT
 	}
 
-	exit (0);
-
+	exit(0);
 }

Modified: branches/1.0/bin/varnishtop/varnishtop.c
===================================================================
--- branches/1.0/bin/varnishtop/varnishtop.c	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/bin/varnishtop/varnishtop.c	2007-05-14 09:42:16 UTC (rev 1419)
@@ -39,8 +39,6 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "compat/vis.h"
-
 #include "vsb.h"
 
 #include "libvarnish.h"

Modified: branches/1.0/configure.ac
===================================================================
--- branches/1.0/configure.ac	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/configure.ac	2007-05-14 09:42:16 UTC (rev 1419)
@@ -60,6 +60,7 @@
 AC_CHECK_HEADERS([stddef.h])
 AC_CHECK_HEADERS([stdlib.h])
 AC_CHECK_HEADERS([unistd.h])
+AC_CHECK_HEADERS([vis.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
@@ -88,6 +89,7 @@
 AC_CHECK_FUNCS([strlcat strlcpy])
 AC_CHECK_FUNCS([strndup])
 AC_CHECK_FUNCS([vis strvis strvisx])
+AC_CHECK_FUNCS([daemon])
 
 save_LIBS="${LIBS}"
 LIBS="${LIBS} ${RT_LIBS}"
@@ -101,7 +103,13 @@
 
 # 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"
+
+# This corresponds to FreeBSD's WARNS level 6
+DEVELOPER_CFLAGS="-Wall -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"
+
+# Turn off warnings for two issues which occur frequently in our code
+#DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Wextra -Wno-missing-field-initializers -Wno-sign-compare"
+
 AC_ARG_ENABLE(developer-warnings,
 	AS_HELP_STRING([--enable-developer-warnings],[enable strict warnings (default is NO)]),
 	CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}")

Modified: branches/1.0/include/Makefile.am
===================================================================
--- branches/1.0/include/Makefile.am	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/include/Makefile.am	2007-05-14 09:42:16 UTC (rev 1419)
@@ -14,11 +14,13 @@
 	compat/strndup.h \
 	compat/vasprintf.h \
 	compat/vis.h \
+	flopen.h \
 	http_headers.h \
 	libvarnish.h \
 	libvcl.h \
 	miniobj.h \
 	queue.h \
+	vpf.h \
 	vsb.h \
 	shmlog.h \
 	shmlog_tags.h \

Copied: branches/1.0/include/flopen.h (from rev 1418, trunk/varnish-cache/include/flopen.h)

Copied: branches/1.0/include/vpf.h (from rev 1418, trunk/varnish-cache/include/vpf.h)

Modified: branches/1.0/lib/libvarnish/Makefile.am
===================================================================
--- branches/1.0/lib/libvarnish/Makefile.am	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/lib/libvarnish/Makefile.am	2007-05-14 09:42:16 UTC (rev 1419)
@@ -11,8 +11,10 @@
 	cli.c \
 	cli_common.c \
 	crc32.c \
+	flopen.c \
 	time.c \
 	version.c \
+	vpf.c \
 	vsb.c
 
 libvarnish_la_CFLAGS = -include config.h

Copied: branches/1.0/lib/libvarnish/flopen.c (from rev 1418, trunk/varnish-cache/lib/libvarnish/flopen.c)

Copied: branches/1.0/lib/libvarnish/vpf.c (from rev 1418, trunk/varnish-cache/lib/libvarnish/vpf.c)

Modified: branches/1.0/redhat/varnish.spec
===================================================================
--- branches/1.0/redhat/varnish.spec	2007-05-14 09:02:23 UTC (rev 1418)
+++ branches/1.0/redhat/varnish.spec	2007-05-14 09:42:16 UTC (rev 1419)
@@ -1,12 +1,11 @@
 Summary: Varnish is a high-performance HTTP accelerator
 Name: varnish
 Version: 1.0.3
-Release: 7%{?dist}
+Release: 8%{?dist}
 License: BSD-like
 Group: System Environment/Daemons
 URL: http://www.varnish-cache.org/
 Source0: http://downloads.sourceforge.net/varnish/varnish-%{version}.tar.gz
-Patch0: varnish-1.0.3.redhat.patch0
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: ncurses-devel 
 Requires: kernel >= 2.6.0 varnish-libs = %{version}-%{release}
@@ -47,15 +46,7 @@
 
 %prep
 %setup -q
-%patch0 -p0
 
-# Convert man pages to UTF-8
-for i in bin/*/*.1 man/*.7
-do
-   iconv -f iso-8859-1 -t utf-8 $i > $i.1.utf8
-   rm -f $i && mv $i.1.utf8 $i
-done
-
 %build
 
 # Remove "--disable static" if you want to build static libraries 
@@ -67,8 +58,7 @@
 sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
 sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
 
-#%{__make} %{?_smp_mflags}
-%{__make} 
+%{__make} %{?_smp_mflags}
 
 sed -e ' s/8080/80/g ' etc/vcl.conf > redhat/vcl.conf
 
@@ -124,6 +114,7 @@
 
 %post
 /sbin/chkconfig --add varnish
+/sbin/chkconfig --add varnishlog
 
 %preun
 if [ $1 -lt 1 ]; then
@@ -144,6 +135,10 @@
 %postun libs -p /sbin/ldconfig
 
 %changelog
+* Fri May 11 2007 Ingvar Hagelund <ingvar at linpro.no> - 1.0.svn-20070511
+- Threw latest changes into svn trunk
+- Removed the conversion of manpages into utf8. They are all utf8 in trunk
+
 * Wed May 09 2007 Ingvar Hagelund <ingvar at linpro.no> - 1.0.3-7
 - Simplified the references to the subpackage names
 - Added init and logrotate scripts for varnishlog

Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2007-05-14 09:02:23 UTC (rev 1418)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2007-05-14 09:42:16 UTC (rev 1419)
@@ -435,6 +435,7 @@
 
 /* cache_response.c */
 void RES_Error(struct sess *sp, int code, const char *reason);
+int Fake(struct sess *sp, int status, const char *reason, int ttl);
 void RES_WriteObj(struct sess *sp);
 
 /* cache_vcl.c */

Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c	2007-05-14 09:02:23 UTC (rev 1418)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c	2007-05-14 09:42:16 UTC (rev 1419)
@@ -320,7 +320,9 @@
 		}
 		usleep(100000 * n);
 	}
+#if 0
 	RES_Error(sp, 503, "Backend did not respond.");
+#endif
 	return (NULL);
 }
 

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2007-05-14 09:02:23 UTC (rev 1418)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2007-05-14 09:42:16 UTC (rev 1419)
@@ -286,27 +286,20 @@
 cnt_fetch(struct sess *sp)
 {
 
-
 	if (Fetch(sp)) {
-		sp->obj->cacheable = 0;
-		HSH_Unbusy(sp->obj);
-		HSH_Deref(sp->obj);
-		sp->obj = NULL;
-		sp->step = STP_DONE;
-		RES_Error(sp, 503, NULL);
-		return (0);
-	}
+		AZ(Fake(sp, 503, "Backend did not respond.", 30));
+	} else {
+		RFC2616_cache_policy(sp, &sp->obj->http);	/* XXX -> VCL */
 
-	RFC2616_cache_policy(sp, &sp->obj->http);	/* XXX -> VCL */
+		VCL_fetch_method(sp);
 
-	VCL_fetch_method(sp);
+		if (sp->handling == VCL_RET_ERROR)
+			INCOMPL();
 
-	if (sp->handling == VCL_RET_ERROR)
-		INCOMPL();
+		if (sp->handling == VCL_RET_PASS)
+			sp->obj->pass = 1;
+	}
 
-	if (sp->handling == VCL_RET_PASS)
-		sp->obj->pass = 1;
-
 	sp->obj->cacheable = 1;
 	if (sp->obj->objhead != NULL) {
 		HSH_Ref(sp->obj); /* get another, STP_DELIVER will deref */

Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c	2007-05-14 09:02:23 UTC (rev 1418)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c	2007-05-14 09:42:16 UTC (rev 1419)
@@ -29,11 +29,11 @@
  * $Id$
  */
 
-#include <stdio.h>		/* XXX: for NULL ?? */
-#include <string.h>		/* XXX: for NULL ?? */
 #include <sys/types.h>
 #include <sys/time.h>
 
+#include <stdlib.h>
+
 #ifndef HAVE_CLOCK_GETTIME
 #include "compat/clock_gettime.h"
 #endif
@@ -134,7 +134,7 @@
 	vsb_cat(sb,
 		"Server: Varnish\r\n"
 		"Connection: close\r\n"
-		"Content-Type: text/html; charset=iso-8859-1\r\n"
+		"Content-Type: text/html; charset=utf-8\r\n"
 		"\r\n"
 		"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
 		"<HTML>\r\n"
@@ -162,7 +162,118 @@
 	vsb_delete(sb);
 }
 
+/*--------------------------------------------------------------------*/
 
+int
+Fake(struct sess *sp, int status, const char *reason, int ttl)
+{
+	struct storage *st;
+	struct object *o;
+	struct vsb vsb;
+	struct http_msg *mp;
+	const char *msg;
+	char buf[40];
+	time_t now;
+	size_t len;
+
+	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
+	CHECK_OBJ_NOTNULL(&sp->obj->http, HTTP_MAGIC);
+	assert(sp->obj->busy != 0);
+	o = sp->obj;
+	time(&now);
+
+	assert(status >= 100 && status <= 999);
+	msg = "Unknown error";
+	for (mp = http_msg; mp->nbr != 0 && mp->nbr <= status; mp++)  {
+		if (mp->nbr < status)
+			continue;
+		if (mp->nbr > status)
+			break;
+		msg = mp->txt;
+		if (reason == NULL)
+			reason = mp->reason;
+		break;
+	}
+	if (reason == NULL)
+		reason = msg;
+	AN(reason);
+	AN(msg);
+
+	o->response = status;
+	o->valid = 1;
+	o->entered = now;
+	o->ttl = now + ttl;
+	o->last_modified = now;
+
+	/* generate body */
+	st = stevedore->alloc(stevedore, 1024);
+	XXXAN(st->stevedore);
+	TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
+
+	vsb_new(&vsb, (char *)st->ptr, st->space, VSB_FIXEDLEN);
+	vsb_cat(&vsb,
+	    "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
+	    "<HTML>\r\n"
+	    "  <HEAD>\r\n");
+	vsb_printf(&vsb,
+	    "    <TITLE>%03d %s</TITLE>\r\n", status, msg);
+	vsb_printf(&vsb,
+	    "  </HEAD>\r\n"
+	    "  <BODY>\r\n");
+	vsb_printf(&vsb,
+	    "    <H1>Error %03d %s</H1>\r\n", status, msg);
+	vsb_printf(&vsb,
+	    "    <P>%s</P>\r\n", reason);
+	vsb_printf(&vsb,
+	    "    <H3>Guru Meditation:</H3>\r\n");
+	vsb_printf(&vsb,
+	    "    <P>XID: %u</P>\r\n", sp->xid);
+	vsb_printf(&vsb,
+	    "    <I><A href=\"http://www.varnish-cache.org/\">Varnish</A></I>\r\n"
+	    "  </BODY>\r\n"
+	    "</HTML>\r\n");
+	vsb_finish(&vsb);
+	vsb_finish(&vsb);
+	o->len = st->len = vsb_len(&vsb);
+	vsb_delete(&vsb);
+
+	/* generate header */
+	o->http.s = calloc(len = 1024, 1);
+	XXXAN(o->http.s);
+	o->http.e = o->http.s + len;
+
+	/* XXX we could use a little less magic here */
+	vsb_new(&vsb, o->http.s, len, VSB_FIXEDLEN);
+	vsb_printf(&vsb, "\n");
+	vsb_printf(&vsb, "\n");
+	vsb_printf(&vsb, "HTTP/1.1\r\n");
+	vsb_printf(&vsb, "%d\n", status);
+	vsb_printf(&vsb, "%s\n", reason);
+	TIM_format(now, buf);
+	vsb_printf(&vsb, "Date: %s\n", buf);
+	vsb_printf(&vsb, "Server: Varnish\n");
+	vsb_printf(&vsb, "Retry-After: %ju\n", (uintmax_t)ttl);
+	vsb_printf(&vsb, "Content-Type: text/html; charset=utf-8\n");
+	vsb_printf(&vsb, "Content-Length: %ud\n", o->len);
+	vsb_finish(&vsb);
+	vsb_delete(&vsb);
+
+	/* XXX and here */
+	o->http.f = o->http.s;
+	o->http.nhd = 0;
+	do {
+		o->http.hd[o->http.nhd].b = o->http.f;
+		while (*o->http.f != '\n')
+			++o->http.f;
+		o->http.hd[o->http.nhd].e = o->http.f;
+		++o->http.nhd;
+		++o->http.f;
+	} while (*o->http.f);
+
+	return (0);
+}
+
 /*--------------------------------------------------------------------*/
 
 static void

Modified: trunk/varnish-cache/bin/varnishtop/varnishtop.c
===================================================================
--- trunk/varnish-cache/bin/varnishtop/varnishtop.c	2007-05-14 09:02:23 UTC (rev 1418)
+++ trunk/varnish-cache/bin/varnishtop/varnishtop.c	2007-05-14 09:42:16 UTC (rev 1419)
@@ -199,5 +199,5 @@
 			TAILQ_INSERT_BEFORE(tp, tp2, list);
 		}
 	}
-	return (0);
+	exit(0);
 }




More information about the varnish-commit mailing list