r1723 - in branches/1.1: . bin/varnishd bin/varnishstat doc include include/compat lib/libcompat lib/libvarnish lib/libvcl

des at projects.linpro.no des at projects.linpro.no
Thu Jul 19 14:20:28 CEST 2007


Author: des
Date: 2007-07-19 14:20:28 +0200 (Thu, 19 Jul 2007)
New Revision: 1723

Removed:
   branches/1.1/include/compat/clock_gettime.h
   branches/1.1/lib/libcompat/clock_gettime.c
Modified:
   branches/1.1/
   branches/1.1/autogen.sh
   branches/1.1/bin/varnishd/cache_hash.c
   branches/1.1/bin/varnishd/cache_lru.c
   branches/1.1/bin/varnishd/mgt_child.c
   branches/1.1/bin/varnishd/mgt_vcc.c
   branches/1.1/bin/varnishd/stevedore.c
   branches/1.1/bin/varnishstat/varnishstat.c
   branches/1.1/doc/changes-1.0.4-1.1.xml
   branches/1.1/include/Makefile.am
   branches/1.1/lib/libcompat/Makefile.am
   branches/1.1/lib/libvarnish/time.c
   branches/1.1/lib/libvcl/vcc_string.c
Log:
Merged revisions 1709-1722 via svnmerge from 
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache

........
  r1710 | des | 2007-07-17 12:33:46 +0200 (Tue, 17 Jul 2007) | 9 lines
  
  Fix child restart by always calling close_sockets() when the child dies;
  otherwise open_sockets() fails, which causes start_child() to fail silently.
  
  Furthermore, if open_sockets() fails and child_state is CH_DIED, it will
  not be possible to start it manually later; therefore, set child_state
  to CH_STOPPED when open_sockets() fails.
  
  Note: it wouldn't hurt if open_sockets() were a little more talkative.
........
  r1711 | des | 2007-07-17 15:05:08 +0200 (Tue, 17 Jul 2007) | 6 lines
  
  Amend previous commit.  The problem was that when a socket was already open,
  open_sockets() did not count it as "good".  Having fixed this, revert to the
  previous behaviour of keeping the sockets open if auto_restart is on; this
  avoids having a brief window (until they are reopened) during which client
  connections are refused.
........
  r1712 | des | 2007-07-17 18:56:21 +0200 (Tue, 17 Jul 2007) | 4 lines
  
  Remove object from LRU list before freeing it; this does not entirely
  eliminate races between the LRU code and the expiry code, but it does
  make them a lot less likely.
........
  r1713 | des | 2007-07-17 18:58:40 +0200 (Tue, 17 Jul 2007) | 2 lines
  
  Return count like the comment says we do.
........
  r1714 | des | 2007-07-17 19:06:12 +0200 (Tue, 17 Jul 2007) | 10 lines
  
  Assert that LRU_DiscardOne() returns 1, to avoid an unlikely but possible
  scenario where multiple clients each require different objects such that
  the sum of the sizes of the objects is larger than the cache (or, in the
  extreme case, one client requests an object which is larger than the
  cache) causing STV_alloc() to enter an infinite loop.
  
  This is not ideal - a better solution would be return NULL and have the
  caller deal with the problem, possibly by returning a 503 result, or by
  stalling the request for some time.
........
  r1715 | des | 2007-07-19 12:58:31 +0200 (Thu, 19 Jul 2007) | 2 lines
  
  gettimeofday() is good enough for varnishstat.
........
  r1716 | des | 2007-07-19 13:01:36 +0200 (Thu, 19 Jul 2007) | 2 lines
  
  If clock_gettime() is not available, use gettimeofday() directly.
........
  r1717 | des | 2007-07-19 13:02:57 +0200 (Thu, 19 Jul 2007) | 2 lines
  
  Retire libcompat's clock_gettime().
........
  r1718 | des | 2007-07-19 13:03:55 +0200 (Thu, 19 Jul 2007) | 2 lines
  
  Missed one occurrence of clock_gettime().
........
  r1719 | des | 2007-07-19 13:11:20 +0200 (Thu, 19 Jul 2007) | 4 lines
  
  Make regexp variables static.  This has the side effect of replacing
  tentative definitions with non-tentative ones, thus sidestepping one
  of the issues we have on MacOS X.
........
  r1720 | des | 2007-07-19 13:17:59 +0200 (Thu, 19 Jul 2007) | 4 lines
  
  Adapt for use on MacOS X / Darwin, which has GNU libtool installed as
  glibtool, and has a version of automake 1.6 which does not exhibit the
  bug I've observed on other platforms.
........
  r1721 | des | 2007-07-19 13:49:43 +0200 (Thu, 19 Jul 2007) | 3 lines
  
  Use the correct cc command line on MacOS.  This is a gross hack.
  Also, ignore the result of dlclose().
