r2112 - in branches/1.2: . bin/varnishd include include/compat lib/libvarnish lib/libvarnishcompat

des at projects.linpro.no des at projects.linpro.no
Thu Oct 18 13:51:33 CEST 2007


Author: des
Date: 2007-10-18 13:51:32 +0200 (Thu, 18 Oct 2007)
New Revision: 2112

Added:
   branches/1.2/include/compat/daemon.h
   branches/1.2/lib/libvarnishcompat/daemon.c
Modified:
   branches/1.2/
   branches/1.2/bin/varnishd/cache_http.c
   branches/1.2/bin/varnishd/cache_main.c
   branches/1.2/include/Makefile.am
   branches/1.2/lib/libvarnish/assert.c
   branches/1.2/lib/libvarnish/binary_heap.c
   branches/1.2/lib/libvarnish/crc32.c
   branches/1.2/lib/libvarnish/vss.c
   branches/1.2/lib/libvarnishcompat/Makefile.am
Log:
Merged revisions 2104-2107 via svnmerge from 
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache

........
  r2104 | phk | 2007-10-16 12:17:24 +0200 (Tue, 16 Oct 2007) | 2 lines
  
  Silence flexelint
........
  r2105 | des | 2007-10-16 15:10:43 +0200 (Tue, 16 Oct 2007) | 2 lines
  
  Use %zd for size_t.
........
  r2106 | des | 2007-10-16 16:12:23 +0200 (Tue, 16 Oct 2007) | 2 lines
  
  Pull in FreeBSD's daemon(3) for platforms that lack it.
........
  r2107 | des | 2007-10-16 16:15:54 +0200 (Tue, 16 Oct 2007) | 2 lines
  
  Whitespace cleanup.
........



Property changes on: branches/1.2
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk/varnish-cache:1-2101
   + /trunk/varnish-cache:1-2101,2104-2107

Modified: branches/1.2/bin/varnishd/cache_http.c
===================================================================
--- branches/1.2/bin/varnishd/cache_http.c	2007-10-18 11:10:25 UTC (rev 2111)
+++ branches/1.2/bin/varnishd/cache_http.c	2007-10-18 11:51:32 UTC (rev 2112)
@@ -89,7 +89,7 @@
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
 	if (t > HTTP_HDR_FIRST)
 		t = HTTP_HDR_FIRST;
-	assert(hp->logtag >= HTTP_Rx && hp->logtag <= HTTP_Obj);
+	assert(hp->logtag >= HTTP_Rx && hp->logtag <= HTTP_Obj); /*lint !e685*/
 	assert(t >= HTTP_HDR_REQ && t <= HTTP_HDR_FIRST);
 	return (logmtx[hp->logtag][t]);
 }

Modified: branches/1.2/bin/varnishd/cache_main.c
===================================================================
--- branches/1.2/bin/varnishd/cache_main.c	2007-10-18 11:10:25 UTC (rev 2111)
+++ branches/1.2/bin/varnishd/cache_main.c	2007-10-18 11:51:32 UTC (rev 2112)
@@ -51,7 +51,7 @@
 	setbuf(stderr, NULL);
 	printf("Child starts\n");
 
-#define SZOF(foo)	printf("sizeof(%s) = %d\n", #foo, sizeof(foo));
+#define SZOF(foo)	printf("sizeof(%s) = %zd\n", #foo, sizeof(foo));
 	SZOF(struct ws);
 	SZOF(struct http);
 	SZOF(struct http_conn);

Modified: branches/1.2/include/Makefile.am
===================================================================
--- branches/1.2/include/Makefile.am	2007-10-18 11:10:25 UTC (rev 2111)
+++ branches/1.2/include/Makefile.am	2007-10-18 11:51:32 UTC (rev 2112)
@@ -7,12 +7,13 @@
 	stats.h \
 	varnishapi.h
 
-noinst_HEADERS = \
+nobase_noinst_HEADERS = \
 	binary_heap.h \
 	cli.h \
 	cli_common.h \
 	cli_priv.h \
 	compat/asprintf.h \
+	compat/daemon.h \
 	compat/setproctitle.h \
 	compat/srandomdev.h \
 	compat/strlcat.h \