........
  r1722 | des | 2007-07-19 14:18:57 +0200 (Thu, 19 Jul 2007) | 2 lines
  
  Document Mac OS X compatibility.
........



Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk/varnish-cache:1-1708
   + /trunk/varnish-cache:1-1722

Modified: branches/1.1/autogen.sh
===================================================================
--- branches/1.1/autogen.sh	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/autogen.sh	2007-07-19 12:20:28 UTC (rev 1723)
@@ -3,22 +3,34 @@
 # $Id$
 #
 
-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
+warn() {
+	echo "WARNING: $@" 1>&2
+}
 
+case `uname -s` in
+Darwin)
+	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
+	;;
+Linux)
+	LIBTOOLIZE=libtoolize
+	;;
+esac
+
 automake_version=$(automake --version | tr ' ' '\n' | egrep '^[0-9]\.[0-9a-z.-]+')
 if [ -z "$automake_version" ] ; then
-    echo "unable to determine automake version"
-    exit 1
+    warn "unable to determine automake version"
 else
     case $automake_version in
 	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
+	    warn "automake ($automake_version) detected; 1.9 or newer recommended"
 	    ;;
 	*)
 	    ;;
@@ -28,7 +40,7 @@
 set -ex
 
 aclocal ${FIX_BROKEN_FREEBSD_PORTS}
-libtoolize --copy --force
+$LIBTOOLIZE --copy --force
 autoheader
 automake --add-missing --copy --foreign
 autoconf

Modified: branches/1.1/bin/varnishd/cache_hash.c
===================================================================
--- branches/1.1/bin/varnishd/cache_hash.c	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/bin/varnishd/cache_hash.c	2007-07-19 12:20:28 UTC (rev 1723)
@@ -259,6 +259,7 @@
 	if (o->vary != NULL)
 		free(o->vary);
 
+	LRU_Remove(o);
 	HSH_Freestore(o);
 	FREE_OBJ(o);
 	VSL_stats->n_object--;

Modified: branches/1.1/bin/varnishd/cache_lru.c
===================================================================
--- branches/1.1/bin/varnishd/cache_lru.c	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/bin/varnishd/cache_lru.c	2007-07-19 12:20:28 UTC (rev 1723)
@@ -161,7 +161,7 @@
 		}
 	}
 	UNLOCK(&lru_mtx);
-	return (0);
+	return (count);
 }
 
 /*

Modified: branches/1.1/bin/varnishd/mgt_child.c
===================================================================
--- branches/1.1/bin/varnishd/mgt_child.c	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/bin/varnishd/mgt_child.c	2007-07-19 12:20:28 UTC (rev 1723)
@@ -130,8 +130,10 @@
 	int good = 0;
 
 	TAILQ_FOREACH_SAFE(ls, &heritage.socks, list, ls2) {
-		if (ls->sock >= 0)
+		if (ls->sock >= 0) {
+			good++;
 			continue;
+		}
 		ls->sock = VSS_listen(ls->addr, params->listen_depth);
 		if (ls->sock < 0) {
 			TAILQ_REMOVE(&heritage.socks, ls, list);
@@ -174,8 +176,10 @@
 	if (child_state != CH_STOPPED && child_state != CH_DIED)
 		return;
 
-	if (open_sockets())
+	if (open_sockets() != 0) {
+		child_state = CH_STOPPED;
 		return;	/* XXX ?? */
+	}
 
 	child_state = CH_STARTING;
 
@@ -341,8 +345,7 @@
 	else if (child_state == CH_DIED) {
 		close_sockets();
 		child_state = CH_STOPPED;
-	}
-	else if (child_state == CH_STOPPING)
+	} else if (child_state == CH_STOPPING)
 		child_state = CH_STOPPED;
 	return (0);
 }

Modified: branches/1.1/bin/varnishd/mgt_vcc.c
===================================================================
--- branches/1.1/bin/varnishd/mgt_vcc.c	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/bin/varnishd/mgt_vcc.c	2007-07-19 12:20:28 UTC (rev 1723)
@@ -181,7 +181,11 @@
 	/* Attempt to open a pipe to the system C-compiler */
 	len = snprintf(buf, sizeof buf,
             "ln -f %s _.c ;"			/* XXX: for debugging */
+#ifdef __APPLE__
+	    "exec cc -dynamiclib -Wl,-flat_namespace,-undefined,suppress -o %s -x c - < %s 2>&1",
+#else
 	    "exec cc -fpic -shared -Wl,-x -o %s -x c - < %s 2>&1",
+#endif
 	    sf, of, sf);
 	xxxassert(len < sizeof buf);
 
@@ -229,7 +233,7 @@
 		free(of);
 		of = NULL;
 	} else
-		AZ(dlclose(p));
+		(void)dlclose(p);
 
 	/* clean up and return */
 	unlink(sf);

Modified: branches/1.1/bin/varnishd/stevedore.c
===================================================================
--- branches/1.1/bin/varnishd/stevedore.c	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/bin/varnishd/stevedore.c	2007-07-19 12:20:28 UTC (rev 1723)
@@ -39,7 +39,7 @@
 	AN(stevedore->alloc);
 	do {
 		if ((st = stevedore->alloc(stevedore, size)) == NULL)
-			LRU_DiscardOne();
+			AN(LRU_DiscardOne());
 	} while (st == NULL);
 	return (st);
 }

Modified: branches/1.1/bin/varnishstat/varnishstat.c
===================================================================
--- branches/1.1/bin/varnishstat/varnishstat.c	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/bin/varnishstat/varnishstat.c	2007-07-19 12:20:28 UTC (rev 1723)
@@ -32,6 +32,8 @@
  * Log tailer for Varnish
  */
 
+#include <sys/time.h>
+
 #include <curses.h>
 #include <errno.h>
 #include <limits.h>
@@ -42,10 +44,6 @@
 #include <time.h>
 #include <unistd.h>
 
-#ifndef HAVE_CLOCK_GETTIME
-#include "compat/clock_gettime.h"
-#endif
-
 #include "libvarnish.h"
 #include "shmlog.h"
 #include "varnishapi.h"