Copied: branches/1.2/include/compat/daemon.h (from rev 2107, trunk/varnish-cache/include/compat/daemon.h)
===================================================================
--- branches/1.2/include/compat/daemon.h	                        (rev 0)
+++ branches/1.2/include/compat/daemon.h	2007-10-18 11:51:32 UTC (rev 2112)
@@ -0,0 +1,39 @@
+/*-
+ * 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_DAEMON_H_INCLUDED
+#define COMPAT_DAEMON_H_INCLUDED
+
+#ifndef HAVE_DAEMON
+int daemon(int nochdir, int noclose);
+#endif
+
+#endif

Modified: branches/1.2/lib/libvarnish/assert.c
===================================================================
--- branches/1.2/lib/libvarnish/assert.c	2007-10-18 11:10:25 UTC (rev 2111)
+++ branches/1.2/lib/libvarnish/assert.c	2007-10-18 11:51:32 UTC (rev 2112)
@@ -57,4 +57,3 @@
 	    "  errno = %d (%s)\n", func, file, line, cond, err, strerror(err));
 	abort();
 }
-

Modified: branches/1.2/lib/libvarnish/binary_heap.c
===================================================================
--- branches/1.2/lib/libvarnish/binary_heap.c	2007-10-18 11:10:25 UTC (rev 2111)
+++ branches/1.2/lib/libvarnish/binary_heap.c	2007-10-18 11:51:32 UTC (rev 2112)
@@ -298,7 +298,7 @@
 #else
 
 struct foo {
-	unsigned 	idx;
+	unsigned	idx;
 	unsigned	key;
 };
 

Modified: branches/1.2/lib/libvarnish/crc32.c
===================================================================
--- branches/1.2/lib/libvarnish/crc32.c	2007-10-18 11:10:25 UTC (rev 2111)
+++ branches/1.2/lib/libvarnish/crc32.c	2007-10-18 11:51:32 UTC (rev 2112)
@@ -99,4 +99,3 @@
 	crc = crc32(~0U, p1, l);
 	return (crc ^ ~0U);
 }
-

Modified: branches/1.2/lib/libvarnish/vss.c
===================================================================
--- branches/1.2/lib/libvarnish/vss.c	2007-10-18 11:10:25 UTC (rev 2111)
+++ branches/1.2/lib/libvarnish/vss.c	2007-10-18 11:51:32 UTC (rev 2112)
@@ -127,14 +127,14 @@
 	struct vss_addr **va;
 	int i, ret;
 
-        memset(&hints, 0, sizeof hints);
-        hints.ai_socktype = SOCK_STREAM;
-        hints.ai_flags = AI_PASSIVE;
-        ret = getaddrinfo(addr, port, &hints, &res0);
-        if (ret != 0) {
-                fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(ret));
-                return (0);
-        }
+	memset(&hints, 0, sizeof hints);
+	hints.ai_socktype = SOCK_STREAM;
+	hints.ai_flags = AI_PASSIVE;
+	ret = getaddrinfo(addr, port, &hints, &res0);
+	if (ret != 0) {
+		fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(ret));
+		return (0);
+	}
 	for (res = res0, i = 0; res != NULL; res = res->ai_next)
 		++i;
 	va = calloc(i, sizeof *va);

Modified: branches/1.2/lib/libvarnishcompat/Makefile.am
===================================================================
--- branches/1.2/lib/libvarnishcompat/Makefile.am	2007-10-18 11:10:25 UTC (rev 2111)
+++ branches/1.2/lib/libvarnishcompat/Makefile.am	2007-10-18 11:51:32 UTC (rev 2112)
@@ -6,6 +6,7 @@
 
 libvarnishcompat_la_SOURCES = \
 	asprintf.c \
+	daemon.c \
 	vasprintf.c \
 	setproctitle.c \
 	srandomdev.c \

Copied: branches/1.2/lib/libvarnishcompat/daemon.c (from rev 2107, trunk/varnish-cache/lib/libvarnishcompat/daemon.c)
===================================================================
--- branches/1.2/lib/libvarnishcompat/daemon.c	                        (rev 0)
+++ branches/1.2/lib/libvarnishcompat/daemon.c	2007-10-18 11:51:32 UTC (rev 2112)
@@ -0,0 +1,92 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * 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.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 THE REGENTS 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$
+ * Derived from:
+ * $FreeBSD: src/lib/libc/gen/daemon.c,v 1.8 2007/01/09 00:27:53 imp Exp $
+ */
+
+#ifndef HAVE_DAEMON
+
+#include <errno.h>
+#include <fcntl.h>
+#include <paths.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <unistd.h>
+
+#include "compat/daemon.h"
+
+int
+daemon(int nochdir, int noclose)
+{
+	struct sigaction osa, sa;
+	int fd;
+	pid_t newgrp;
+	int oerrno;
+	int osa_ok;
+
+	/* A SIGHUP may be thrown when the parent exits below. */
+	sigemptyset(&sa.sa_mask);
+	sa.sa_handler = SIG_IGN;
+	sa.sa_flags = 0;
+	osa_ok = sigaction(SIGHUP, &sa, &osa);
+
+	switch (fork()) {
+	case -1:
+		return (-1);
+	case 0:
+		break;
+	default:
+		exit(0);
+	}
+
+	newgrp = setsid();
+	oerrno = errno;
+	if (osa_ok != -1)
+		sigaction(SIGHUP, &osa, NULL);
+
+	if (newgrp == -1) {
+		errno = oerrno;
+		return (-1);
+	}
+
+	if (!nochdir)
+		(void)chdir("/");
+
+	if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
+		(void)dup2(fd, STDIN_FILENO);
+		(void)dup2(fd, STDOUT_FILENO);
+		(void)dup2(fd, STDERR_FILENO);
+		if (fd > 2)
+			(void)close(fd);
+	}
+	return (0);
+}
+
+#endif




More information about the varnish-commit mailing list