@@ -64,7 +62,7 @@
 {
 	struct varnish_stats copy;
 	intmax_t ju;
-	struct timespec ts;
+	struct timeval tv;
 	double tt, lt, hit, miss, ratio, up;
 	double a1, a2, a3;
 	unsigned n1, n2, n3;
@@ -86,11 +84,11 @@
 
 	lt = 0;
 	while (1) {
-		clock_gettime(CLOCK_REALTIME, &ts);
-		tt = ts.tv_nsec * 1e-9 + ts.tv_sec;
+		gettimeofday(&tv, NULL);
+		tt = tv.tv_usec * 1e-6 + tv.tv_sec;
 		lt = tt - lt;
 
-		rt = ts.tv_sec - VSL_stats->start_time;
+		rt = tv.tv_sec - VSL_stats->start_time;
 		up = rt;
 
 		mvprintw(0, 0, "%*s", COLS - 1, VSL_Name());
@@ -160,11 +158,11 @@
 static void
 do_once(struct varnish_stats *VSL_stats)
 {
-	struct timespec ts;
+	struct timeval tv;
 	double up;
 
-	clock_gettime(CLOCK_REALTIME, &ts);
-	up = ts.tv_sec - VSL_stats->start_time;
+	gettimeofday(&tv, NULL);
+	up = tv.tv_sec - VSL_stats->start_time;
 
 #define MAC_STAT(n, t, f, d) \
 	do { \

Modified: branches/1.1/doc/changes-1.0.4-1.1.xml
===================================================================
--- branches/1.1/doc/changes-1.0.4-1.1.xml	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/doc/changes-1.0.4-1.1.xml	2007-07-19 12:20:28 UTC (rev 1723)
@@ -178,6 +178,10 @@
       <para>A new management command, <command>status</command>,
       returns the state of the child.</para>
     </change>
+
+    <change type="enh" ref="1719-1721">
+      <para>Varnish will now build and run on Mac OS X.</para>
+    </change>
   </subsystem>
 
   <subsystem>

Modified: branches/1.1/include/Makefile.am
===================================================================
--- branches/1.1/include/Makefile.am	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/include/Makefile.am	2007-07-19 12:20:28 UTC (rev 1723)
@@ -13,7 +13,6 @@
 	cli_common.h \
 	cli_priv.h \
 	compat/asprintf.h \
-	compat/clock_gettime.h \
 	compat/setproctitle.h \
 	compat/srandomdev.h \
 	compat/strlcat.h \

Deleted: branches/1.1/include/compat/clock_gettime.h
===================================================================
--- branches/1.1/include/compat/clock_gettime.h	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/include/compat/clock_gettime.h	2007-07-19 12:20:28 UTC (rev 1723)
@@ -1,44 +0,0 @@
-/*-
- * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2007 Linpro AS
- * All rights reserved.
- *
- * Author: Dag-Erling Smørgrav <des at linpro.no>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id$
- */
-
-#ifndef COMPAT_CLOCK_GETTIME_H_INCLUDED
-#define COMPAT_CLOCK_GETTIME_H_INCLUDED
-
-#ifndef HAVE_CLOCK_GETTIME
-typedef enum {
-	CLOCK_REALTIME,
-	CLOCK_MONOTONIC,
-} clockid_t;
-
-int clock_gettime(clockid_t clk_id, struct timespec *tp);
-#endif
-
-#endif

Modified: branches/1.1/lib/libcompat/Makefile.am
===================================================================
--- branches/1.1/lib/libcompat/Makefile.am	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/lib/libcompat/Makefile.am	2007-07-19 12:20:28 UTC (rev 1723)
@@ -6,7 +6,6 @@
 
 libcompat_a_SOURCES = \
 	asprintf.c \
-	clock_gettime.c \
 	vasprintf.c \
 	setproctitle.c \
 	srandomdev.c \

Deleted: branches/1.1/lib/libcompat/clock_gettime.c
===================================================================
--- branches/1.1/lib/libcompat/clock_gettime.c	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/lib/libcompat/clock_gettime.c	2007-07-19 12:20:28 UTC (rev 1723)
@@ -1,60 +0,0 @@
-/*-
- * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2007 Linpro AS
- * All rights reserved.
- *
- * Author: Dag-Erling Smørgrav <des at linpro.no>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id$
- *
- */
-
-#ifndef HAVE_CLOCK_GETTIME
-
-#include <sys/time.h>
-
-#include <errno.h>
-#include <time.h>
-
-#include "compat/clock_gettime.h"
-
-int
-clock_gettime(clockid_t clk_id, struct timespec *tp)
-{
-	struct timeval tv;
-
-	switch (clk_id) {
-	case CLOCK_REALTIME:
-	case CLOCK_MONOTONIC:
-		if (gettimeofday(&tv, NULL) != 0)
-			return (-1);
-		tp->tv_sec = tv.tv_sec;
-		tp->tv_nsec = tv.tv_usec * 1000;
-		return (0);
-	default:
-		errno = EINVAL;
-		return (-1);
-	}
-}
-#endif

Modified: branches/1.1/lib/libvarnish/time.c
===================================================================
--- branches/1.1/lib/libvarnish/time.c	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/lib/libvarnish/time.c	2007-07-19 12:20:28 UTC (rev 1723)
@@ -46,32 +46,44 @@
  *
  */
 
+#include <sys/time.h>
+
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
 
-#ifndef HAVE_CLOCK_GETTIME
-#include "compat/clock_gettime.h"
-#endif
-
 #include "libvarnish.h"
 
 double
 TIM_mono(void)
 {
+#ifdef HAVE_CLOCK_GETTIME
 	struct timespec ts;
 
 	assert(clock_gettime(CLOCK_MONOTONIC, &ts) == 0);
 	return (ts.tv_sec + 1e-9 * ts.tv_nsec);
+#else
+	struct timeval tv;
+
+	assert(gettimeofday(&tv, NULL) == 0);
+	return (tv.tv_sec + 1e-6 * tv.tv_usec);
+#endif
 }
 
 double
 TIM_real(void)
 {
+#ifdef HAVE_CLOCK_GETTIME
 	struct timespec ts;
 
 	assert(clock_gettime(CLOCK_REALTIME, &ts) == 0);
 	return (ts.tv_sec + 1e-9 * ts.tv_nsec);
+#else
+	struct timeval tv;
+
+	assert(gettimeofday(&tv, NULL) == 0);
+	return (tv.tv_sec + 1e-6 * tv.tv_usec);
+#endif
 }
 
 void
@@ -85,9 +97,10 @@
 
 /* XXX: add statistics ? */
 static const char *fmts[] = {
-	"%a, %d %b %Y %T GMT",	/* RFC 822 & RFC1123 */
-	"%A, %d-%b-%y %T GMT",	/* RFC850 */
+	"%a, %d %b %Y %T GMT",	/* RFC 822 & RFC 1123 */
+	"%A, %d-%b-%y %T GMT",	/* RFC 850 */
 	"%a %b %d %T %Y",	/* ANSI-C asctime() */
+	"%F %T",		/* ISO 8601 */
 	NULL
 };
 

Modified: branches/1.1/lib/libvcl/vcc_string.c
===================================================================
--- branches/1.1/lib/libvcl/vcc_string.c	2007-07-19 12:18:57 UTC (rev 1722)
+++ branches/1.1/lib/libvcl/vcc_string.c	2007-07-19 12:20:28 UTC (rev 1723)
@@ -56,7 +56,7 @@
 	p = TlAlloc(tl, strlen(buf) + 1);
 	strcpy(p, buf);
 
-	Fh(tl, 0, "void *%s;\n", buf);
+	Fh(tl, 0, "static void *%s;\n", buf);
 	Fi(tl, 0, "\tVRT_re_init(&%s, ",buf);
 	EncToken(tl->fi, tl->t);
 	Fi(tl, 0, ", %d);\n", sub);




More information about the varnish-commit mailing list