From knutroy at projects.linpro.no Mon Sep 3 10:12:29 2007
From: knutroy at projects.linpro.no (knutroy at projects.linpro.no)
Date: Mon, 3 Sep 2007 12:12:29 +0200 (CEST)
Subject: r1932 - in trunk/varnish-tools: autobuild regress regress/bin
regress/lib/Varnish
Message-ID: <20070903101229.DC4261EC21C@projects.linpro.no>
Author: knutroy
Date: 2007-09-03 12:12:29 +0200 (Mon, 03 Sep 2007)
New Revision: 1932
Added:
trunk/varnish-tools/regress/MANIFEST
trunk/varnish-tools/regress/Makefile.PL
trunk/varnish-tools/regress/bin/
trunk/varnish-tools/regress/bin/varnish-regress.pl
Removed:
trunk/varnish-tools/regress/varnish-regress.pl
Modified:
trunk/varnish-tools/autobuild/autobuild.sh
trunk/varnish-tools/regress/lib/Varnish/Test.pm
Log:
* Added Makefile.PL to test framework.
* Moved varnish-regress.pl to subdirectory "bin".
* Minor POD additions.
Modified: trunk/varnish-tools/autobuild/autobuild.sh
===================================================================
--- trunk/varnish-tools/autobuild/autobuild.sh 2007-08-31 12:14:06 UTC (rev 1931)
+++ trunk/varnish-tools/autobuild/autobuild.sh 2007-09-03 10:12:29 UTC (rev 1932)
@@ -85,7 +85,7 @@
) > build.log 2>&1
# Run regression test framework.
-PATH=/tmp/"$DIR"/sbin:"$PATH" trunk/varnish-tools/regress/varnish-regress.pl > regress.html 2> regress.log
+PATH=/tmp/"$DIR"/sbin:"$PATH" trunk/varnish-tools/regress/bin/varnish-regress.pl > regress.html 2> regress.log
# Update status file.
grep -A 4 '
Total ' regress.html \
Added: trunk/varnish-tools/regress/MANIFEST
===================================================================
--- trunk/varnish-tools/regress/MANIFEST (rev 0)
+++ trunk/varnish-tools/regress/MANIFEST 2007-09-03 10:12:29 UTC (rev 1932)
@@ -0,0 +1,23 @@
+bin/varnish-regress.pl
+doc/README
+doc/structure.dia
+lib/Varnish/Test.pm
+lib/Varnish/Test/Case.pm
+lib/Varnish/Test/Case/LRU.pm
+lib/Varnish/Test/Case/POST.pm
+lib/Varnish/Test/Case/RePurge.pm
+lib/Varnish/Test/Case/Ticket056.pm
+lib/Varnish/Test/Case/Ticket102.pm
+lib/Varnish/Test/Case/Ticket128.pm
+lib/Varnish/Test/Case/Vary.pm
+lib/Varnish/Test/Client.pm
+lib/Varnish/Test/Engine.pm
+lib/Varnish/Test/Report.pm
+lib/Varnish/Test/Report/HTML.pm
+lib/Varnish/Test/Report/report.html
+lib/Varnish/Test/Server.pm
+lib/Varnish/Test/Varnish.pm
+Makefile.PL
+MANIFEST
+README
+TODO
Added: trunk/varnish-tools/regress/Makefile.PL
===================================================================
--- trunk/varnish-tools/regress/Makefile.PL (rev 0)
+++ trunk/varnish-tools/regress/Makefile.PL 2007-09-03 10:12:29 UTC (rev 1932)
@@ -0,0 +1,6 @@
+# $Id$
+
+use ExtUtils::MakeMaker;
+
+WriteMakefile(NAME => 'Varnish::Test',
+ EXE_FILES => ['bin/varnish-regress.pl']);
Property changes on: trunk/varnish-tools/regress/Makefile.PL
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: trunk/varnish-tools/regress/bin/varnish-regress.pl (from rev 1931, trunk/varnish-tools/regress/varnish-regress.pl)
===================================================================
--- trunk/varnish-tools/regress/bin/varnish-regress.pl (rev 0)
+++ trunk/varnish-tools/regress/bin/varnish-regress.pl 2007-09-03 10:12:29 UTC (rev 1932)
@@ -0,0 +1,100 @@
+#!/usr/bin/perl -w
+#-
+# Copyright (c) 2006 Linpro AS
+# 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
+# in this position and unchanged.
+# 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 THE 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$
+#
+
+=head1 NAME
+
+varnish-regress.pl - run Varnish regression tests
+
+=cut
+
+use strict;
+
+eval { require Varnish::Test };
+if ($@) {
+ use FindBin;
+ use lib "$FindBin::Bin/../lib";
+}
+
+use Getopt::Long;
+use Varnish::Test;
+use Varnish::Test::Report::HTML;
+
+sub usage() {
+ print STDERR < \&usage)
+ or usage();
+
+ my $controller = new Varnish::Test;
+ my @all_cases = $controller->cases();
+
+ if (@ARGV == 1 && $ARGV[0] eq 'list') {
+ print join(' ', @all_cases), "\n";
+ exit 0;
+ }
+
+ if (!@ARGV) {
+ @ARGV = @all_cases;
+ } else {
+ map { s/^(\d+)$/sprintf('Ticket%03d', $1)/e } @ARGV;
+ }
+
+ $controller->start_engine();
+ foreach my $casename (@ARGV) {
+ $controller->run_case($casename);
+ }
+ $controller->stop_engine();
+
+ my $report = new Varnish::Test::Report::HTML;
+ $report->run($controller->results());
+}
+
+=head1 SEE ALSO
+
+L
+
+=cut
Modified: trunk/varnish-tools/regress/lib/Varnish/Test.pm
===================================================================
--- trunk/varnish-tools/regress/lib/Varnish/Test.pm 2007-08-31 12:14:06 UTC (rev 1931)
+++ trunk/varnish-tools/regress/lib/Varnish/Test.pm 2007-09-03 10:12:29 UTC (rev 1932)
@@ -173,3 +173,12 @@
}
1;
+
+=head1 SEE ALSO
+
+L
+L
+L
+L
+
+=cut
Deleted: trunk/varnish-tools/regress/varnish-regress.pl
===================================================================
--- trunk/varnish-tools/regress/varnish-regress.pl 2007-08-31 12:14:06 UTC (rev 1931)
+++ trunk/varnish-tools/regress/varnish-regress.pl 2007-09-03 10:12:29 UTC (rev 1932)
@@ -1,86 +0,0 @@
-#!/usr/bin/perl -w
-#-
-# Copyright (c) 2006 Linpro AS
-# 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
-# in this position and unchanged.
-# 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 THE 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$
-#
-
-use strict;
-
-use FindBin;
-
-use lib "$FindBin::Bin/lib";
-
-use Getopt::Long;
-use Varnish::Test;
-use Varnish::Test::Report::HTML;
-
-sub usage() {
- print STDERR < \&usage)
- or usage();
-
- my $controller = new Varnish::Test;
- my @all_cases = $controller->cases();
-
- if (@ARGV == 1 && $ARGV[0] eq 'list') {
- print join(' ', @all_cases), "\n";
- exit 0;
- }
-
- if (!@ARGV) {
- @ARGV = @all_cases;
- } else {
- map { s/^(\d+)$/sprintf('Ticket%03d', $1)/e } @ARGV;
- }
-
- $controller->start_engine();
- foreach my $casename (@ARGV) {
- $controller->run_case($casename);
- }
- $controller->stop_engine();
-
- my $report = new Varnish::Test::Report::HTML;
- $report->run($controller->results());
-}
From cecilihf at projects.linpro.no Tue Sep 4 08:03:44 2007
From: cecilihf at projects.linpro.no (cecilihf at projects.linpro.no)
Date: Tue, 4 Sep 2007 10:03:44 +0200 (CEST)
Subject: r1933 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070904080344.CF0AD1EC3DD@projects.linpro.no>
Author: cecilihf
Date: 2007-09-04 10:03:43 +0200 (Tue, 04 Sep 2007)
New Revision: 1933
Modified:
trunk/varnish-cache/bin/varnishd/cache_backend_random.c
Log:
Copy-paste error.
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-03 10:12:29 UTC (rev 1932)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-04 08:03:43 UTC (rev 1933)
@@ -48,7 +48,7 @@
struct ber {
unsigned magic;
-#define BER_MAGIC 0x66f05894
+#define BER_MAGIC 0x645b3f4
struct brspec *blist;
#if 0
/* Store a hash of the backend info given in
@@ -61,7 +61,7 @@
struct brspec {
unsigned magic;
-#define BRSPEC_MAGIC 0x761d69c2
+#define BRSPEC_MAGIC 0x5aa072a7
struct brspec *next;
double limit;
char *hostname;
From cecilihf at projects.linpro.no Tue Sep 4 08:04:49 2007
From: cecilihf at projects.linpro.no (cecilihf at projects.linpro.no)
Date: Tue, 4 Sep 2007 10:04:49 +0200 (CEST)
Subject: r1934 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070904080449.1A1941EC307@projects.linpro.no>
Author: cecilihf
Date: 2007-09-04 10:04:48 +0200 (Tue, 04 Sep 2007)
New Revision: 1934
Modified:
trunk/varnish-cache/bin/varnishd/cache_backend_random.c
Log:
Missing 0
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-04 08:03:43 UTC (rev 1933)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-04 08:04:48 UTC (rev 1934)
@@ -48,7 +48,7 @@
struct ber {
unsigned magic;
-#define BER_MAGIC 0x645b3f4
+#define BER_MAGIC 0x645b03f4
struct brspec *blist;
#if 0
/* Store a hash of the backend info given in
From ssm at projects.linpro.no Tue Sep 4 10:55:25 2007
From: ssm at projects.linpro.no (ssm at projects.linpro.no)
Date: Tue, 4 Sep 2007 12:55:25 +0200 (CEST)
Subject: r1935 - trunk/varnish-cache/debian
Message-ID: <20070904105525.E1CB91EC3DD@projects.linpro.no>
Author: ssm
Date: 2007-09-04 12:55:25 +0200 (Tue, 04 Sep 2007)
New Revision: 1935
Modified:
trunk/varnish-cache/debian/changelog
trunk/varnish-cache/debian/rules
trunk/varnish-cache/debian/varnish.default
trunk/varnish-cache/debian/varnish.varnishlog.init
Log:
* Set statedir to /var/lib, to conform to debian packaging standards.
* Removed -n switch from varnish defaults file and varnishlog init script.
Use the default instance name instead. This makes sure varnish utilities work
without having to use the -n switch for the default instance.
Modified: trunk/varnish-cache/debian/changelog
===================================================================
--- trunk/varnish-cache/debian/changelog 2007-09-04 08:04:48 UTC (rev 1934)
+++ trunk/varnish-cache/debian/changelog 2007-09-04 10:55:25 UTC (rev 1935)
@@ -1,14 +1,20 @@
-varnish (1.1.1) unstable; urgency=low
+varnish (1.1.1-1) unstable; urgency=low
+ [Lars Bahner]
* New upstream release
* User and Group id added to default DAEMON_OPTS
* Added user and group creation to postinst
* Added missing man pages
- -- Lars Bahner Mon, 20 Aug 2007 11:29:33 +0200
+ [Stig Sandbeck Mathisen]
+ * Set statedir to /var/lib
+ * Removed -n switch from varnish defaults file and varnishlog init script.
+ Use the default instance name instead.
-varnish (1.1) unstable; urgency=low
+ -- Stig Sandbeck Mathisen Tue, 04 Sep 2007 12:27:09 +0200
+varnish (1.1-1) unstable; urgency=low
+
* New upstream release
* Split package into varnish, libvarnish and libvarnish-dev
Modified: trunk/varnish-cache/debian/rules
===================================================================
--- trunk/varnish-cache/debian/rules 2007-09-04 08:04:48 UTC (rev 1934)
+++ trunk/varnish-cache/debian/rules 2007-09-04 10:55:25 UTC (rev 1935)
@@ -32,7 +32,7 @@
# The boilerplate linker flags won't allow varnish to compile :(
# There are circular dependencies in the varnish libraries, but
# the core developers have OK'ed that we don't check.
- ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" --localstatedir=/var
+ ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" --localstatedir=/var/lib
build: build-stamp
Modified: trunk/varnish-cache/debian/varnish.default
===================================================================
--- trunk/varnish-cache/debian/varnish.default 2007-09-04 08:04:48 UTC (rev 1934)
+++ trunk/varnish-cache/debian/varnish.default 2007-09-04 10:55:25 UTC (rev 1935)
@@ -7,6 +7,10 @@
# Maximum number of open files (for ulimit -n)
NFILES=131072
+# Default varnish instance name is the local nodename. Can be overridden with
+# the -n switch, to have more instances on a single server.
+INSTANCE=$(uname -n)
+
# This file contains 4 alternatives, please use only one.
## Alternative 1, Minimal configuration, no VCL
@@ -18,8 +22,7 @@
-T localhost:6082 \
-b localhost:8080 \
-u varnish -g varnish \
- -n /var/lib/varnish \
- -s file,/var/lib/varnish/varnish_storage.bin,1G"
+ -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"
## Alternative 2, Configuration with VCL
@@ -32,7 +35,7 @@
# -T localhost:6082 \
# -f /etc/varnish/default.vcl \
# -n /var/lib/varnish \
-# -s file,/var/lib/varnish/varnish_storage.bin,1G"
+# -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"
## Alternative 3, Advanced configuration
@@ -65,7 +68,7 @@
# VARNISH_HOMEDIR=/var/lib/varnish
#
# # Cache file location
-# VARNISH_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin
+# VARNISH_STORAGE_FILE=/var/lib/varnish/$INSTANCE/varnish_storage.bin
#
# # Cache file size: in bytes, optionally using k / M / G / T suffix,
# # or in percentage of available disk space using the % suffix.
@@ -84,7 +87,6 @@
# -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
# -t ${VARNISH_TTL} \
# -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \
-# -n ${VARNISH_HOMEDIR} \
# -s ${VARNISH_STORAGE}"
#
Modified: trunk/varnish-cache/debian/varnish.varnishlog.init
===================================================================
--- trunk/varnish-cache/debian/varnish.varnishlog.init 2007-09-04 08:04:48 UTC (rev 1934)
+++ trunk/varnish-cache/debian/varnish.varnishlog.init 2007-09-04 10:55:25 UTC (rev 1935)
@@ -24,7 +24,7 @@
test -x $DAEMON || exit 0
-DAEMON_OPTS="-a -n /var/lib/varnish -w ${LOGFILE} -D -P $PIDFILE"
+DAEMON_OPTS="-a -w ${LOGFILE} -D -P $PIDFILE"
case "$1" in
start)
From knutroy at projects.linpro.no Tue Sep 4 14:00:14 2007
From: knutroy at projects.linpro.no (knutroy at projects.linpro.no)
Date: Tue, 4 Sep 2007 16:00:14 +0200 (CEST)
Subject: r1936 - trunk/varnish-doc/en/inside-varnish
Message-ID: <20070904140014.438161EC429@projects.linpro.no>
Author: knutroy
Date: 2007-09-04 16:00:13 +0200 (Tue, 04 Sep 2007)
New Revision: 1936
Modified:
trunk/varnish-doc/en/inside-varnish/article.xml
Log:
* Added information about test framework to "Inside Varnish".
Modified: trunk/varnish-doc/en/inside-varnish/article.xml
===================================================================
--- trunk/varnish-doc/en/inside-varnish/article.xml 2007-09-04 10:55:25 UTC (rev 1935)
+++ trunk/varnish-doc/en/inside-varnish/article.xml 2007-09-04 14:00:13 UTC (rev 1936)
@@ -335,7 +335,76 @@
The test framework
- Lorem ipsum dolor sit amet
+ The test framework for Varnish consists of a library of Perl
+ modules organized under Varnish::Test . The
+ framework works by starting up a Varnish daemon process and
+ communicating with it while acting as both client and server. The
+ framework also operates the management command-line interface of
+ the Varnish daemon. This enables the framework to monitor all
+ external aspects of the daemon's behavior.
+
+ The test framework contains a set of test-cases, each one
+ being a Perl module organized under
+ Varnish::Test::Case . The test-cases are run
+ sequentially, and each one typically focuses on a specific element
+ of Varnish's behavior or functionality. If the expectations of a
+ test-case is not fulfilled by the daemon being tested, the
+ test-case fails. Only when all test-cases succeeds, the Varnish
+ daemon may be considered healthy.
+
+ Test-case development is an ongoing process, and anyone is
+ welcome to contribute test-cases which reveals erroneous behavior
+ in at least one revision of Varnish.
+
+
+ I/O-handling
+
+ The test framework is based on a single
+ select(2) -driven loop, where all relevant
+ I/O channels are monitored. Activity on the I/O channels is
+ handled in an event-driven way, so the select loop also works as
+ an event loop. I/O-events are dispatched and optionally handled
+ by the running test-case which then decides what to do next. The
+ event loop may be paused, in order to drive the test processing
+ flow forward.
+
+
+
+ Object structure
+
+ The test framework employs an object-oriented approach and
+ uses (Perl) objects to represent instances of servers
+ (Varnish::Test::Server ), clients
+ (Varnish::Test::Client ), and HTTP messages
+ (HTTP::Message ).
+
+ Also, the Varnish daemon is represented by an object
+ (Varnish::Test::Varnish ) taking care of the
+ daemon process which is spawned by the test framework process
+ before the tests start.
+
+ Additionally, each test-case is represented by its own
+ object derived from the super-class
+ Varnish::Test::Case .
+
+ In the center of all the objects stands the engine object
+ (Varnish::Test::Engine ) which coordinates
+ the communication between the other objects by dispatching and
+ queuing events. The engine also sets up the
+ select(2) -loop, using an object instance of
+ the CPAN module IO::Multiplex .
+
+
+
+ Further information
+
+ Consult the POD-based in-source documentation for more
+ details if you like to get involved in developing test-cases or
+ improving the framework in general. In that case, prior
+ experience with Perl as well as a general understanding of
+ network programming using select(2) , is
+ beneficial.
+
From knutroy at projects.linpro.no Wed Sep 5 12:49:05 2007
From: knutroy at projects.linpro.no (knutroy at projects.linpro.no)
Date: Wed, 5 Sep 2007 14:49:05 +0200 (CEST)
Subject: r1937 - in trunk/varnish-tools/regress: . bin lib/Varnish
lib/Varnish/Test lib/Varnish/Test/Server
Message-ID: <20070905124905.B8A5A1EC3DD@projects.linpro.no>
Author: knutroy
Date: 2007-09-05 14:49:05 +0200 (Wed, 05 Sep 2007)
New Revision: 1937
Added:
trunk/varnish-tools/regress/lib/Varnish/Test/Server/
trunk/varnish-tools/regress/lib/Varnish/Test/Server/Connection.pm
Removed:
trunk/varnish-tools/regress/TODO
Modified:
trunk/varnish-tools/regress/
trunk/varnish-tools/regress/bin/varnish-regress.pl
trunk/varnish-tools/regress/lib/Varnish/Test.pm
trunk/varnish-tools/regress/lib/Varnish/Test/Case.pm
trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm
trunk/varnish-tools/regress/lib/Varnish/Test/Engine.pm
trunk/varnish-tools/regress/lib/Varnish/Test/Report.pm
trunk/varnish-tools/regress/lib/Varnish/Test/Server.pm
trunk/varnish-tools/regress/lib/Varnish/Test/Varnish.pm
Log:
* Added POD.
* Moved Varnish::Test::Server::Connection to its own module file.
* Removed TODO which was not too exciting anyway.
Property changes on: trunk/varnish-tools/regress
___________________________________________________________________
Name: svn:ignore
+ Makefile
Deleted: trunk/varnish-tools/regress/TODO
===================================================================
--- trunk/varnish-tools/regress/TODO 2007-09-04 14:00:13 UTC (rev 1936)
+++ trunk/varnish-tools/regress/TODO 2007-09-05 12:49:05 UTC (rev 1937)
@@ -1,2 +0,0 @@
-* Completely POD-ify Perl-code.
-* Detect and act upon unexpected death of Varnish grandchild process.
Modified: trunk/varnish-tools/regress/bin/varnish-regress.pl
===================================================================
--- trunk/varnish-tools/regress/bin/varnish-regress.pl 2007-09-04 14:00:13 UTC (rev 1936)
+++ trunk/varnish-tools/regress/bin/varnish-regress.pl 2007-09-05 12:49:05 UTC (rev 1937)
@@ -32,6 +32,27 @@
varnish-regress.pl - run Varnish regression tests
+=head1 DESCRIPTION
+
+This program is a thin wrapper around the L regression
+test framework library. Using this library, regression tests are
+performed on Varnish.
+
+The Varnish daemon (L) must be available in one of the
+directories given by the "PATH" environment variable.
+
+By default, this program will run all test-cases available in the
+regression test framework library, or the test-cases selected by name
+as arguments on the command line.
+
+=head1 OUTPUT
+
+STDERR is used to continually report progress during testing.
+
+STDOUT is used to output a HTML-formatted report at the end of the
+run, provided that execution does not abort prematurely for any
+reason.
+
=cut
use strict;
@@ -96,5 +117,6 @@
=head1 SEE ALSO
L
+L
=cut
Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case.pm
===================================================================
--- trunk/varnish-tools/regress/lib/Varnish/Test/Case.pm 2007-09-04 14:00:13 UTC (rev 1936)
+++ trunk/varnish-tools/regress/lib/Varnish/Test/Case.pm 2007-09-05 12:49:05 UTC (rev 1937)
@@ -34,14 +34,16 @@
=head1 DESCRIPTION
-Varnish::Test::Case is meant to be the superclass of specific
-test-case clases. It provides functionality to run a number of tests
-defined in methods whose names start with "test", as well as keeping
-track of the number of successful or failed tests.
+Varnish::Test::Case is the superclass of test-case clases. It provides
+functionality to run a number of tests defined in methods whose names
+start with "test", as well as keeping track of the number of
+successful or failed tests.
It also provides default event handlers for "ev_client_response" and
"ev_client_timeout", which are standard for most test-cases.
+=head1 METHODS
+
=cut
package Varnish::Test::Case;
@@ -54,6 +56,12 @@
use POSIX qw(strftime);
use Time::HiRes qw(gettimeofday tv_interval);
+=head2 new
+
+Create a new Case object.
+
+=cut
+
sub new($$) {
my ($this, $engine) = @_;
my $class = ref($this) || $this;
@@ -64,12 +72,25 @@
'failed' => 0 }, $class);
}
+=head2 log
+
+Logging facility.
+
+=cut
+
sub log($$) {
my ($self, $str) = @_;
$self->{'engine'}->log($self, 'CAS: ', $str);
}
+=head2 init
+
+Test-case initialization which loads specified VCL into Varnish and
+starts the Varnish daemon's child.
+
+=cut
+
sub init($) {
my ($self) = @_;
my ($code, $text);
@@ -105,6 +126,13 @@
}
}
+=head2 fini
+
+Does the reverse of "init" by stopping the Varnish child and reverting
+to a default VCL definition.
+
+=cut
+
sub fini($) {
my ($self) = @_;
@@ -127,6 +155,12 @@
}
}
+=head2 run
+
+Run test-case proper when everything is set up right.
+
+=cut
+
sub run($;@) {
my ($self, @args) = @_;
@@ -162,18 +196,37 @@
$self->{'stop'} = [gettimeofday()];
}
+=head2 run_loop
+
+Proxy for Varnish::Test::Engine::run_loop.
+
+=cut
+
sub run_loop($@) {
my ($self, @wait_for) = @_;
return $self->{'engine'}->run_loop(@wait_for);
}
+=head2 new_client
+
+Creates a new Client object.
+
+=cut
+
sub new_client($) {
my ($self) = @_;
return Varnish::Test::Client->new($self->{'engine'});
}
+=head2 results
+
+Report test-case results as a hashref suitable for Template
+processing.
+
+=cut
+
sub results($) {
my ($self) = @_;
@@ -196,12 +249,22 @@
# Default event handlers
#
+=head1 DEFAULT EVENT HANDLER METHODS
+
+=head2 ev_client_response
+
+=cut
+
sub ev_client_response($$$) {
my ($self, $client, $response) = @_;
return $response;
}
+=head2 ev_client_timeout
+
+=cut
+
sub ev_client_timeout($$) {
my ($self, $client) = @_;
@@ -209,6 +272,10 @@
return $client;
}
+=head2 ev_server_request
+
+=cut
+
sub ev_server_request($$$$) {
my ($self, $server, $connection, $request) = @_;
@@ -237,6 +304,10 @@
$connection->send_response($response);
}
+=head2 ev_server_timeout
+
+=cut
+
sub ev_server_timeout($$) {
my ($self, $srvconn) = @_;
@@ -248,6 +319,16 @@
# Client utilities
#
+=head1 CLIENT UTILITY METHODS
+
+=head2 request
+
+Prepare and send an HTTP request using Client object given as
+argument. Also, HTTP method, URI, HTTP headers and content are given
+as argument. HTTP headers and content is optional.
+
+=cut
+
sub request($$$$;$$) {
my ($self, $client, $method, $uri, $header, $content) = @_;
@@ -279,18 +360,40 @@
return $self->{'cached_response'} = $resp;
}
+=head2 head
+
+Send "HEAD" request using "request" method above. Client object, URI,
+and HTTP headers (optional) are given as arguments.
+
+=cut
+
sub head($$$;$) {
my ($self, $client, $uri, $header) = @_;
return $self->request($client, 'HEAD', $uri, $header);
}
+=head2 get
+
+Send "GET" request using "request" method above. Client object, URI,
+and HTTP headers (optional) are given as arguments.
+
+=cut
+
sub get($$$;$) {
my ($self, $client, $uri, $header) = @_;
return $self->request($client, 'GET', $uri, $header);
}
+=head2 post
+
+Send "POST" request using "request" method above. Client object, URI,
+and HTTP headers (optional) and body (optional) are given as
+arguments.
+
+=cut
+
sub post($$$;$$) {
my ($self, $client, $uri, $header, $body) = @_;
@@ -299,6 +402,18 @@
return $self->request($client, 'POST', $uri, $header, $body);
}
+=head1 ASSERT METHODS
+
+The following assert methods take an optional response object is their
+last argument. When this argument is not used, response object is
+looked up in $self->{'cached_response'}.
+
+=head2 assert_code
+
+Assert a certain HTTP status code.
+
+=cut
+
sub assert_code($$;$) {
my ($self, $code, $resp) = @_;
@@ -308,6 +423,12 @@
unless $resp->code == $code;
}
+=head2 assert_ok
+
+Assert status "200 OK" using "assert_code" method above.
+
+=cut
+
sub assert_ok($;$) {
my ($self, $resp) = @_;
@@ -317,6 +438,12 @@
$self->assert_code(200, $resp);
}
+=head2 assert_xid
+
+Assert a certain XID in "X-Varnish" header.
+
+=cut
+
sub assert_xid($;$) {
my ($self, $resp) = @_;
@@ -329,6 +456,12 @@
unless ($resp->header('X-Varnish') =~ m/^\d+(?: \d+)?$/);
}
+=head2 assert_no_xid
+
+Assert absence of "X-Varnish" header.
+
+=cut
+
sub assert_no_xid($;$) {
my ($self, $resp) = @_;
@@ -339,6 +472,12 @@
if (defined($resp->header('X-Varnish')));
}
+=head2 assert_cached
+
+Assert that "X-Varnish" header indicates that the response was cached.
+
+=cut
+
sub assert_cached($;$) {
my ($self, $resp) = @_;
@@ -350,6 +489,13 @@
unless $resp->header('X-Varnish') =~ /^\d+ \d+$/;
}
+=head2 assert_uncached
+
+Assert that "X-Varnish" header indicates that the response was NOT
+cached.
+
+=cut
+
sub assert_uncached($;$) {
my ($self, $resp) = @_;
@@ -361,6 +507,13 @@
if $resp->header('X-Varnish') =~ /^\d+ \d+$/;
}
+=head2 assert_header
+
+Assert that a certain header (named by an argument) is present, and
+optionally matches a given regular expression.
+
+=cut
+
sub assert_header($$;$$) {
my ($self, $header, $re, $resp) = @_;
@@ -375,6 +528,13 @@
}
}
+=head2 assert_body
+
+Assert presence of a HTTP body, optionally matching given regular
+expression.
+
+=cut
+
sub assert_body($;$$) {
my ($self, $re, $resp) = @_;
@@ -389,6 +549,12 @@
}
}
+=head2 assert_no_body
+
+Assert absence of HTTP body.
+
+=cut
+
sub assert_no_body($;$) {
my ($self, $resp) = @_;
@@ -402,6 +568,14 @@
# Miscellaneous
#
+=head1 MISCELLANEOUS METHODS
+
+=head2 usleep
+
+Sleep for a given number of microseconds.
+
+=cut
+
sub usleep($$) {
my ($self, $usec) = @_;
@@ -409,3 +583,11 @@
}
1;
+
+=head1 SEE ALSO
+
+L
+L
+L
+
+=cut
Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm
===================================================================
--- trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm 2007-09-04 14:00:13 UTC (rev 1936)
+++ trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm 2007-09-05 12:49:05 UTC (rev 1937)
@@ -44,9 +44,17 @@
use strict;
use IO::Socket::INET;
+use HTTP::Response;
our $id_seq = 1;
+=head2 new
+
+Called by test-cases to create a new Client object to be used to send
+HTTP-requests.
+
+=cut
+
sub new($$) {
my ($this, $engine, $attrs) = @_;
my $class = ref($this) || $this;
@@ -62,18 +70,36 @@
return $self;
}
+=head2 log
+
+Logging facility.
+
+=cut
+
sub log($$;$) {
my ($self, $str, $extra_prefix) = @_;
$self->{'engine'}->log($self, sprintf('CLI[%d]: ', $self->{'id'}) . ($extra_prefix || ''), $str);
}
+=head2 logf
+
+Logging facility using a formatting string as first argument.
+
+=cut
+
sub logf($$;@) {
my ($self, $fmt, @args) = @_;
$self->{'engine'}->log($self, sprintf('CLI[%d]: ', $self->{'id'}), sprintf($fmt, @args));
}
+=head2 send_request
+
+Called by test-cases to send HTTP requests out on a connection.
+
+=cut
+
sub send_request($$;$) {
my ($self, $request, $timeout) = @_;
@@ -93,6 +119,13 @@
$self->logf("%s %s %s", $request->method(), $request->uri(), $request->protocol());
}
+=head2 got_response
+
+Called by mux_input and mux_eof to dispatch event related to received
+HTTP response.
+
+=cut
+
sub got_response($$) {
my ($self, $response) = @_;
@@ -101,6 +134,13 @@
$self->{'engine'}->ev_client_response($self, $response);
}
+=head2 shutdown
+
+Called by test-cases to shutdown client including termination of HTTP
+connection.
+
+=cut
+
sub shutdown($) {
my ($self) = @_;
@@ -119,6 +159,17 @@
}
}
+=head1 IO::MULTIPLEX CALLBACKS
+
+=head2 mux_input
+
+Called by L when new input is received on an associated
+file-handle. Complete HTTP messages are extracted from the input
+buffer, while any incomplete message is left in the buffer, awaiting
+more input (mux_input) or EOF (mux_eof).
+
+=cut
+
sub mux_input($$$$) {
my ($self, $mux, $fh, $data) = @_;
@@ -197,6 +248,13 @@
# nothing at all or a partial HTTP message.
}
+=head2 mux_eof
+
+Called by L when connection is being shutdown by
+foreign host.
+
+=cut
+
sub mux_eof($$$$) {
my ($self, $mux, $fh, $data) = @_;
@@ -210,6 +268,13 @@
}
}
+=head2 mux_timeout
+
+Called by L when a specified timeout has been reached
+on an associated file-handle.
+
+=cut
+
sub mux_timeout($$$) {
my ($self, $mux, $fh) = @_;
@@ -217,6 +282,13 @@
$self->{'engine'}->ev_client_timeout($self);
}
+=head2 mux_close
+
+Called by L when an associated file-handle has been
+closed.
+
+=cut
+
sub mux_close($$) {
my ($self, $mux, $fh) = @_;
@@ -224,3 +296,10 @@
}
1;
+
+=head1 SEE ALSO
+
+L
+L
+
+=cut
Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Engine.pm
===================================================================
--- trunk/varnish-tools/regress/lib/Varnish/Test/Engine.pm 2007-09-04 14:00:13 UTC (rev 1936)
+++ trunk/varnish-tools/regress/lib/Varnish/Test/Engine.pm 2007-09-05 12:49:05 UTC (rev 1937)
@@ -34,15 +34,15 @@
=head1 DESCRIPTION
-Varnish::Test::Engine is primarily a wrapper around a
-IO::Multiplex-based select-loop which monitors activity on
-client-side, server-side and Varnish's I/O-channels. On startup, it
-automatically creates an associated Server object and a Varnish
-objects whoses sockets/filehandles are registered in the
-IO::Multiplex-object.
+An L object is primarily a wrapper
+around a L-based L object which monitors
+activity on relevant sockets and file handles.
-Additionally, event dispatching is performed by the AUTOLOAD method.
+Additionally, an Engine object performs event dispatching and queuing,
+which are handled by an AUTOLOAD method.
+=head1 METHODS
+
=cut
package Varnish::Test::Engine;
@@ -53,6 +53,16 @@
use Varnish::Test::Varnish;
use IO::Multiplex;
+=head2 new
+
+Used by main program to create a new Varnish::Test::Engine object
+which starts up a L and
+L object, so test-cases are ready to be run.
+Also an object is started to handle the central
+select(2) mechanism.
+
+=cut
+
sub new($$;%) {
my ($this, $controller, %config) = @_;
my $class = ref($this) || $this;
@@ -83,6 +93,12 @@
return $self;
}
+=head2 log
+
+Logging facility.
+
+=cut
+
sub log($$$) {
my ($self, $object, $prefix, $str) = @_;
@@ -92,6 +108,14 @@
print STDERR $str;
}
+=head2 run_loop
+
+Enter event loop based on IO::Multiplex::loop. Also, handles
+dispatching of "wait-for" or "die" events which are returned to the
+caller.
+
+=cut
+
sub run_loop($@) {
my ($self, @wait_for) = @_;
@@ -145,6 +169,13 @@
return undef;
}
+=head2 shutdown
+
+Shutdown Engine by shutting down Server, Varnish, and IO::Multiplex
+objects.
+
+=cut
+
sub shutdown($) {
my ($self) = @_;
@@ -158,7 +189,17 @@
}
}
-sub AUTOLOAD ($;@) {
+=head2 AUTOLOAD
+
+Event dispatch mechanism. When an I/O event occurs, it goes through
+this method because $engine->ev_* resolves to this one. It will the
+look for a method of the same name in the running test-case object.
+Queuing and end-loop signaling is done when a "wait-for" or "die"
+event occurs.
+
+=cut
+
+sub AUTOLOAD($;@) {
my ($self, @args) = @_;
(my $event = our $AUTOLOAD) =~ s/.*://;
@@ -209,3 +250,11 @@
}
1;
+
+=head1 SEE ALSO
+
+L
+L
+L
+
+=cut
Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Report.pm
===================================================================
--- trunk/varnish-tools/regress/lib/Varnish/Test/Report.pm 2007-09-04 14:00:13 UTC (rev 1936)
+++ trunk/varnish-tools/regress/lib/Varnish/Test/Report.pm 2007-09-05 12:49:05 UTC (rev 1937)
@@ -28,12 +28,32 @@
# $Id$
#
+=head1 NAME
+
+Varnish::Test::Report
+
+=head1 DESCRIPTION
+
+Produce test result reports in different formats. Currently, HTML
+format is supported via a subclass found in
+Varnish::Test::Report::HTML.
+
+=head1 METHODS
+
+=cut
+
package Varnish::Test::Report;
use strict;
use Template;
+=head2 new
+
+Create a new Report object.
+
+=cut
+
sub new($) {
my ($this) = @_;
my $class = ref($this) || $this;
@@ -51,6 +71,12 @@
return $self;
}
+=head2 new
+
+Generate report.
+
+=cut
+
sub run($@) {
my ($self, @cases) = @_;
@@ -75,3 +101,9 @@
}
1;
+
+=head1 SEE ALSO
+
+L
+
+=cut
Added: trunk/varnish-tools/regress/lib/Varnish/Test/Server/Connection.pm
===================================================================
--- trunk/varnish-tools/regress/lib/Varnish/Test/Server/Connection.pm (rev 0)
+++ trunk/varnish-tools/regress/lib/Varnish/Test/Server/Connection.pm 2007-09-05 12:49:05 UTC (rev 1937)
@@ -0,0 +1,226 @@
+#!/usr/bin/perl -w
+#-
+# Copyright (c) 2006-2007 Linpro AS
+# 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
+# in this position and unchanged.
+# 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 THE 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$
+#
+
+=head1 NAME
+
+Varnish::Test::Server::Connection
+
+=head1 DESCRIPTION
+
+An Varnish::Test::Server::Connection object is used to handle an
+individual HTTP connection which stems from the listening socket
+handled by L.
+
+=cut
+
+package Varnish::Test::Server::Connection;
+
+use strict;
+use HTTP::Request;
+use HTTP::Status;
+
+=head2 new
+
+Called by a Server object when a new connection (given by the
+file-handle argument) is established. This object is set as the
+IO::Multiplex call-back object for this connection.
+
+=cut
+
+sub new($$) {
+ my ($this, $server, $fh) = @_;
+ my $class = ref($this) || $this;
+
+ my $self = bless({ 'server' => $server,
+ 'engine' => $server->{'engine'},
+ 'fh' => $fh,
+ 'mux' => $server->{'mux'},
+ 'data' => '' }, $class);
+ $self->{'mux'}->set_callback_object($self, $fh);
+ return $self;
+}
+
+=head2 send_response
+
+Called by test-cases to send a given HTTP::Response object out on the
+associated HTTP connection.
+
+=cut
+
+sub send_response($$) {
+ my ($self, $response) = @_;
+
+ $response->message(status_message($response->code()))
+ unless $response->message();
+ $self->{'mux'}->write($self->{'fh'}, $response->as_string("\r\n"));
+ $self->{'server'}->{'responses'} += 1;
+ $self->{'server'}->logf("%s %s", $response->code(), $response->message());
+}
+
+=head2 shutdown
+
+Called by test-cases to close HTTP connection.
+
+=cut
+
+sub shutdown($) {
+ my ($self) = @_;
+
+ my $inbuffer = $self->{'mux'}->inbuffer($self->{'fh'});
+
+ if (defined($inbuffer) and $inbuffer ne '') {
+ use Data::Dumper;
+
+ $self->{'server'}->log('Junk or incomplete request. Discarding: ' . Dumper(\$inbuffer));
+ $self->{'mux'}->inbuffer($self->{'fh'}, '');
+ }
+
+ $self->{'mux'}->close($self->{'fh'});
+}
+
+=head1 IO::MULTIPLEX CALLBACKS
+
+=head2 mux_input
+
+Called by L when new input is received on an associated
+file-handle. Complete HTTP messages are extracted from the input
+buffer, while any incomplete message is left in the buffer, awaiting
+more input (mux_input) or EOF (mux_eof).
+
+=cut
+
+sub mux_input($$$$) {
+ my ($self, $mux, $fh, $data) = @_;
+
+ $mux->set_timeout($fh, undef);
+
+ # Iterate through the input buffer ($$data) and identify HTTP
+ # messages, one per iteration. Break out of the loop when there
+ # are no complete HTTP messages left in the buffer, and let
+ # whatever data remains stay in the buffer, as we will get a new
+ # chance to parse it next time we get more data ("mux_input").
+ while ($$data =~ /\n\r?\n/) {
+ # If we find a double (CR)LF in the input data, we have at
+ # least a complete header section of a message, so look for
+ # content-length and decide what to do.
+
+ my $request = HTTP::Request->parse($$data);
+ my $content_ref = $request->content_ref;
+ my $content_length = $request->content_length;
+
+ if (defined($content_length)) {
+ my $data_length = length($$content_ref);
+ if ($data_length == $content_length) {
+ # We found exactly content-length amount of data, so
+ # empty input buffer and send request to event
+ # handling.
+ $$data = '';
+ $self->{'server'}->got_request($self, $request);
+ }
+ elsif ($data_length < $content_length) {
+ # We only received the first part of an HTTP message,
+ # so break out of loop and wait for more.
+ $mux->set_timeout($fh, 2);
+ last;
+ }
+ else {
+ # We have more than content-length data, which means
+ # more than just one HTTP message. The extra data
+ # (beyond content-length) is now at the end of
+ # $$content_ref, so move it back to the input buffer
+ # so we can parse it on the next iteration. Note that
+ # this "substr" also removes this data from
+ # $$content_ref (the message body of $request itself).
+ $$data = substr($$content_ref, $content_length,
+ $data_length - $content_length, '');
+ # Send request to event handling.
+ $self->{'server'}->got_request($self, $request);
+ }
+ }
+ else {
+ # HTTP requests without a content-length has no body by
+ # definition, so whatever was parsed as content must be
+ # the start of another request. Hence, move this back to
+ # input buffer and empty the body of this $request. Then,
+ # send $request to event handling.
+
+ $$data = $$content_ref;
+ $$content_ref = '';
+ $self->{'server'}->got_request($self, $request);
+ }
+ }
+}
+
+=head2 mux_timeout
+
+Called by L when a specified timeout has been reached
+on an associated file-handle.
+
+=cut
+
+sub mux_timeout($$$) {
+ my ($self, $mux, $fh) = @_;
+
+ $self->{'mux'}->set_timeout($fh, undef);
+ $self->{'engine'}->ev_server_timeout($self);
+}
+
+=head2 mux_eof
+
+Called by L when connection is being shutdown by
+foreign host.
+
+=cut
+
+sub mux_eof($$$$) {
+ my ($self, $mux, $fh, $data) = @_;
+
+ # On server side, HTTP does not use EOF from client to signal end
+ # of request, so if there is anything left in input buffer, it
+ # must be incomplete because "mux_input" left it there.
+
+ if ($$data ne '') {
+ use Data::Dumper;
+
+ $self->{'server'}->log('Junk or incomplete request. Discarding: ' . Dumper($data));
+ $$data = '';
+ }
+}
+
+1;
+
+=head1 SEE ALSO
+
+L
+L
+L
+L
+
+=cut
Property changes on: trunk/varnish-tools/regress/lib/Varnish/Test/Server/Connection.pm
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Server.pm
===================================================================
--- trunk/varnish-tools/regress/lib/Varnish/Test/Server.pm 2007-09-04 14:00:13 UTC (rev 1936)
+++ trunk/varnish-tools/regress/lib/Varnish/Test/Server.pm 2007-09-05 12:49:05 UTC (rev 1937)
@@ -38,7 +38,7 @@
TCP socket, receiving HTTP requests and sending responses.
Every established connection is handled by an associated object of
-type Varnish::Test::Server::Connection.
+type L.
=cut
@@ -46,8 +46,17 @@
use strict;
+use Varnish::Test::Server::Connection;
use IO::Socket::INET;
+=head2 new
+
+Called by a Varnish::Test::Engine object to create a new Server
+object. It sets up its listening socket and registers it in Engine's
+IO::Multiplex object (mux).
+
+=cut
+
sub new($$) {
my ($this, $engine, $attrs) = @_;
my $class = ref($this) || $this;
@@ -73,18 +82,37 @@
return $self;
}
+=head2 log
+
+Logging facility.
+
+=cut
+
sub log($$;$) {
my ($self, $str, $extra_prefix) = @_;
$self->{'engine'}->log($self, 'SRV: ' . ($extra_prefix || ''), $str);
}
+=head2 logf
+
+Logging facility using a formatting string as first argument.
+
+=cut
+
sub logf($$;@) {
my ($self, $fmt, @args) = @_;
$self->{'engine'}->log($self, 'SRV: ', sprintf($fmt, @args));
}
+=head2 shutdown
+
+Called by the main program to terminate the server object and its
+listening socket.
+
+=cut
+
sub shutdown($) {
my ($self) = @_;
@@ -92,20 +120,14 @@
delete $self->{'socket'};
}
-sub mux_connection($$$) {
- my ($self, $mux, $fh) = @_;
+=head2 got_request
- $self->log('CONNECT');
- my $connection = Varnish::Test::Server::Connection->new($self, $fh);
-}
+Called by L object when an HTTP
+message has been received. An B event is
+dispatched.
-sub mux_close($$) {
- my ($self, $mux, $fh) = @_;
+=cut
- $self->log('CLOSE');
- delete $self->{'socket'} if $fh == $self->{'socket'};
-}
-
sub got_request($$) {
my ($self, $connection, $request) = @_;
@@ -114,131 +136,42 @@
$self->{'engine'}->ev_server_request($self, $connection, $request);
}
-package Varnish::Test::Server::Connection;
+=head1 IO::MULTIPLEX CALLBACKS
-use strict;
-use HTTP::Status;
+=head2 mux_connection
-sub new($$) {
- my ($this, $server, $fh) = @_;
- my $class = ref($this) || $this;
+Called by L when the listening socket has received a
+new connection. The file-handle of the new connection is provided as
+an argument and is given to a newly created
+L object which will operate the new
+connection from now on.
- my $self = bless({ 'server' => $server,
- 'engine' => $server->{'engine'},
- 'fh' => $fh,
- 'mux' => $server->{'mux'},
- 'data' => '' }, $class);
- $self->{'mux'}->set_callback_object($self, $fh);
- return $self;
-}
+=cut
-sub send_response($$) {
- my ($self, $response) = @_;
+sub mux_connection($$$) {
+ my ($self, $mux, $fh) = @_;
- $response->message(status_message($response->code()))
- unless $response->message();
- $self->{'mux'}->write($self->{'fh'}, $response->as_string("\r\n"));
- $self->{'server'}->{'responses'} += 1;
- $self->{'server'}->logf("%s %s", $response->code(), $response->message());
+ $self->log('CONNECT');
+ my $connection = Varnish::Test::Server::Connection->new($self, $fh);
}
-sub shutdown($) {
- my ($self) = @_;
+=head2 mux_close
- my $inbuffer = $self->{'mux'}->inbuffer($self->{'fh'});
+Called by L when the listening socket has been closed.
- if (defined($inbuffer) and $inbuffer ne '') {
- use Data::Dumper;
+=cut
- $self->{'server'}->log('Junk or incomplete request. Discarding: ' . Dumper(\$inbuffer));
- $self->{'mux'}->inbuffer($self->{'fh'}, '');
- }
-
- $self->{'mux'}->close($self->{'fh'});
-}
-
-sub mux_input($$$$) {
- my ($self, $mux, $fh, $data) = @_;
-
- $mux->set_timeout($fh, undef);
-
- # Iterate through the input buffer ($$data) and identify HTTP
- # messages, one per iteration. Break out of the loop when there
- # are no complete HTTP messages left in the buffer, and let
- # whatever data remains stay in the buffer, as we will get a new
- # chance to parse it next time we get more data ("mux_input").
- while ($$data =~ /\n\r?\n/) {
- # If we find a double (CR)LF in the input data, we have at
- # least a complete header section of a message, so look for
- # content-length and decide what to do.
-
- my $request = HTTP::Request->parse($$data);
- my $content_ref = $request->content_ref;
- my $content_length = $request->content_length;
-
- if (defined($content_length)) {
- my $data_length = length($$content_ref);
- if ($data_length == $content_length) {
- # We found exactly content-length amount of data, so
- # empty input buffer and send request to event
- # handling.
- $$data = '';
- $self->{'server'}->got_request($self, $request);
- }
- elsif ($data_length < $content_length) {
- # We only received the first part of an HTTP message,
- # so break out of loop and wait for more.
- $mux->set_timeout($fh, 2);
- last;
- }
- else {
- # We have more than content-length data, which means
- # more than just one HTTP message. The extra data
- # (beyond content-length) is now at the end of
- # $$content_ref, so move it back to the input buffer
- # so we can parse it on the next iteration. Note that
- # this "substr" also removes this data from
- # $$content_ref (the message body of $request itself).
- $$data = substr($$content_ref, $content_length,
- $data_length - $content_length, '');
- # Send request to event handling.
- $self->{'server'}->got_request($self, $request);
- }
- }
- else {
- # HTTP requests without a content-length has no body by
- # definition, so whatever was parsed as content must be
- # the start of another request. Hence, move this back to
- # input buffer and empty the body of this $request. Then,
- # send $request to event handling.
-
- $$data = $$content_ref;
- $$content_ref = '';
- $self->{'server'}->got_request($self, $request);
- }
- }
-}
-
-sub mux_timeout($$$) {
+sub mux_close($$) {
my ($self, $mux, $fh) = @_;
- $self->{'mux'}->set_timeout($fh, undef);
- $self->{'engine'}->ev_server_timeout($self);
+ $self->log('CLOSE');
+ delete $self->{'socket'} if $fh == $self->{'socket'};
}
-sub mux_eof($$$$) {
- my ($self, $mux, $fh, $data) = @_;
+1;
- # On server side, HTTP does not use EOF from client to signal end
- # of request, so if there is anything left in input buffer, it
- # must be incomplete because "mux_input" left it there.
+=head1 SEE ALSO
- if ($$data ne '') {
- use Data::Dumper;
+L
- $self->{'server'}->log('Junk or incomplete request. Discarding: ' . Dumper($data));
- $$data = '';
- }
-}
-
-1;
+=cut
Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Varnish.pm
===================================================================
--- trunk/varnish-tools/regress/lib/Varnish/Test/Varnish.pm 2007-09-04 14:00:13 UTC (rev 1936)
+++ trunk/varnish-tools/regress/lib/Varnish/Test/Varnish.pm 2007-09-05 12:49:05 UTC (rev 1937)
@@ -30,17 +30,19 @@
=head1 NAME
-Varnish::Test::Varnish - Varnish child-process controller
+Varnish::Test::Varnish - Varnish daemon process controller
=head1 DESCRIPTION
-A Varnish::Test::Varnish object is used to fork off a Varnish child
-process and control traffic going into and coming out of the Varnish
-(management process) command-line interface (CLI).
+A Varnish::Test::Varnish object is used to fork off a Varnish daemon
+(varnishd) process and control traffic going into and coming out of
+the Varnish (management process) command-line interface (CLI).
Various events are generated when certain strings are identified in
the output from the CLI.
+=head1 METHODS
+
=cut
package Varnish::Test::Varnish;
@@ -50,6 +52,13 @@
use IO::Socket::INET;
use Socket;
+=head2 new
+
+Called by an Varnish::Test::Engine object to create a
+Varnish::Test::Varnish object which spawns a "varnishd" sub-process.
+
+=cut
+
sub new($$;$) {
my ($this, $engine, $attrs) = @_;
my $class = ref($this) || $this;
@@ -145,12 +154,25 @@
return $self;
}
+=head2 log
+
+Logging facility.
+
+=cut
+
sub log($$) {
my ($self, $str) = @_;
$self->{'engine'}->log($self, 'VAR: ', $str);
}
+=head2 backend_block
+
+Return a string containing a VCL "backend" block containing the
+information about the running backend (Varnish::Test::Server object).
+
+=cut
+
sub backend_block($$) {
my ($self, $name) = @_;
@@ -158,6 +180,13 @@
$name, split(':', $self->{'engine'}->{'config'}->{'server_address'}));
}
+=head2 send_command
+
+Called by main program or test-cases to send commands to the Varnish
+deamon.
+
+=cut
+
sub send_command($@) {
my ($self, @args) = @_;
die "not ready\n"
@@ -186,18 +215,38 @@
return ($code, $text);
}
+=head2 send_vcl
+
+Send "vcl.inline" command to Varnish daemon.
+
+=cut
+
sub send_vcl($$$) {
my ($self, $config, $vcl) = @_;
return $self->send_command('vcl.inline', $config, $vcl);
}
+=head2 use_vcl
+
+Send "vcl.use" command to the Varnish daemon.
+
+=cut
+
sub use_vcl($$) {
my ($self, $config) = @_;
return $self->send_command('vcl.use', $config);
}
+=head2 start_child
+
+Issue command to start Varnish daemon's child process, so that HTTP
+traffic may begin. An B will be dispatched from
+"mux_input" once the child actually has started.
+
+=cut
+
sub start_child($) {
my ($self) = @_;
die "not ready\n"
@@ -223,6 +272,12 @@
return (500, 'unable to start child');
}
+=head2 stop_child
+
+Issue command to stop Varnish daemon's child process.
+
+=cut
+
sub stop_child($) {
my ($self) = @_;
die "not ready\n"
@@ -246,12 +301,24 @@
return (500, 'unable to stop child');
}
+=head2 set_param
+
+Send "param.set" command to Varnish daemon.
+
+=cut
+
sub set_param($$$) {
my ($self, $param, $value) = @_;
return $self->send_command('param.set', $param, $value);
}
+=head2 shutdown
+
+Shutdown Varnish daemon.
+
+=cut
+
sub shutdown($) {
my ($self) = @_;
@@ -267,6 +334,14 @@
if $self->{'pid'};
}
+=head2 mux_input
+
+Called by L when new input is received on the Varnish
+daemon's output channels. Dispatches relevant events based on the
+output received.
+
+=cut
+
sub mux_input($$$$) {
my ($self, $mux, $fh, $data) = @_;
@@ -318,6 +393,13 @@
}
}
+=head2 mux_timeout
+
+Called by L when a specified timeout has been reached
+on an associated file-handle. Dispatch an B event.
+
+=cut
+
sub mux_timeout($$$) {
my ($self, $mux, $fh) = @_;
Modified: trunk/varnish-tools/regress/lib/Varnish/Test.pm
===================================================================
--- trunk/varnish-tools/regress/lib/Varnish/Test.pm 2007-09-04 14:00:13 UTC (rev 1936)
+++ trunk/varnish-tools/regress/lib/Varnish/Test.pm 2007-09-05 12:49:05 UTC (rev 1937)
@@ -34,7 +34,7 @@
=head1 DESCRIPTION
-The varnish regression test framework works by starting up a Varnish
+The Varnish regression test framework works by starting up a Varnish
process and then communicating with this process as both client and
server.
@@ -63,7 +63,7 @@
A single select(2)-driven loop is used to handle all activity on both
server and client side, as well on Varnish's I/O-channels. This is
-done using IO::Multiplex.
+done using L.
As a result of using a select-loop (as opposed to a multi-threaded or
multi-process approach), the framework has an event-driven design in
@@ -98,6 +98,8 @@
supposed to pause the select-loop and return control back to the main
program.
+=head1 METHODS
+
=cut
package Varnish::Test;
@@ -105,6 +107,12 @@
use Varnish::Test::Case;
use Varnish::Test::Engine;
+=head2 new
+
+Create a new Test object.
+
+=cut
+
sub new($) {
my ($this) = @_;
my $class = ref($this) || $this;
@@ -112,6 +120,14 @@
return bless({ 'cases' => [] }, $class);
}
+=head2 start_engine
+
+Creates an associated L object which in turn
+starts an L, a L, and a
+L object.
+
+=cut
+
sub start_engine($;@) {
my ($self, @args) = @_;
@@ -119,6 +135,15 @@
$self->{'engine'} = Varnish::Test::Engine->new(@args);
}
+=head2 stop_engine
+
+Stop Engine object using its "shutdown" method which also stops the
+server, Varnish, and closes all other open sockets (which might have
+been left by client objects that have not been shut down explicitly
+during test-case run).
+
+=cut
+
sub stop_engine($;$) {
my ($self) = @_;
@@ -128,6 +153,13 @@
}
}
+=head2 cases
+
+Return a list of Perl modules under Varnish/Test/Case directory. These
+are all the available test-cases.
+
+=cut
+
sub cases($) {
my ($self) = @_;
@@ -141,6 +173,12 @@
return @cases;
}
+=head2 run_case
+
+Run a test-case given by its name.
+
+=cut
+
sub run_case($$) {
my ($self, $name) = @_;
@@ -166,6 +204,12 @@
}
}
+=head2 results
+
+Return a hashref of all test-case results.
+
+=cut
+
sub results($) {
my ($self) = @_;
@@ -177,8 +221,9 @@
=head1 SEE ALSO
L
+L
L
-L
L
+L
=cut
From knutroy at projects.linpro.no Wed Sep 5 14:53:25 2007
From: knutroy at projects.linpro.no (knutroy at projects.linpro.no)
Date: Wed, 5 Sep 2007 16:53:25 +0200 (CEST)
Subject: r1938 - trunk/varnish-tools/regress
Message-ID: <20070905145325.659141EC307@projects.linpro.no>
Author: knutroy
Date: 2007-09-05 16:53:25 +0200 (Wed, 05 Sep 2007)
New Revision: 1938
Modified:
trunk/varnish-tools/regress/MANIFEST
Log:
Forgot to update MANIFEST.
Modified: trunk/varnish-tools/regress/MANIFEST
===================================================================
--- trunk/varnish-tools/regress/MANIFEST 2007-09-05 12:49:05 UTC (rev 1937)
+++ trunk/varnish-tools/regress/MANIFEST 2007-09-05 14:53:25 UTC (rev 1938)
@@ -16,8 +16,8 @@
lib/Varnish/Test/Report/HTML.pm
lib/Varnish/Test/Report/report.html
lib/Varnish/Test/Server.pm
+lib/Varnish/Test/Server/Connection.pm
lib/Varnish/Test/Varnish.pm
Makefile.PL
MANIFEST
README
-TODO
From des at projects.linpro.no Thu Sep 6 23:22:06 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Fri, 7 Sep 2007 01:22:06 +0200 (CEST)
Subject: r1939 - trunk/varnish-doc/share
Message-ID: <20070906232206.949E11EC429@projects.linpro.no>
Author: des
Date: 2007-09-07 01:22:06 +0200 (Fri, 07 Sep 2007)
New Revision: 1939
Modified:
trunk/varnish-doc/share/docbook-xml.css
Log:
Limit the width to a sensible value so text will still be readable when you
maximize your browser window.
Add formatting for .
Correct whitespace handling for .
Modified: trunk/varnish-doc/share/docbook-xml.css
===================================================================
--- trunk/varnish-doc/share/docbook-xml.css 2007-09-05 14:53:25 UTC (rev 1938)
+++ trunk/varnish-doc/share/docbook-xml.css 2007-09-06 23:22:06 UTC (rev 1939)
@@ -5,6 +5,7 @@
color: black;
font-family: sans-serif;
margin: 1in;
+ max-width: 80ex;
}
/*
@@ -228,6 +229,13 @@
}
/*
+ * Formatting
+ */
+emphasis {
+ font-style: italic;
+}
+
+/*
* Misc
*/
command {
@@ -264,5 +272,6 @@
border: thin solid black;
background-color: #ccc;
font-family: monospace;
+ white-space: pre;
padding: 0.5ex;
}
From cecilihf at projects.linpro.no Fri Sep 7 09:22:31 2007
From: cecilihf at projects.linpro.no (cecilihf at projects.linpro.no)
Date: Fri, 7 Sep 2007 11:22:31 +0200 (CEST)
Subject: r1940 - in trunk/varnish-cache: bin/varnishd include lib/libvcl
Message-ID: <20070907092231.AEDEE1EC468@projects.linpro.no>
Author: cecilihf
Date: 2007-09-07 11:22:30 +0200 (Fri, 07 Sep 2007)
New Revision: 1940
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_backend.c
trunk/varnish-cache/bin/varnishd/cache_backend_random.c
trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/include/vcl.h
trunk/varnish-cache/include/vrt.h
trunk/varnish-cache/lib/libvcl/vcc_backend.c
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Added health checks for individual servers within a balanced backend cluster.
The health checks work the same as for a general backend. The worse the health of
an individual server within a balanced backend, the less likely it will be to get new
connections.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-06 23:22:06 UTC (rev 1939)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-07 09:22:30 UTC (rev 1940)
@@ -337,6 +337,7 @@
typedef void vbe_init_f(void);
typedef const char *vbe_gethostname_f(struct backend *);
typedef void vbe_cleanup_f(struct backend *);
+typedef void vbe_updatehealth_f(struct sess *sp, struct vbe_conn *vc, int);
struct backend_method {
const char *name;
@@ -345,6 +346,7 @@
vbe_recycle_f *recycle;
vbe_cleanup_f *cleanup;
vbe_gethostname_f *gethostname;
+ vbe_updatehealth_f *updatehealth;
vbe_init_f *init;
};
@@ -396,6 +398,7 @@
struct backend *VBE_NewBackend(struct backend_method *method);
struct vbe_conn *VBE_NewConn(void);
void VBE_ReleaseConn(struct vbe_conn *);
+void VBE_UpdateHealth(struct sess *sp, struct vbe_conn *, int);
/* cache_backend_simple.c */
extern struct backend_method backend_method_simple;
Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-06 23:22:06 UTC (rev 1939)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-07 09:22:30 UTC (rev 1940)
@@ -231,6 +231,22 @@
CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
}
+/* Update health ----------------------------------------------*/
+
+void
+VBE_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int a)
+{
+ struct backend *b;
+
+ CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
+ CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
+ b = vc->backend;
+ AN(b->method);
+ AN(b->method->updatehealth);
+ b->method->updatehealth(sp, vc, a);
+ CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
+}
+
/*--------------------------------------------------------------------*/
void
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-06 23:22:06 UTC (rev 1939)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-07 09:22:30 UTC (rev 1940)
@@ -50,6 +50,7 @@
unsigned magic;
#define BER_MAGIC 0x645b03f4
struct brspec *blist;
+ int count;
#if 0
/* Store a hash of the backend info given in
* vcl for comparison when a new vcl file is
@@ -72,6 +73,7 @@
double dnstime;
unsigned dnsseq;
TAILQ_HEAD(, vbe_conn) connlist;
+ int health;
};
/*--------------------------------------------------------------------*/
@@ -217,6 +219,8 @@
struct ber *ber;
struct brspec *bs;
double r;
+ int min_health = -10;
+ int num = 0;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
@@ -230,6 +234,19 @@
bs = bs->next;
CHECK_OBJ_NOTNULL(bs, BRSPEC_MAGIC);
}
+
+ /* If health is low (bad), use round-robin to find
+ * a server with better health (if possible).
+ */
+ while (bs->health < min_health) {
+ bs = bs->next;
+ num++;
+ if (num > ber->count) {
+ min_health *= 10;
+ num = 0;
+ }
+ }
+
while (1) {
LOCK(&bp->mtx);
vc = TAILQ_FIRST(&bs->connlist);
@@ -379,6 +396,30 @@
/*--------------------------------------------------------------------*/
static void
+ber_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int add)
+{
+ struct brspec *bs, *first;
+ struct ber *ber;
+
+ if (vc != NULL) {
+ CAST_OBJ_NOTNULL(bs, vc->priv, BRSPEC_MAGIC);
+
+ if (bs->health + add >= -10000 || bs->health + add <= 10000)
+ bs->health += add;
+ } else {
+ CAST_OBJ_NOTNULL(ber, sp->backend->priv, BRSPEC_MAGIC);
+ first = ber->blist;
+ bs = first;
+ do {
+ bs = bs->next;
+ bs->health = (int)((double)bs->health / 2);
+ } while (bs != first);
+ }
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
ber_Init(void)
{
@@ -392,6 +433,7 @@
.close = ber_ClosedFd,
.recycle = ber_RecycleFd,
.gethostname = ber_GetHostname,
+ .updatehealth = ber_UpdateHealth,
.cleanup = ber_Cleanup,
.init = ber_Init
};
@@ -426,6 +468,7 @@
ber = calloc(sizeof *ber, 1);
XXXAN(ber);
ber->magic = BER_MAGIC;
+ ber->count = t->count;
b->priv = ber;
@@ -454,6 +497,7 @@
bs->limit = limit;
bs->dnsttl = 300;
+ bs->health = 0;
if (bs_first == NULL)
bs_first = bs;
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-06 23:22:06 UTC (rev 1939)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-07 09:22:30 UTC (rev 1940)
@@ -50,6 +50,7 @@
unsigned magic;
#define BRR_MAGIC 0x66f05894
struct bspec *blist;
+ int count;
#if 0
/* Store a hash of the backend info given in
* vcl for comparison when a new vcl file is
@@ -71,6 +72,7 @@
double dnstime;
unsigned dnsseq;
TAILQ_HEAD(, vbe_conn) connlist;
+ int health;
};
/*--------------------------------------------------------------------*/
@@ -215,13 +217,22 @@
int reuse = 0;
struct brr *brr;
struct bspec *bs;
+ int min_health = -10;
+ int num = 0;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
bp = sp->backend;
CAST_OBJ_NOTNULL(brr, bp->priv, BRR_MAGIC);
- bs = brr->blist = brr->blist->next;
+ do {
+ bs = brr->blist = brr->blist->next;
+ num++;
+ if (num > brr->count) {
+ min_health *= 10;
+ num = 0;
+ }
+ } while (bs->health < min_health);
while (1) {
LOCK(&bp->mtx);
@@ -372,6 +383,31 @@
/*--------------------------------------------------------------------*/
static void
+brr_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int add)
+{
+ struct bspec *bs, *first;
+ struct brr *brr;
+
+ if (vc != NULL) {
+
+ CAST_OBJ_NOTNULL(bs, vc->priv, BSPEC_MAGIC);
+
+ if (bs->health + add >= -10000 || bs->health + add <= 10000)
+ bs->health += add;
+ } else {
+ CAST_OBJ_NOTNULL(brr, sp->backend->priv, BSPEC_MAGIC);
+ first = brr->blist;
+ bs = first;
+ do {
+ bs = bs->next;
+ bs->health = (int)((double)bs->health / 2);
+ } while (bs != first);
+ }
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
brr_Init(void)
{
@@ -385,6 +421,7 @@
.close = brr_ClosedFd,
.recycle = brr_RecycleFd,
.gethostname = brr_GetHostname,
+ .updatehealth = brr_UpdateHealth,
.cleanup = brr_Cleanup,
.init = brr_Init
};
@@ -417,6 +454,7 @@
brr = calloc(sizeof *brr, 1);
XXXAN(brr);
brr->magic = BRR_MAGIC;
+ brr->count = t->count;
b->priv = brr;
@@ -437,6 +475,7 @@
XXXAN(bs->hostname);
bs->dnsttl = 300;
+ bs->health = 0;
if (bs_first == NULL)
bs_first = bs;
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-06 23:22:06 UTC (rev 1939)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-07 09:22:30 UTC (rev 1940)
@@ -348,6 +348,21 @@
/*--------------------------------------------------------------------*/
static void
+bes_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int a)
+{
+ (void)sp;
+ (void)vc;
+ (void)a;
+
+ /*
+ * Not of any use for simple backend. The global health
+ * parameter of the backend should be enough.
+ */
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
bes_Init(void)
{
@@ -361,6 +376,7 @@
.close = bes_ClosedFd,
.recycle = bes_RecycleFd,
.gethostname = bes_GetHostname,
+ .updatehealth = bes_UpdateHealth,
.cleanup = bes_Cleanup,
.init = bes_Init
};
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-06 23:22:06 UTC (rev 1939)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-07 09:22:30 UTC (rev 1940)
@@ -434,6 +434,7 @@
if (minutes > sp->backend->minute_limit) {
sp->backend->minute_limit++;
sp->backend->health = (int)((double)sp->backend->health / 2);
+ VBE_UpdateHealth(sp, NULL, 0);
}
VCL_hit_method(sp);
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-06 23:22:06 UTC (rev 1939)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-07 09:22:30 UTC (rev 1940)
@@ -377,6 +377,12 @@
cls = 1;
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
+
+ if (http_GetStatus(sp->bereq->http) == 200)
+ VBE_UpdateHealth(sp, vc, 1);
+ else if(http_GetStatus(sp->bereq->http) == 504)
+ VBE_UpdateHealth(sp, vc, -1);
+
if (cls)
VBE_ClosedFd(sp->wrk, vc);
else
Modified: trunk/varnish-cache/include/vcl.h
===================================================================
--- trunk/varnish-cache/include/vcl.h 2007-09-06 23:22:06 UTC (rev 1939)
+++ trunk/varnish-cache/include/vcl.h 2007-09-07 09:22:30 UTC (rev 1940)
@@ -21,7 +21,7 @@
struct vrt_ref *ref;
unsigned nref;
unsigned busy;
-
+
unsigned nsrc;
const char **srcname;
const char **srcbody;
Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2007-09-06 23:22:06 UTC (rev 1939)
+++ trunk/varnish-cache/include/vrt.h 2007-09-07 09:22:30 UTC (rev 1940)
@@ -55,6 +55,7 @@
struct vrt_round_robin_backend {
const char *name;
+ unsigned count;
struct vrt_backend_entry *bentry;
};
Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2007-09-06 23:22:06 UTC (rev 1939)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2007-09-07 09:22:30 UTC (rev 1940)
@@ -311,6 +311,7 @@
Fc(tl, 0, "\nstatic struct vrt_round_robin_backend sbe_%.*s = {\n",
PF(t_be));
Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(t_be));
+ Fc(tl, 0, "\t.count = %d,\n", cnt);
Fc(tl, 0, "\t.bentry = &bentry_%.*s_%d\n", PF(t_be), cnt-1);
Fc(tl, 0, "};\n");
Fi(tl, 0, "\tVRT_init_round_robin_backend(&VGC_backend_%.*s , &sbe_%.*s);\n",
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-06 23:22:06 UTC (rev 1939)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-07 09:22:30 UTC (rev 1940)
@@ -433,6 +433,7 @@
vsb_cat(sb, "\n");
vsb_cat(sb, "struct vrt_round_robin_backend {\n");
vsb_cat(sb, " const char *name;\n");
+ vsb_cat(sb, " unsigned count;\n");
vsb_cat(sb, " struct vrt_backend_entry *bentry;\n");
vsb_cat(sb, "};\n");
vsb_cat(sb, "\n");
From knutroy at projects.linpro.no Fri Sep 7 11:31:18 2007
From: knutroy at projects.linpro.no (knutroy at projects.linpro.no)
Date: Fri, 7 Sep 2007 13:31:18 +0200 (CEST)
Subject: r1941 - trunk/varnish-tools/regress/lib/Varnish/Test
Message-ID: <20070907113118.9CDAB1EC46C@projects.linpro.no>
Author: knutroy
Date: 2007-09-07 13:31:18 +0200 (Fri, 07 Sep 2007)
New Revision: 1941
Modified:
trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm
Log:
* Added recognition of HEAD responses.
Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm
===================================================================
--- trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm 2007-09-07 09:22:30 UTC (rev 1940)
+++ trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm 2007-09-07 11:31:18 UTC (rev 1941)
@@ -62,6 +62,7 @@
my $self = bless({ 'engine' => $engine,
'mux' => $engine->{'mux'},
'id' => $id_seq++,
+ 'pending' => [],
'requests' => 0,
'responses' => 0 }, $class);
@@ -117,6 +118,7 @@
$self->{'mux'}->write($self->{'fh'}, $request->as_string("\r\n"));
$self->{'requests'} += 1;
$self->logf("%s %s %s", $request->method(), $request->uri(), $request->protocol());
+ push(@{$self->{'pending'}}, $request);
}
=head2 got_response
@@ -131,7 +133,7 @@
$self->{'responses'} += 1;
$self->logf("%s %s", $response->code(), $response->message());
- $self->{'engine'}->ev_client_response($self, $response);
+ $self->{'engine'}->ev_client_response($self, $response, shift(@{$self->{'pending'}}));
}
=head2 shutdown
@@ -183,6 +185,9 @@
# if connection is closed ("mux_eof").
while ($$data =~ /\n\r?\n/) {
+ die "Received HTTP-data without awaiting any response\n"
+ unless @{$self->{'pending'}};
+
# If we find a double (CR)LF in the input data, we have at
# least a complete header section of a message, so look for
# content-length and decide what to do.
@@ -190,7 +195,18 @@
my $response = HTTP::Response->parse($$data);
my $content_length = $response->content_length;
- if (defined($content_length)) {
+ if (${$self->{'pending'}}[0]->method eq 'HEAD') {
+ # This is the response of a HEAD request, so we don't
+ # expect or want any content. Any remaining input data
+ # should be the start of another HTTP-message.
+
+ $$data = $response->content;
+ $response->content('');
+
+ # Send response to event handling.
+ $self->got_response($response);
+ }
+ elsif (defined($content_length)) {
my $content_ref = $response->content_ref;
my $data_length = length($$content_ref);
if ($data_length == $content_length) {
@@ -200,14 +216,6 @@
$$data = '';
$self->got_response($response);
}
- elsif ($data_length == 0) {
- # We got a body-less response, which may or may not
- # be correct; leave it to the test case to decide.
- $self->log("No body received despite" .
- " Content-Length $content_length");
- $$data = '';
- $self->got_response($response);
- }
elsif ($data_length < $content_length) {
# We only received the first part of an HTTP message,
# so break out of loop and wait for more.
@@ -259,13 +267,17 @@
my ($self, $mux, $fh, $data) = @_;
if ($$data ne '') {
- die "Junk or incomplete response\n"
+ die "Received HTTP-data without awaiting any response\n"
+ unless @{$self->{'pending'}};
+ die "Received incomplete response headers and connection is closing\n"
unless $$data =~ "\n\r?\n";
my $response = HTTP::Response->parse($$data);
$$data = '';
$self->got_response($response);
}
+ $self->logf("%d pending request(s) never received a response\n", @{$self->{'pending'}})
+ if @{$self->{'pending'}};
}
=head2 mux_timeout
From phk at projects.linpro.no Wed Sep 12 06:12:18 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Wed, 12 Sep 2007 08:12:18 +0200 (CEST)
Subject: r1942 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070912061218.772B01EC42F@projects.linpro.no>
Author: phk
Date: 2007-09-12 08:12:18 +0200 (Wed, 12 Sep 2007)
New Revision: 1942
Modified:
trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
Make sure to initialize t_end if we drop sessions.
Fixes #132
Many thanks to Janis Putrams for debugging this.
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-07 11:31:18 UTC (rev 1941)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-12 06:12:18 UTC (rev 1942)
@@ -310,6 +310,7 @@
(params->wthread_max * params->overflow_max) / 100)) {
VSL_stats->n_wrk_drop++;
UNLOCK(&tmtx);
+ sp->t_end = TIM_real();
vca_close_session(sp, "dropped");
vca_return_session(sp);
return;
From des at projects.linpro.no Wed Sep 12 08:37:42 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Wed, 12 Sep 2007 10:37:42 +0200 (CEST)
Subject: r1943 - trunk/varnish-cache
Message-ID: <20070912083742.C5F591EC405@projects.linpro.no>
Author: des
Date: 2007-09-12 10:37:42 +0200 (Wed, 12 Sep 2007)
New Revision: 1943
Modified:
trunk/varnish-cache/autogen.des
Log:
Install man pages into the correct directory.
Modified: trunk/varnish-cache/autogen.des
===================================================================
--- trunk/varnish-cache/autogen.des 2007-09-12 06:12:18 UTC (rev 1942)
+++ trunk/varnish-cache/autogen.des 2007-09-12 08:37:42 UTC (rev 1943)
@@ -17,4 +17,5 @@
--enable-extra-developer-warnings \
--enable-stack-protector \
--enable-werror \
- --prefix=/opt/varnish
+ --prefix=/opt/varnish \
+ --mandir=/opt/varnish/man
From anders at fupp.net Wed Sep 12 12:10:15 2007
From: anders at fupp.net (Anders Nordby)
Date: Wed, 12 Sep 2007 14:10:15 +0200
Subject: r1942 - trunk/varnish-cache/bin/varnishd
In-Reply-To: <20070912061218.772B01EC42F@projects.linpro.no>
References: <20070912061218.772B01EC42F@projects.linpro.no>
Message-ID: <20070912121015.GA93519@fupp.net>
Hi,
After applying this patch to Varnish 1.1.1 (+commit 1913, the fix for
ticket #150), I got a sig10 crash:
Sep 12 13:51:14 cache10 kernel: pid 73320 (varnishd), uid 0: exited on
signal 10 (core dumped)
Backtrace of the core dump shows:
# gdb -c varnishd.core -s
/usr/local/sbin/varnishd
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "amd64-marcel-freebsd"...
Core was generated by `varnishd'.
Program terminated with signal 10, Bus error.
#0 0x00000000004089f0 in vbe_sock_conn (ai=0xd0d0d0d0d0d0d0d0)
at cache_backend.c:158
158 s = socket(ai->ai_family, ai->ai_socktype,
ai->ai_protocol);
(gdb) bt
#0 0x00000000004089f0 in vbe_sock_conn (ai=0xd0d0d0d0d0d0d0d0)
at cache_backend.c:158
#1 0x0000000000408a9c in vbe_conn_try (bp=0xaf4d00, pai=0x7ffff9bcc848)
at cache_backend.c:176
#2 0x0000000000408c74 in vbe_connect (sp=0x2a81008, bp=0xaf4d00)
at cache_backend.c:224
#3 0x0000000000409093 in vbe_nextfd (sp=0x2a81008) at
cache_backend.c:295
#4 0x00000000004092d2 in VBE_GetFd (sp=0x2a81008) at
cache_backend.c:332
#5 0x000000000040ca50 in Fetch (sp=0x2a81008) at cache_fetch.c:278
#6 0x000000000040a094 in cnt_fetch (sp=0x2a81008) at cache_center.c:300
#7 0x000000000040b0fd in CNT_Session (sp=0x2a81008) at steps.h:40
#8 0x0000000000412aa8 in wrk_do_one (w=0x7ffff9bccad0) at
cache_pool.c:194
#9 0x0000000000412fa3 in wrk_thread (priv=0x856300) at cache_pool.c:248
#10 0x000000080098755b in ?? ()
#11 0x0000000000000000 in ?? ()
#12 0x00007ffffe5f3fd8 in ?? ()
#13 0x0000000004756a00 in ?? ()
#14 0x0000000000000000 in ?? ()
#15 0x000000000053be00 in ?? ()
#16 0x00007ffff99cf000 in ?? ()
Cannot access memory at address 0x7ffff9bcf000
(gdb)
This is on FreeBSD/amd64 6.2-RELEASE.
Should I try trunk to see if it is any better?
On Wed, Sep 12, 2007 at 08:12:18AM +0200, phk at projects.linpro.no wrote:
> Author: phk
> Date: 2007-09-12 08:12:18 +0200 (Wed, 12 Sep 2007)
> New Revision: 1942
>
> Modified:
> trunk/varnish-cache/bin/varnishd/cache_pool.c
> Log:
> Make sure to initialize t_end if we drop sessions.
>
> Fixes #132
>
> Many thanks to Janis Putrams for debugging this.
>
>
>
> Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
> ===================================================================
> --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-07 11:31:18 UTC (rev 1941)
> +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-12 06:12:18 UTC (rev 1942)
> @@ -310,6 +310,7 @@
> (params->wthread_max * params->overflow_max) / 100)) {
> VSL_stats->n_wrk_drop++;
> UNLOCK(&tmtx);
> + sp->t_end = TIM_real();
> vca_close_session(sp, "dropped");
> vca_return_session(sp);
> return;
>
> _______________________________________________
> varnish-commit mailing list
> varnish-commit at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-commit
--
Anders.
From ssm at projects.linpro.no Wed Sep 12 13:19:28 2007
From: ssm at projects.linpro.no (ssm at projects.linpro.no)
Date: Wed, 12 Sep 2007 15:19:28 +0200 (CEST)
Subject: r1944 - trunk/varnish-cache/debian
Message-ID: <20070912131928.3FC7B1EC307@projects.linpro.no>
Author: ssm
Date: 2007-09-12 15:19:27 +0200 (Wed, 12 Sep 2007)
New Revision: 1944
Modified:
trunk/varnish-cache/debian/changelog
Log:
Bump debian version-revision to 1.1.2-1
Modified: trunk/varnish-cache/debian/changelog
===================================================================
--- trunk/varnish-cache/debian/changelog 2007-09-12 08:37:42 UTC (rev 1943)
+++ trunk/varnish-cache/debian/changelog 2007-09-12 13:19:27 UTC (rev 1944)
@@ -1,3 +1,9 @@
+varnish (1.1.2-1) unstable; urgency=low
+
+ * New upstream release
+
+ -- Stig Sandbeck Mathisen Wed, 12 Sep 2007 15:16:30 +0200
+
varnish (1.1.1-1) unstable; urgency=low
[Lars Bahner]
From ssm at projects.linpro.no Wed Sep 12 14:30:36 2007
From: ssm at projects.linpro.no (ssm at projects.linpro.no)
Date: Wed, 12 Sep 2007 16:30:36 +0200 (CEST)
Subject: r1945 - trunk/varnish-cache/debian
Message-ID: <20070912143036.ACB621EC21C@projects.linpro.no>
Author: ssm
Date: 2007-09-12 16:30:36 +0200 (Wed, 12 Sep 2007)
New Revision: 1945
Modified:
trunk/varnish-cache/debian/lintian-override
trunk/varnish-cache/debian/varnish.postinst
Log:
Debian package: Fix lintian warnings
* Add magic tag in varnish.postinst for debhelper
* Remove old overrides, add two overrides for update-rc.d
Modified: trunk/varnish-cache/debian/lintian-override
===================================================================
--- trunk/varnish-cache/debian/lintian-override 2007-09-12 13:19:27 UTC (rev 1944)
+++ trunk/varnish-cache/debian/lintian-override 2007-09-12 14:30:36 UTC (rev 1945)
@@ -1,4 +1,3 @@
-varnish: non-dev-pkg-with-shlib-symlink usr/lib/libvarnish.so.0.0.0 usr/lib/libvarnish.so
-varnish: non-dev-pkg-with-shlib-symlink usr/lib/libvarnishapi.so.0.0.0 usr/lib/libvarnishapi.so
-varnish: non-dev-pkg-with-shlib-symlink usr/lib/libvcl.so.0.0.0 usr/lib/libvcl.so
-varnish: package-name-doesnt-match-sonames libvarnishapi0 libvcl0 libvarnish0
+varnish: duplicate-updaterc.d-calls-in-postinst varnish
+varnish: duplicate-updaterc.d-calls-in-postinst varnishlog
+
Modified: trunk/varnish-cache/debian/varnish.postinst
===================================================================
--- trunk/varnish-cache/debian/varnish.postinst 2007-09-12 13:19:27 UTC (rev 1944)
+++ trunk/varnish-cache/debian/varnish.postinst 2007-09-12 14:30:36 UTC (rev 1945)
@@ -8,6 +8,7 @@
varnish_setup_user
+#DEBHELPER#
# Automatically added by dh_installinit
if [ -x "/etc/init.d/varnish" ]; then
update-rc.d varnish defaults >/dev/null
From ssm at projects.linpro.no Wed Sep 12 14:31:22 2007
From: ssm at projects.linpro.no (ssm at projects.linpro.no)
Date: Wed, 12 Sep 2007 16:31:22 +0200 (CEST)
Subject: r1946 - trunk/varnish-cache/debian
Message-ID: <20070912143122.8484B1EC454@projects.linpro.no>
Author: ssm
Date: 2007-09-12 16:31:22 +0200 (Wed, 12 Sep 2007)
New Revision: 1946
Added:
trunk/varnish-cache/debian/libvarnish0-dev.dirs
trunk/varnish-cache/debian/libvarnish0-dev.install
trunk/varnish-cache/debian/libvarnish0.dirs
trunk/varnish-cache/debian/libvarnish0.install
Removed:
trunk/varnish-cache/debian/libvarnish-dev.dirs
trunk/varnish-cache/debian/libvarnish-dev.install
trunk/varnish-cache/debian/libvarnish.dirs
trunk/varnish-cache/debian/libvarnish.install
Modified:
trunk/varnish-cache/debian/changelog
trunk/varnish-cache/debian/control
Log:
Debian package: Rename library and development packages to reflect soname
Modified: trunk/varnish-cache/debian/changelog
===================================================================
--- trunk/varnish-cache/debian/changelog 2007-09-12 14:30:36 UTC (rev 1945)
+++ trunk/varnish-cache/debian/changelog 2007-09-12 14:31:22 UTC (rev 1946)
@@ -1,8 +1,9 @@
varnish (1.1.2-1) unstable; urgency=low
* New upstream release
+ * Renamed library and development packages to reflect sonames
- -- Stig Sandbeck Mathisen Wed, 12 Sep 2007 15:16:30 +0200
+ -- Stig Sandbeck Mathisen Wed, 12 Sep 2007 16:05:22 +0200
varnish (1.1.1-1) unstable; urgency=low
Modified: trunk/varnish-cache/debian/control
===================================================================
--- trunk/varnish-cache/debian/control 2007-09-12 14:30:36 UTC (rev 1945)
+++ trunk/varnish-cache/debian/control 2007-09-12 14:31:22 UTC (rev 1946)
@@ -8,7 +8,7 @@
Package: varnish
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, gcc ( >= 3.3), libvarnish, libc6-dev | libc-dev
+Depends: ${shlibs:Depends}, ${misc:Depends}, gcc ( >= 3.3), libc6-dev | libc-dev, adduser
Description: A state-of-the-art, high-performance HTTP accelerator
varnish is the server-side alternative to Squid, written primarily with
speed in mind, and with a look to implementing full ESI-support in
@@ -21,26 +21,16 @@
will take full advantage of the advanced I/O features offered by these
operating systems.
-Package: libvarnish
+Package: libvarnish0
+Replaces: libvarnish
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Shared library for Varnish
- Shared library for Varnish.
- .
- Varnish is the server-side alternative to Squid, written primarily
- with speed in mind.
- .
- The goal of the Varnish project is to develop a state-of-the-art,
- high-performance HTTP accelerator.
+Description: Shared libraries for Varnish
+ Shared libraries for the Varnish HTTP accelerator.
-Package: libvarnish-dev
+Package: libvarnish0-dev
+Replaces: libvarnish-dev
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libvarnish
+Depends: ${shlibs:Depends}, ${misc:Depends}, libvarnish0
Description: Shared library for Varnish
Development files for the Varnish library.
- .
- Varnish is the server-side alternative to Squid, written primarily
- with speed in mind.
- .
- The goal of the Varnish project is to develop a state-of-the-art,
- high-performance HTTP accelerator.
Deleted: trunk/varnish-cache/debian/libvarnish-dev.dirs
===================================================================
--- trunk/varnish-cache/debian/libvarnish-dev.dirs 2007-09-12 14:30:36 UTC (rev 1945)
+++ trunk/varnish-cache/debian/libvarnish-dev.dirs 2007-09-12 14:31:22 UTC (rev 1946)
@@ -1 +0,0 @@
-usr/lib
Deleted: trunk/varnish-cache/debian/libvarnish-dev.install
===================================================================
--- trunk/varnish-cache/debian/libvarnish-dev.install 2007-09-12 14:30:36 UTC (rev 1945)
+++ trunk/varnish-cache/debian/libvarnish-dev.install 2007-09-12 14:31:22 UTC (rev 1946)
@@ -1,3 +0,0 @@
-usr/include
-usr/lib/*.a
-usr/lib/*.la
Deleted: trunk/varnish-cache/debian/libvarnish.dirs
===================================================================
--- trunk/varnish-cache/debian/libvarnish.dirs 2007-09-12 14:30:36 UTC (rev 1945)
+++ trunk/varnish-cache/debian/libvarnish.dirs 2007-09-12 14:31:22 UTC (rev 1946)
@@ -1 +0,0 @@
-usr/lib
Deleted: trunk/varnish-cache/debian/libvarnish.install
===================================================================
--- trunk/varnish-cache/debian/libvarnish.install 2007-09-12 14:30:36 UTC (rev 1945)
+++ trunk/varnish-cache/debian/libvarnish.install 2007-09-12 14:31:22 UTC (rev 1946)
@@ -1 +0,0 @@
-usr/lib/lib*.so.*
Copied: trunk/varnish-cache/debian/libvarnish0-dev.dirs (from rev 1943, trunk/varnish-cache/debian/libvarnish-dev.dirs)
===================================================================
--- trunk/varnish-cache/debian/libvarnish0-dev.dirs (rev 0)
+++ trunk/varnish-cache/debian/libvarnish0-dev.dirs 2007-09-12 14:31:22 UTC (rev 1946)
@@ -0,0 +1 @@
+usr/lib
Copied: trunk/varnish-cache/debian/libvarnish0-dev.install (from rev 1943, trunk/varnish-cache/debian/libvarnish-dev.install)
===================================================================
--- trunk/varnish-cache/debian/libvarnish0-dev.install (rev 0)
+++ trunk/varnish-cache/debian/libvarnish0-dev.install 2007-09-12 14:31:22 UTC (rev 1946)
@@ -0,0 +1,3 @@
+usr/include
+usr/lib/*.a
+usr/lib/*.la
Copied: trunk/varnish-cache/debian/libvarnish0.dirs (from rev 1943, trunk/varnish-cache/debian/libvarnish.dirs)
===================================================================
--- trunk/varnish-cache/debian/libvarnish0.dirs (rev 0)
+++ trunk/varnish-cache/debian/libvarnish0.dirs 2007-09-12 14:31:22 UTC (rev 1946)
@@ -0,0 +1 @@
+usr/lib
Copied: trunk/varnish-cache/debian/libvarnish0.install (from rev 1943, trunk/varnish-cache/debian/libvarnish.install)
===================================================================
--- trunk/varnish-cache/debian/libvarnish0.install (rev 0)
+++ trunk/varnish-cache/debian/libvarnish0.install 2007-09-12 14:31:22 UTC (rev 1946)
@@ -0,0 +1 @@
+usr/lib/lib*.so.*
From des at projects.linpro.no Wed Sep 12 14:41:44 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Wed, 12 Sep 2007 16:41:44 +0200 (CEST)
Subject: r1947 - branches/1.1
Message-ID: <20070912144144.365C31EC21C@projects.linpro.no>
Author: des
Date: 2007-09-12 16:41:43 +0200 (Wed, 12 Sep 2007)
New Revision: 1947
Modified:
branches/1.1/configure.ac
Log:
To make life easier on packagers, bump version number ahead of time.
Modified: branches/1.1/configure.ac
===================================================================
--- branches/1.1/configure.ac 2007-09-12 14:31:22 UTC (rev 1946)
+++ branches/1.1/configure.ac 2007-09-12 14:41:43 UTC (rev 1947)
@@ -3,7 +3,7 @@
AC_PREREQ(2.59)
AC_COPYRIGHT([Copyright (c) 2006-2007 Linpro AS / Verdens Gang AS])
AC_REVISION([$Id$])
-AC_INIT([Varnish], [1.1.1], [varnish-dev at projects.linpro.no])
+AC_INIT([Varnish], [1.1.2], [varnish-dev at projects.linpro.no])
AC_CONFIG_SRCDIR(include/varnishapi.h)
AM_CONFIG_HEADER(config.h)
From ssm at projects.linpro.no Wed Sep 12 15:21:12 2007
From: ssm at projects.linpro.no (ssm at projects.linpro.no)
Date: Wed, 12 Sep 2007 17:21:12 +0200 (CEST)
Subject: r1948 - in trunk/varnish-cache/bin: varnishadm varnishreplay
Message-ID: <20070912152112.E0EAE1EC6F1@projects.linpro.no>
Author: ssm
Date: 2007-09-12 17:21:12 +0200 (Wed, 12 Sep 2007)
New Revision: 1948
Modified:
trunk/varnish-cache/bin/varnishadm/varnishadm.1
trunk/varnish-cache/bin/varnishreplay/varnishreplay.1
Log:
Man page fixes
* Close list in varnishreplay.1
* Remove macro after Cm, as this cancelled the effect of Cm
Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.1
===================================================================
--- trunk/varnish-cache/bin/varnishadm/varnishadm.1 2007-09-12 14:41:43 UTC (rev 1947)
+++ trunk/varnish-cache/bin/varnishadm/varnishadm.1 2007-09-12 15:21:12 UTC (rev 1948)
@@ -36,7 +36,7 @@
.Sh SYNOPSIS
.Nm
.Fl T Ar address:port
-.Cm Ar command
+.Cm command
.Op Ar ...
.Sh DESCRIPTION
The
Modified: trunk/varnish-cache/bin/varnishreplay/varnishreplay.1
===================================================================
--- trunk/varnish-cache/bin/varnishreplay/varnishreplay.1 2007-09-12 14:41:43 UTC (rev 1947)
+++ trunk/varnish-cache/bin/varnishreplay/varnishreplay.1 2007-09-12 15:21:12 UTC (rev 1948)
@@ -53,6 +53,7 @@
.It Fl r Ar file
Parse logs from this file.
This option is mandatory.
+.El
.Sh SEE ALSO
.Xr varnishd 1 ,
.Xr varnishlog 1
From des at projects.linpro.no Wed Sep 12 15:55:51 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Wed, 12 Sep 2007 17:55:51 +0200 (CEST)
Subject: r1949 - in trunk/varnish-cache/bin: varnishadm varnishd varnishreplay
Message-ID: <20070912155552.02DFB1EC471@projects.linpro.no>
Author: des
Date: 2007-09-12 17:55:51 +0200 (Wed, 12 Sep 2007)
New Revision: 1949
Modified:
trunk/varnish-cache/bin/varnishadm/varnishadm.1
trunk/varnish-cache/bin/varnishd/varnishd.1
trunk/varnish-cache/bin/varnishreplay/varnishreplay.1
Log:
Additional markup fixes, bump date
Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.1
===================================================================
--- trunk/varnish-cache/bin/varnishadm/varnishadm.1 2007-09-12 15:21:12 UTC (rev 1948)
+++ trunk/varnish-cache/bin/varnishadm/varnishadm.1 2007-09-12 15:55:51 UTC (rev 1949)
@@ -28,14 +28,14 @@
.\"
.\" $Id$
.\"
-.Dd August 19, 2007
+.Dd September 12, 2007
.Dt VARNISHADM 1
.Os
.Sh NAME
.Nm varnishadm
.Sh SYNOPSIS
.Nm
-.Fl T Ar address:port
+.Fl T Ar address Ns : Ns Ar port
.Cm command
.Op Ar ...
.Sh DESCRIPTION
@@ -43,11 +43,11 @@
.Nm
utility sends the given command and arguments to the
.Xr varnishd 1
-instance at address:port and prints the results.
+instance at the specified address and port and prints the results.
.Pp
The following options are available:
.Bl -tag -width Fl
-.It Fl T Ar address:port
+.It Fl T Ar address Ns : Ns Ar port
Connect to the management interface at the specified address and port.
.El
.Sh EXIT STATUS
Modified: trunk/varnish-cache/bin/varnishd/varnishd.1
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.1 2007-09-12 15:21:12 UTC (rev 1948)
+++ trunk/varnish-cache/bin/varnishd/varnishd.1 2007-09-12 15:55:51 UTC (rev 1949)
@@ -36,7 +36,7 @@
.Nd HTTP accelerator daemon
.Sh SYNOPSIS
.Nm
-.Op Fl a Ar addrss Ns Op : Ns Ar port
+.Op Fl a Ar address Ns Op : Ns Ar port
.Op Fl b Ar host Ns Op : Ns Ar port
.Op Fl d
.Op Fl F
Modified: trunk/varnish-cache/bin/varnishreplay/varnishreplay.1
===================================================================
--- trunk/varnish-cache/bin/varnishreplay/varnishreplay.1 2007-09-12 15:21:12 UTC (rev 1948)
+++ trunk/varnish-cache/bin/varnishreplay/varnishreplay.1 2007-09-12 15:55:51 UTC (rev 1949)
@@ -27,7 +27,7 @@
.\"
.\" $Id$
.\"
-.Dd June 25, 2007
+.Dd September 12, 2007
.Dt VARNISHREPLAY 1
.Os
.Sh NAME
@@ -36,7 +36,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl D
-.Fl a Ar address:port
+.Fl a Ar address Ns : Ns Ar port
.Fl r Ar file
.Sh DESCRIPTION
The
@@ -45,7 +45,7 @@
.Pp
The following options are available:
.Bl -tag -width Fl
-.It Fl a Ar address:port
+.It Fl a Ar address Ns : Ns Ar port
Send the traffic over tcp to this address and port.
This option is mandatory.
.It Fl D
From des at projects.linpro.no Wed Sep 12 16:05:55 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Wed, 12 Sep 2007 18:05:55 +0200 (CEST)
Subject: r1950 - in branches/1.1: . bin/varnishadm bin/varnishd
bin/varnishreplay debian
Message-ID: <20070912160555.840FA1EC454@projects.linpro.no>
Author: des
Date: 2007-09-12 18:05:55 +0200 (Wed, 12 Sep 2007)
New Revision: 1950
Removed:
branches/1.1/debian/libvarnish-dev.dirs
branches/1.1/debian/libvarnish-dev.install
branches/1.1/debian/libvarnish.dirs
branches/1.1/debian/libvarnish.install
Modified:
branches/1.1/
branches/1.1/autogen.des
branches/1.1/bin/varnishadm/varnishadm.1
branches/1.1/bin/varnishd/varnishd.1
branches/1.1/bin/varnishreplay/varnishreplay.1
branches/1.1/debian/changelog
branches/1.1/debian/control
branches/1.1/debian/lintian-override
branches/1.1/debian/rules
branches/1.1/debian/varnish.default
branches/1.1/debian/varnish.postinst
branches/1.1/debian/varnish.varnishlog.init
Log:
Merged revisions 1935-1939,1941,1943-1949 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1935 | ssm | 2007-09-04 12:55:25 +0200 (Tue, 04 Sep 2007) | 7 lines
* Set statedir to /var/lib, to conform to debian packaging standards.
* Removed -n switch from varnish defaults file and varnishlog init script.
Use the default instance name instead. This makes sure varnish utilities work
without having to use the -n switch for the default instance.
........
r1943 | des | 2007-09-12 10:37:42 +0200 (Wed, 12 Sep 2007) | 2 lines
Install man pages into the correct directory.
........
r1944 | ssm | 2007-09-12 15:19:27 +0200 (Wed, 12 Sep 2007) | 1 line
Bump debian version-revision to 1.1.2-1
........
r1945 | ssm | 2007-09-12 16:30:36 +0200 (Wed, 12 Sep 2007) | 4 lines
Debian package: Fix lintian warnings
* Add magic tag in varnish.postinst for debhelper
* Remove old overrides, add two overrides for update-rc.d
........
r1946 | ssm | 2007-09-12 16:31:22 +0200 (Wed, 12 Sep 2007) | 1 line
Debian package: Rename library and development packages to reflect soname
........
r1948 | ssm | 2007-09-12 17:21:12 +0200 (Wed, 12 Sep 2007) | 4 lines
Man page fixes
* Close list in varnishreplay.1
* Remove macro after Cm, as this cancelled the effect of Cm
........
r1949 | des | 2007-09-12 17:55:51 +0200 (Wed, 12 Sep 2007) | 2 lines
Additional markup fixes, bump date
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1795,1797-1798,1800-1808,1810-1815,1817,1819,1823,1831-1838,1846,1853-1855,1857-1859,1862,1865,1867-1868,1871,1873-1880,1896,1898,1902-1905,1907,1909,1913-1916,1920-1928
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1795,1797-1798,1800-1808,1810-1815,1817,1819,1823,1831-1838,1846,1853-1855,1857-1859,1862,1865,1867-1868,1871,1873-1880,1896,1898,1902-1905,1907,1909,1913-1916,1920-1928,1935-1939,1941,1943-1949
Modified: branches/1.1/autogen.des
===================================================================
--- branches/1.1/autogen.des 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/autogen.des 2007-09-12 16:05:55 UTC (rev 1950)
@@ -17,4 +17,5 @@
--enable-extra-developer-warnings \
--enable-stack-protector \
--enable-werror \
- --prefix=/opt/varnish
+ --prefix=/opt/varnish \
+ --mandir=/opt/varnish/man
Modified: branches/1.1/bin/varnishadm/varnishadm.1
===================================================================
--- branches/1.1/bin/varnishadm/varnishadm.1 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/bin/varnishadm/varnishadm.1 2007-09-12 16:05:55 UTC (rev 1950)
@@ -28,26 +28,26 @@
.\"
.\" $Id$
.\"
-.Dd August 19, 2007
+.Dd September 12, 2007
.Dt VARNISHADM 1
.Os
.Sh NAME
.Nm varnishadm
.Sh SYNOPSIS
.Nm
-.Fl T Ar address:port
-.Cm Ar command
+.Fl T Ar address Ns : Ns Ar port
+.Cm command
.Op Ar ...
.Sh DESCRIPTION
The
.Nm
utility sends the given command and arguments to the
.Xr varnishd 1
-instance at address:port and prints the results.
+instance at the specified address and port and prints the results.
.Pp
The following options are available:
.Bl -tag -width Fl
-.It Fl T Ar address:port
+.It Fl T Ar address Ns : Ns Ar port
Connect to the management interface at the specified address and port.
.El
.Sh EXIT STATUS
Modified: branches/1.1/bin/varnishd/varnishd.1
===================================================================
--- branches/1.1/bin/varnishd/varnishd.1 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/bin/varnishd/varnishd.1 2007-09-12 16:05:55 UTC (rev 1950)
@@ -36,7 +36,7 @@
.Nd HTTP accelerator daemon
.Sh SYNOPSIS
.Nm
-.Op Fl a Ar addrss Ns Op : Ns Ar port
+.Op Fl a Ar address Ns Op : Ns Ar port
.Op Fl b Ar host Ns Op : Ns Ar port
.Op Fl d
.Op Fl F
Modified: branches/1.1/bin/varnishreplay/varnishreplay.1
===================================================================
--- branches/1.1/bin/varnishreplay/varnishreplay.1 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/bin/varnishreplay/varnishreplay.1 2007-09-12 16:05:55 UTC (rev 1950)
@@ -27,7 +27,7 @@
.\"
.\" $Id$
.\"
-.Dd June 25, 2007
+.Dd September 12, 2007
.Dt VARNISHREPLAY 1
.Os
.Sh NAME
@@ -36,7 +36,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl D
-.Fl a Ar address:port
+.Fl a Ar address Ns : Ns Ar port
.Fl r Ar file
.Sh DESCRIPTION
The
@@ -45,7 +45,7 @@
.Pp
The following options are available:
.Bl -tag -width Fl
-.It Fl a Ar address:port
+.It Fl a Ar address Ns : Ns Ar port
Send the traffic over tcp to this address and port.
This option is mandatory.
.It Fl D
@@ -53,6 +53,7 @@
.It Fl r Ar file
Parse logs from this file.
This option is mandatory.
+.El
.Sh SEE ALSO
.Xr varnishd 1 ,
.Xr varnishlog 1
Modified: branches/1.1/debian/changelog
===================================================================
--- branches/1.1/debian/changelog 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/debian/changelog 2007-09-12 16:05:55 UTC (rev 1950)
@@ -1,14 +1,27 @@
-varnish (1.1.1) unstable; urgency=low
+varnish (1.1.2-1) unstable; urgency=low
* New upstream release
+ * Renamed library and development packages to reflect sonames
+
+ -- Stig Sandbeck Mathisen Wed, 12 Sep 2007 16:05:22 +0200
+
+varnish (1.1.1-1) unstable; urgency=low
+
+ [Lars Bahner]
+ * New upstream release
* User and Group id added to default DAEMON_OPTS
* Added user and group creation to postinst
* Added missing man pages
- -- Lars Bahner Mon, 20 Aug 2007 11:29:33 +0200
+ [Stig Sandbeck Mathisen]
+ * Set statedir to /var/lib
+ * Removed -n switch from varnish defaults file and varnishlog init script.
+ Use the default instance name instead.
-varnish (1.1) unstable; urgency=low
+ -- Stig Sandbeck Mathisen Tue, 04 Sep 2007 12:27:09 +0200
+varnish (1.1-1) unstable; urgency=low
+
* New upstream release
* Split package into varnish, libvarnish and libvarnish-dev
Modified: branches/1.1/debian/control
===================================================================
--- branches/1.1/debian/control 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/debian/control 2007-09-12 16:05:55 UTC (rev 1950)
@@ -8,7 +8,7 @@
Package: varnish
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, gcc ( >= 3.3), libvarnish, libc6-dev | libc-dev
+Depends: ${shlibs:Depends}, ${misc:Depends}, gcc ( >= 3.3), libc6-dev | libc-dev, adduser
Description: A state-of-the-art, high-performance HTTP accelerator
varnish is the server-side alternative to Squid, written primarily with
speed in mind, and with a look to implementing full ESI-support in
@@ -21,26 +21,16 @@
will take full advantage of the advanced I/O features offered by these
operating systems.
-Package: libvarnish
+Package: libvarnish0
+Replaces: libvarnish
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Shared library for Varnish
- Shared library for Varnish.
- .
- Varnish is the server-side alternative to Squid, written primarily
- with speed in mind.
- .
- The goal of the Varnish project is to develop a state-of-the-art,
- high-performance HTTP accelerator.
+Description: Shared libraries for Varnish
+ Shared libraries for the Varnish HTTP accelerator.
-Package: libvarnish-dev
+Package: libvarnish0-dev
+Replaces: libvarnish-dev
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libvarnish
+Depends: ${shlibs:Depends}, ${misc:Depends}, libvarnish0
Description: Shared library for Varnish
Development files for the Varnish library.
- .
- Varnish is the server-side alternative to Squid, written primarily
- with speed in mind.
- .
- The goal of the Varnish project is to develop a state-of-the-art,
- high-performance HTTP accelerator.
Deleted: branches/1.1/debian/libvarnish-dev.dirs
===================================================================
--- branches/1.1/debian/libvarnish-dev.dirs 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/debian/libvarnish-dev.dirs 2007-09-12 16:05:55 UTC (rev 1950)
@@ -1 +0,0 @@
-usr/lib
Deleted: branches/1.1/debian/libvarnish-dev.install
===================================================================
--- branches/1.1/debian/libvarnish-dev.install 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/debian/libvarnish-dev.install 2007-09-12 16:05:55 UTC (rev 1950)
@@ -1,3 +0,0 @@
-usr/include
-usr/lib/*.a
-usr/lib/*.la
Deleted: branches/1.1/debian/libvarnish.dirs
===================================================================
--- branches/1.1/debian/libvarnish.dirs 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/debian/libvarnish.dirs 2007-09-12 16:05:55 UTC (rev 1950)
@@ -1 +0,0 @@
-usr/lib
Deleted: branches/1.1/debian/libvarnish.install
===================================================================
--- branches/1.1/debian/libvarnish.install 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/debian/libvarnish.install 2007-09-12 16:05:55 UTC (rev 1950)
@@ -1 +0,0 @@
-usr/lib/lib*.so.*
Modified: branches/1.1/debian/lintian-override
===================================================================
--- branches/1.1/debian/lintian-override 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/debian/lintian-override 2007-09-12 16:05:55 UTC (rev 1950)
@@ -1,4 +1,3 @@
-varnish: non-dev-pkg-with-shlib-symlink usr/lib/libvarnish.so.0.0.0 usr/lib/libvarnish.so
-varnish: non-dev-pkg-with-shlib-symlink usr/lib/libvarnishapi.so.0.0.0 usr/lib/libvarnishapi.so
-varnish: non-dev-pkg-with-shlib-symlink usr/lib/libvcl.so.0.0.0 usr/lib/libvcl.so
-varnish: package-name-doesnt-match-sonames libvarnishapi0 libvcl0 libvarnish0
+varnish: duplicate-updaterc.d-calls-in-postinst varnish
+varnish: duplicate-updaterc.d-calls-in-postinst varnishlog
+
Modified: branches/1.1/debian/rules
===================================================================
--- branches/1.1/debian/rules 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/debian/rules 2007-09-12 16:05:55 UTC (rev 1950)
@@ -32,7 +32,7 @@
# The boilerplate linker flags won't allow varnish to compile :(
# There are circular dependencies in the varnish libraries, but
# the core developers have OK'ed that we don't check.
- ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" --localstatedir=/var
+ ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" --localstatedir=/var/lib
build: build-stamp
Modified: branches/1.1/debian/varnish.default
===================================================================
--- branches/1.1/debian/varnish.default 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/debian/varnish.default 2007-09-12 16:05:55 UTC (rev 1950)
@@ -7,6 +7,10 @@
# Maximum number of open files (for ulimit -n)
NFILES=131072
+# Default varnish instance name is the local nodename. Can be overridden with
+# the -n switch, to have more instances on a single server.
+INSTANCE=$(uname -n)
+
# This file contains 4 alternatives, please use only one.
## Alternative 1, Minimal configuration, no VCL
@@ -18,8 +22,7 @@
-T localhost:6082 \
-b localhost:8080 \
-u varnish -g varnish \
- -n /var/lib/varnish \
- -s file,/var/lib/varnish/varnish_storage.bin,1G"
+ -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"
## Alternative 2, Configuration with VCL
@@ -32,7 +35,7 @@
# -T localhost:6082 \
# -f /etc/varnish/default.vcl \
# -n /var/lib/varnish \
-# -s file,/var/lib/varnish/varnish_storage.bin,1G"
+# -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"
## Alternative 3, Advanced configuration
@@ -65,7 +68,7 @@
# VARNISH_HOMEDIR=/var/lib/varnish
#
# # Cache file location
-# VARNISH_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin
+# VARNISH_STORAGE_FILE=/var/lib/varnish/$INSTANCE/varnish_storage.bin
#
# # Cache file size: in bytes, optionally using k / M / G / T suffix,
# # or in percentage of available disk space using the % suffix.
@@ -84,7 +87,6 @@
# -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
# -t ${VARNISH_TTL} \
# -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \
-# -n ${VARNISH_HOMEDIR} \
# -s ${VARNISH_STORAGE}"
#
Modified: branches/1.1/debian/varnish.postinst
===================================================================
--- branches/1.1/debian/varnish.postinst 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/debian/varnish.postinst 2007-09-12 16:05:55 UTC (rev 1950)
@@ -8,6 +8,7 @@
varnish_setup_user
+#DEBHELPER#
# Automatically added by dh_installinit
if [ -x "/etc/init.d/varnish" ]; then
update-rc.d varnish defaults >/dev/null
Modified: branches/1.1/debian/varnish.varnishlog.init
===================================================================
--- branches/1.1/debian/varnish.varnishlog.init 2007-09-12 15:55:51 UTC (rev 1949)
+++ branches/1.1/debian/varnish.varnishlog.init 2007-09-12 16:05:55 UTC (rev 1950)
@@ -24,7 +24,7 @@
test -x $DAEMON || exit 0
-DAEMON_OPTS="-a -n /var/lib/varnish -w ${LOGFILE} -D -P $PIDFILE"
+DAEMON_OPTS="-a -w ${LOGFILE} -D -P $PIDFILE"
case "$1" in
start)
From des at projects.linpro.no Wed Sep 12 16:09:26 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Wed, 12 Sep 2007 18:09:26 +0200 (CEST)
Subject: r1951 - in branches/1.1: . bin/varnishd
Message-ID: <20070912160926.4EA241EC454@projects.linpro.no>
Author: des
Date: 2007-09-12 18:09:26 +0200 (Wed, 12 Sep 2007)
New Revision: 1951
Modified:
branches/1.1/
branches/1.1/bin/varnishd/cache_acceptor.c
Log:
Merged revisions 1884 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1884 | phk | 2007-08-20 12:39:05 +0200 (Mon, 20 Aug 2007) | 2 lines
remove debugging message
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1795,1797-1798,1800-1808,1810-1815,1817,1819,1823,1831-1838,1846,1853-1855,1857-1859,1862,1865,1867-1868,1871,1873-1880,1896,1898,1902-1905,1907,1909,1913-1916,1920-1928,1935-1939,1941,1943-1949
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1795,1797-1798,1800-1808,1810-1815,1817,1819,1823,1831-1838,1846,1853-1855,1857-1859,1862,1865,1867-1868,1871,1873-1880,1884,1896,1898,1902-1905,1907,1909,1913-1916,1920-1928,1935-1939,1941,1943-1949
Modified: branches/1.1/bin/varnishd/cache_acceptor.c
===================================================================
--- branches/1.1/bin/varnishd/cache_acceptor.c 2007-09-12 16:05:55 UTC (rev 1950)
+++ branches/1.1/bin/varnishd/cache_acceptor.c 2007-09-12 16:09:26 UTC (rev 1951)
@@ -103,8 +103,6 @@
if (memcmp(&tv, &tv_rcvtimeo, l))
need_rcvtimeo = 1;
need_test = 0;
- printf("socktest: linger=%d sndtimeo=%d rcvtimeo=%d\n",
- need_linger, need_sndtimeo, need_rcvtimeo);
}
void
From des at projects.linpro.no Wed Sep 12 16:13:17 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Wed, 12 Sep 2007 18:13:17 +0200 (CEST)
Subject: r1952 - in branches/1.1: . doc
Message-ID: <20070912161317.30C6A1EC21C@projects.linpro.no>
Author: des
Date: 2007-09-12 18:13:16 +0200 (Wed, 12 Sep 2007)
New Revision: 1952
Added:
branches/1.1/doc/changes-wiki.xsl
Modified:
branches/1.1/
Log:
Merged revisions 1912 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1912 | des | 2007-08-20 23:11:15 +0200 (Mon, 20 Aug 2007) | 3 lines
Add a stylesheet that does a pretty good job of generating Trac-compatible
WikiText from a change log.
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1795,1797-1798,1800-1808,1810-1815,1817,1819,1823,1831-1838,1846,1853-1855,1857-1859,1862,1865,1867-1868,1871,1873-1880,1884,1896,1898,1902-1905,1907,1909,1913-1916,1920-1928,1935-1939,1941,1943-1949
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1795,1797-1798,1800-1808,1810-1815,1817,1819,1823,1831-1838,1846,1853-1855,1857-1859,1862,1865,1867-1868,1871,1873-1880,1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941,1943-1949
Copied: branches/1.1/doc/changes-wiki.xsl (from rev 1912, trunk/varnish-cache/doc/changes-wiki.xsl)
===================================================================
--- branches/1.1/doc/changes-wiki.xsl (rev 0)
+++ branches/1.1/doc/changes-wiki.xsl 2007-09-12 16:13:16 UTC (rev 1952)
@@ -0,0 +1,76 @@
+
+
+]>
+
+
+
+
+
+
+
+ ==
+
+ ==&lf;
+
+
+
+
+ Change log for
+
+
+
+
+
+
+ ===
+ Changes between
+
+ and
+
+ ===&lf;
+
+
+
+
+ ====
+
+ ====&lf;
+
+
+
+
+ *
+
+
+
+
+
+ &lf;
+
+
+
+ #
+
+
+
+
+ {{{
+
+ }}}
+
+
+
+
+
+
+
+ Warning: no template for element
+
+
+
+
+
From des at projects.linpro.no Wed Sep 12 16:21:17 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Wed, 12 Sep 2007 18:21:17 +0200 (CEST)
Subject: r1953 - branches/1.1/debian
Message-ID: <20070912162117.94A491EC454@projects.linpro.no>
Author: des
Date: 2007-09-12 18:21:17 +0200 (Wed, 12 Sep 2007)
New Revision: 1953
Added:
branches/1.1/debian/libvarnish0-dev.dirs
branches/1.1/debian/libvarnish0-dev.install
branches/1.1/debian/libvarnish0.dirs
branches/1.1/debian/libvarnish0.install
Log:
svnmerge poo-pooed again.
Copied: branches/1.1/debian/libvarnish0-dev.dirs (from rev 1948, trunk/varnish-cache/debian/libvarnish0-dev.dirs)
===================================================================
--- branches/1.1/debian/libvarnish0-dev.dirs (rev 0)
+++ branches/1.1/debian/libvarnish0-dev.dirs 2007-09-12 16:21:17 UTC (rev 1953)
@@ -0,0 +1 @@
+usr/lib
Copied: branches/1.1/debian/libvarnish0-dev.install (from rev 1948, trunk/varnish-cache/debian/libvarnish0-dev.install)
===================================================================
--- branches/1.1/debian/libvarnish0-dev.install (rev 0)
+++ branches/1.1/debian/libvarnish0-dev.install 2007-09-12 16:21:17 UTC (rev 1953)
@@ -0,0 +1,3 @@
+usr/include
+usr/lib/*.a
+usr/lib/*.la
Copied: branches/1.1/debian/libvarnish0.dirs (from rev 1948, trunk/varnish-cache/debian/libvarnish0.dirs)
===================================================================
--- branches/1.1/debian/libvarnish0.dirs (rev 0)
+++ branches/1.1/debian/libvarnish0.dirs 2007-09-12 16:21:17 UTC (rev 1953)
@@ -0,0 +1 @@
+usr/lib
Copied: branches/1.1/debian/libvarnish0.install (from rev 1948, trunk/varnish-cache/debian/libvarnish0.install)
===================================================================
--- branches/1.1/debian/libvarnish0.install (rev 0)
+++ branches/1.1/debian/libvarnish0.install 2007-09-12 16:21:17 UTC (rev 1953)
@@ -0,0 +1 @@
+usr/lib/lib*.so.*
From des at projects.linpro.no Wed Sep 12 16:24:09 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Wed, 12 Sep 2007 18:24:09 +0200 (CEST)
Subject: r1954 - in branches/1.1: . bin/varnishd
Message-ID: <20070912162409.AF18A1EC454@projects.linpro.no>
Author: des
Date: 2007-09-12 18:24:09 +0200 (Wed, 12 Sep 2007)
New Revision: 1954
Modified:
branches/1.1/
branches/1.1/bin/varnishd/cache_pool.c
Log:
Merged revisions 1942 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1942 | phk | 2007-09-12 08:12:18 +0200 (Wed, 12 Sep 2007) | 7 lines
Make sure to initialize t_end if we drop sessions.
Fixes #132
Many thanks to Janis Putrams for debugging this.
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1795,1797-1798,1800-1808,1810-1815,1817,1819,1823,1831-1838,1846,1853-1855,1857-1859,1862,1865,1867-1868,1871,1873-1880,1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941,1943-1949
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1795,1797-1798,1800-1808,1810-1815,1817,1819,1823,1831-1838,1846,1853-1855,1857-1859,1862,1865,1867-1868,1871,1873-1880,1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
Modified: branches/1.1/bin/varnishd/cache_pool.c
===================================================================
--- branches/1.1/bin/varnishd/cache_pool.c 2007-09-12 16:21:17 UTC (rev 1953)
+++ branches/1.1/bin/varnishd/cache_pool.c 2007-09-12 16:24:09 UTC (rev 1954)
@@ -310,6 +310,7 @@
(params->wthread_max * params->overflow_max) / 100)) {
VSL_stats->n_wrk_drop++;
UNLOCK(&tmtx);
+ sp->t_end = TIM_real();
vca_close_session(sp, "dropped");
vca_return_session(sp);
return;
From cecilihf at projects.linpro.no Tue Sep 18 11:40:44 2007
From: cecilihf at projects.linpro.no (cecilihf at projects.linpro.no)
Date: Tue, 18 Sep 2007 13:40:44 +0200 (CEST)
Subject: r1955 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070918114044.6A0951EC21C@projects.linpro.no>
Author: cecilihf
Date: 2007-09-18 13:40:44 +0200 (Tue, 18 Sep 2007)
New Revision: 1955
Modified:
trunk/varnish-cache/bin/varnishd/cache_response.c
Log:
Fixes #157. Always replace Date with current time on varnish server.
Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2007-09-12 16:24:09 UTC (rev 1954)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2007-09-18 11:40:44 UTC (rev 1955)
@@ -29,6 +29,8 @@
* $Id$
*/
+#include
+#include
#include
#include
@@ -109,6 +111,8 @@
void
RES_BuildHttp(struct sess *sp)
{
+ char *time_str;
+
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (sp->obj->response == 200 && sp->http->conds && res_do_conds(sp))
@@ -121,6 +125,17 @@
http_CopyResp(sp->http, &sp->obj->http);
http_FilterFields(sp->wrk, sp->fd, sp->http, &sp->obj->http,
HTTPH_A_DELIVER);
+
+ /* Replace Date header with current date instead of keeping the date
+ * originally given by the backend when the object was fetched (which
+ * could be a long time ago).
+ */
+ http_Unset(sp->http, H_Date);
+ time_str = malloc(50);
+ sprintf(time_str, "Date: ");
+ TIM_format(TIM_real(), &(time_str[6]));
+ http_SetHeader(sp->wrk, sp->fd, sp->http, time_str);
+
if (sp->xid != sp->obj->xid)
http_PrintfHeader(sp->wrk, sp->fd, sp->http,
"X-Varnish: %u %u", sp->xid, sp->obj->xid);
From phk at projects.linpro.no Thu Sep 20 06:26:17 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 08:26:17 +0200 (CEST)
Subject: r1956 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920062617.66DAE1EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-20 08:26:17 +0200 (Thu, 20 Sep 2007)
New Revision: 1956
Modified:
trunk/varnish-cache/bin/varnishd/cache_ban.c
trunk/varnish-cache/bin/varnishd/cache_vrt_re.c
Log:
Make regular expressions case insensitive.
This is not optimal, but a better compromise than the alternative.
DNS names are case insensitive, but URLs are not.
However, URLs are very often filenames and having files which differ
only in case is already asking for trouble.
Modified: trunk/varnish-cache/bin/varnishd/cache_ban.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_ban.c 2007-09-18 11:40:44 UTC (rev 1955)
+++ trunk/varnish-cache/bin/varnishd/cache_ban.c 2007-09-20 06:26:17 UTC (rev 1956)
@@ -62,7 +62,7 @@
b = calloc(sizeof *b, 1);
XXXAN(b);
- i = regcomp(&b->regexp, regexp, REG_EXTENDED | REG_NOSUB);
+ i = regcomp(&b->regexp, regexp, REG_EXTENDED | REG_ICASE | REG_NOSUB);
if (i) {
char buf[512];
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2007-09-18 11:40:44 UTC (rev 1955)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2007-09-20 06:26:17 UTC (rev 1956)
@@ -53,7 +53,7 @@
t = calloc(sizeof *t, 1);
XXXAN(t);
/* This was already check-compiled by the VCL compiler */
- AZ(regcomp(t, re, REG_EXTENDED | (sub ? 0 : REG_NOSUB)));
+ AZ(regcomp(t, re, REG_EXTENDED | REG_ICASE | (sub ? 0 : REG_NOSUB)));
*rep = t;
}
From phk at projects.linpro.no Thu Sep 20 07:02:35 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 09:02:35 +0200 (CEST)
Subject: r1957 - trunk/varnish-cache/include
Message-ID: <20070920070235.D048D1EC2B2@projects.linpro.no>
Author: phk
Date: 2007-09-20 09:02:35 +0200 (Thu, 20 Sep 2007)
New Revision: 1957
Modified:
trunk/varnish-cache/include/miniobj.h
Log:
Add a REPLACE() macro, for manipulating malloced string variables.
Modified: trunk/varnish-cache/include/miniobj.h
===================================================================
--- trunk/varnish-cache/include/miniobj.h 2007-09-20 06:26:17 UTC (rev 1956)
+++ trunk/varnish-cache/include/miniobj.h 2007-09-20 07:02:35 UTC (rev 1957)
@@ -30,10 +30,21 @@
CHECK_OBJ((to), (type_magic)); \
} while (0);
-#define CAST_OBJ_NOTNULL(to, from, type_magic) \
+#define CAST_OBJ_NOTNULL(to, from, type_magic) \
do { \
(to) = (from); \
assert((to) != NULL); \
CHECK_OBJ((to), (type_magic)); \
} while (0);
+#define REPLACE(ptr, val) \
+ do { \
+ if ((ptr) != NULL) \
+ free(ptr); \
+ if ((val) != NULL) { \
+ ptr = strdup(val); \
+ AN((ptr)); \
+ } else { \
+ ptr = NULL; \
+ } \
+ } while (0);
From phk at projects.linpro.no Thu Sep 20 07:03:09 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 09:03:09 +0200 (CEST)
Subject: r1958 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920070309.BA12A1EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-20 09:03:09 +0200 (Thu, 20 Sep 2007)
New Revision: 1958
Modified:
trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
Use REPLACE macro to manipulate malloc'ed string variables.
Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-09-20 07:02:35 UTC (rev 1957)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-09-20 07:03:09 UTC (rev 1958)
@@ -67,18 +67,6 @@
static struct params master;
-/* XXX: Far too generic to live here ? */
-static void
-replace(char **p, const char *q)
-{
-
- AN(*q);
- if (*p != NULL)
- free(*p);
- *p = strdup(q);
- AN(*p);
-}
-
/*--------------------------------------------------------------------*/
static void
@@ -184,7 +172,7 @@
cli_result(cli, CLIS_PARAM);
return;
}
- replace(&master.user, pw->pw_name);
+ REPLACE(master.user, pw->pw_name);
master.uid = pw->pw_uid;
master.gid = pw->pw_gid;
@@ -192,7 +180,7 @@
if ((gr = getgrgid(pw->pw_gid)) != NULL &&
(gr = getgrnam(gr->gr_name)) != NULL &&
gr->gr_gid == pw->pw_gid)
- replace(&master.group, gr->gr_name);
+ REPLACE(master.group, gr->gr_name);
} else if (master.user) {
cli_out(cli, "%s (%d)", master.user, (int)master.uid);
} else {
@@ -226,7 +214,7 @@
cli_result(cli, CLIS_PARAM);
return;
}
- replace(&master.group, gr->gr_name);
+ REPLACE(master.group, gr->gr_name);
master.gid = gr->gr_gid;
} else if (master.group) {
cli_out(cli, "%s (%d)", master.group, (int)master.gid);
@@ -458,7 +446,7 @@
return;
}
- replace(&master.listen_address, arg);
+ REPLACE(master.listen_address, arg);
clean_listen_sock_head(&heritage.socks);
heritage.nsocks = 0;
From phk at projects.linpro.no Thu Sep 20 07:09:53 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 09:09:53 +0200 (CEST)
Subject: r1959 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920070953.7E1B71EC2B2@projects.linpro.no>
Author: phk
Date: 2007-09-20 09:09:53 +0200 (Thu, 20 Sep 2007)
New Revision: 1959
Modified:
trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
Log:
Use FREE_OBJ() and REPLACE() macros
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-20 07:03:09 UTC (rev 1958)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-20 07:09:53 UTC (rev 1959)
@@ -328,9 +328,9 @@
TAILQ_REMOVE(&bes->connlist, vbe, list);
if (vbe->fd >= 0)
close(vbe->fd);
- free(vbe);
+ FREE_OBJ(vbe);
}
- free(bes);
+ FREE_OBJ(bes);
}
/*--------------------------------------------------------------------*/
@@ -419,16 +419,13 @@
bes->dnsttl = 300;
AN(t->name);
- b->vcl_name = strdup(t->name);
- XXXAN(b->vcl_name);
+ REPLACE(b->vcl_name, t->name);
AN(t->port);
- bes->portname = strdup(t->port);
- XXXAN(bes->portname);
+ REPLACE(bes->portname, t->port);
AN(t->host);
- bes->hostname = strdup(t->host);
- XXXAN(bes->hostname);
+ REPLACE(bes->hostname, t->host);
*bp = b;
}
From phk at projects.linpro.no Thu Sep 20 07:14:41 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 09:14:41 +0200 (CEST)
Subject: r1960 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920071441.1BB611EC21C@projects.linpro.no>
Author: phk
Date: 2007-09-20 09:14:40 +0200 (Thu, 20 Sep 2007)
New Revision: 1960
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_backend.c
Log:
Call the init methods of all backend styles.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-20 07:09:53 UTC (rev 1959)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-20 07:14:40 UTC (rev 1960)
@@ -402,6 +402,8 @@
/* cache_backend_simple.c */
extern struct backend_method backend_method_simple;
+extern struct backend_method backend_method_random;
+extern struct backend_method backend_method_round_robin;
/* cache_ban.c */
void AddBan(const char *, int hash);
Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-20 07:09:53 UTC (rev 1959)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-20 07:14:40 UTC (rev 1960)
@@ -255,4 +255,6 @@
MTX_INIT(&VBE_mtx);
backend_method_simple.init();
+ backend_method_random.init();
+ backend_method_round_robin.init();
}
From phk at projects.linpro.no Thu Sep 20 07:19:34 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 09:19:34 +0200 (CEST)
Subject: r1961 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920071934.654111EC2B2@projects.linpro.no>
Author: phk
Date: 2007-09-20 09:19:34 +0200 (Thu, 20 Sep 2007)
New Revision: 1961
Modified:
trunk/varnish-cache/bin/varnishd/cache_backend.c
trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
Log:
Make updatehealth an optional method for backends
Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-20 07:14:40 UTC (rev 1960)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-20 07:19:34 UTC (rev 1961)
@@ -242,8 +242,8 @@
CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
b = vc->backend;
AN(b->method);
- AN(b->method->updatehealth);
- b->method->updatehealth(sp, vc, a);
+ if(b->method->updatehealth != NULL)
+ b->method->updatehealth(sp, vc, a);
CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
}
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-20 07:14:40 UTC (rev 1960)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-20 07:19:34 UTC (rev 1961)
@@ -348,21 +348,6 @@
/*--------------------------------------------------------------------*/
static void
-bes_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int a)
-{
- (void)sp;
- (void)vc;
- (void)a;
-
- /*
- * Not of any use for simple backend. The global health
- * parameter of the backend should be enough.
- */
-}
-
-/*--------------------------------------------------------------------*/
-
-static void
bes_Init(void)
{
@@ -376,7 +361,6 @@
.close = bes_ClosedFd,
.recycle = bes_RecycleFd,
.gethostname = bes_GetHostname,
- .updatehealth = bes_UpdateHealth,
.cleanup = bes_Cleanup,
.init = bes_Init
};
From phk at projects.linpro.no Thu Sep 20 07:22:56 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 09:22:56 +0200 (CEST)
Subject: r1962 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920072256.795751EC21C@projects.linpro.no>
Author: phk
Date: 2007-09-20 09:22:56 +0200 (Thu, 20 Sep 2007)
New Revision: 1962
Modified:
trunk/varnish-cache/bin/varnishd/cache_backend.c
trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
Log:
Make init an optional method for backends
Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-20 07:19:34 UTC (rev 1961)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-20 07:22:56 UTC (rev 1962)
@@ -249,12 +249,22 @@
/*--------------------------------------------------------------------*/
+static void
+VBE_AddBackendMethod(struct backend_method *bem)
+{
+
+ if (bem->init != NULL)
+ bem->init();
+}
+
+/*--------------------------------------------------------------------*/
+
void
VBE_Init(void)
{
MTX_INIT(&VBE_mtx);
- backend_method_simple.init();
- backend_method_random.init();
- backend_method_round_robin.init();
+ VBE_AddBackendMethod(&backend_method_simple);
+ VBE_AddBackendMethod(&backend_method_random);
+ VBE_AddBackendMethod(&backend_method_round_robin);
}
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-20 07:19:34 UTC (rev 1961)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-20 07:22:56 UTC (rev 1962)
@@ -347,14 +347,6 @@
/*--------------------------------------------------------------------*/
-static void
-bes_Init(void)
-{
-
-}
-
-/*--------------------------------------------------------------------*/
-
struct backend_method backend_method_simple = {
.name = "simple",
.getfd = bes_GetFd,
@@ -362,7 +354,6 @@
.recycle = bes_RecycleFd,
.gethostname = bes_GetHostname,
.cleanup = bes_Cleanup,
- .init = bes_Init
};
/*--------------------------------------------------------------------*/
From phk at projects.linpro.no Thu Sep 20 08:14:40 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 10:14:40 +0200 (CEST)
Subject: r1963 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920081440.4BA391EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-20 10:14:40 +0200 (Thu, 20 Sep 2007)
New Revision: 1963
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_backend.c
Log:
Add a VBE_TryConnect() which tries to connected to a given backend+addrinfo
combination. This will be necessary in most if not all backend methods,
so it should be generic.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-20 07:22:56 UTC (rev 1962)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-20 08:14:40 UTC (rev 1963)
@@ -68,6 +68,7 @@
struct object;
struct objhead;
struct workreq;
+struct addrinfo;
/*--------------------------------------------------------------------*/
@@ -399,6 +400,7 @@
struct vbe_conn *VBE_NewConn(void);
void VBE_ReleaseConn(struct vbe_conn *);
void VBE_UpdateHealth(struct sess *sp, struct vbe_conn *, int);
+int VBE_TryConnect(struct sess *sp, struct addrinfo *ai);
/* cache_backend_simple.c */
extern struct backend_method backend_method_simple;
Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-20 07:22:56 UTC (rev 1962)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-20 08:14:40 UTC (rev 1963)
@@ -33,8 +33,12 @@
*/
#include
+#include
#include
+#include
+#include
+
#include "heritage.h"
#include "shmlog.h"
#include "cache.h"
@@ -46,7 +50,65 @@
struct backendlist backendlist = TAILQ_HEAD_INITIALIZER(backendlist);
+
/*--------------------------------------------------------------------
+ * Attempt to connect to a given addrinfo entry.
+ *
+ * Must be called with locked backend, but will release the backend
+ * lock during the slow/sleeping stuff, so that other worker threads
+ * can have a go, while we ponder.
+ *
+ */
+
+int
+VBE_TryConnect(struct sess *sp, struct addrinfo *ai)
+{
+ struct sockaddr_storage ss;
+ int fam, sockt, proto;
+ socklen_t alen;
+ int s;
+ char abuf1[TCP_ADDRBUFSIZE], abuf2[TCP_ADDRBUFSIZE];
+ char pbuf1[TCP_PORTBUFSIZE], pbuf2[TCP_PORTBUFSIZE];
+
+ /*
+ * ai is only valid with the lock held, so copy out the bits
+ * we need to make the connection
+ */
+ fam = ai->ai_family;
+ sockt = ai->ai_socktype;
+ proto = ai->ai_protocol;
+ alen = ai->ai_addrlen;
+ assert(alen <= sizeof ss);
+ memcpy(&ss, ai->ai_addr, alen);
+
+ /* release lock during stuff that can take a long time */
+ UNLOCK(&sp->backend->mtx);
+
+ s = socket(fam, sockt, proto);
+ if (s < 0) {
+ LOCK(&sp->backend->mtx);
+ return (s);
+ }
+
+ if (connect(s, (void *)&ss, alen) != 0) {
+ close(s);
+ LOCK(&sp->backend->mtx);
+ return (-1);
+ }
+
+ TCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1);
+ TCP_name((void*)&ss, alen,
+ abuf2, sizeof abuf2, pbuf2, sizeof pbuf2);
+ WSL(sp->wrk, SLT_BackendOpen, s, "%s %s %s %s %s",
+ sp->backend->vcl_name, abuf1, pbuf1, abuf2, pbuf2);
+
+ LOCK(&sp->backend->mtx);
+ return (s);
+}
+
+
+
+/*--------------------------------------------------------------------
* Get a http structure for talking to the backend.
*/
From phk at projects.linpro.no Thu Sep 20 08:16:02 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 10:16:02 +0200 (CEST)
Subject: r1964 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920081602.59F671EC21C@projects.linpro.no>
Author: phk
Date: 2007-09-20 10:16:01 +0200 (Thu, 20 Sep 2007)
New Revision: 1964
Modified:
trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
Log:
Go over the simple backend and make it more readable.
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-20 08:14:40 UTC (rev 1963)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-20 08:16:01 UTC (rev 1964)
@@ -28,10 +28,6 @@
*
* $Id$
*
- *
- * XXX: When we switch VCL we can have vbe_conn's dangling from
- * XXX: the backends no longer used. When the VCL's refcount
- * XXX: drops to zero we should zap them.
*/
#include
@@ -62,75 +58,106 @@
TAILQ_HEAD(, vbe_conn) connlist;
};
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Try to get a socket connected to one of the addresses on the list.
+ * We start from the cached "last good" address and try all items on
+ * the list exactly once.
+ * If a new DNS lookup is made while we try, we start over and try the
+ * new list exactly once.
+ */
-
static int
bes_conn_try_list(struct sess *sp, struct bes *bes)
{
struct addrinfo *ai, *from;
- struct sockaddr_storage ss;
- int fam, sockt, proto;
- socklen_t alen;
int s, loops;
- char abuf1[TCP_ADDRBUFSIZE], abuf2[TCP_ADDRBUFSIZE];
- char pbuf1[TCP_PORTBUFSIZE], pbuf2[TCP_PORTBUFSIZE];
unsigned myseq;
+ CHECK_OBJ_NOTNULL(bes, BES_MAGIC);
+ if (bes->addr == NULL)
+ return (-1);
+ AN(bes->last_addr);
+
/* Called with lock held */
myseq = bes->dnsseq;
loops = 0;
- from = bes->last_addr;
- for (ai = from; ai != NULL && (loops != 1 || ai != from);) {
- fam = ai->ai_family;
- sockt = ai->ai_socktype;
- proto = ai->ai_protocol;
- alen = ai->ai_addrlen;
- assert(alen <= sizeof ss);
- memcpy(&ss, ai->ai_addr, alen);
- UNLOCK(&sp->backend->mtx);
- s = socket(fam, sockt, proto);
- if (s >= 0 && connect(s, (void *)&ss, alen)) {
- AZ(close(s));
- s = -1;
- }
- if (s >= 0) {
- TCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1);
- TCP_name((void*)&ss, alen,
- abuf2, sizeof abuf2, pbuf2, sizeof pbuf2);
- WSL(sp->wrk, SLT_BackendOpen, s, "%s %s %s %s %s",
- sp->backend->vcl_name, abuf1, pbuf1, abuf2, pbuf2);
- }
- LOCK(&sp->backend->mtx);
- if (s >= 0) {
+ ai = from = bes->last_addr;
+ while (1) {
+
+ /* NB: releases/acquires lock */
+ s = VBE_TryConnect(sp, ai);
+
+ if (s >= 0) {
+ /* Update cached "last good" if still valid */
if (myseq == bes->dnsseq)
bes->last_addr = ai;
return (s);
}
+
if (myseq != bes->dnsseq) {
+ /* A DNS-lookup happended, try again from start */
loops = 0;
from = bes->last_addr;
ai = from;
} else {
+ /* Try next one */
ai = ai->ai_next;
if (ai == NULL) {
loops++;
ai = bes->addr;
}
}
+ if (loops == 1 && ai == from)
+ return (-1);
}
- return (-1);
}
/*--------------------------------------------------------------------*/
+static const char *
+bes_dns_lookup(struct backend *bp)
+{
+ struct addrinfo *res, hint, *old;
+ struct bes *bes;
+ int error;
+
+ CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
+ CAST_OBJ_NOTNULL(bes, bp->priv, BES_MAGIC);
+
+ bes->dnstime = TIM_mono();
+
+ /* Let go of lock while we do sleepable stuff */
+ UNLOCK(&bp->mtx);
+
+ memset(&hint, 0, sizeof hint);
+ hint.ai_family = PF_UNSPEC;
+ hint.ai_socktype = SOCK_STREAM;
+ res = NULL;
+ error = getaddrinfo(bes->hostname,
+ bes->portname == NULL ? "http" : bes->portname,
+ &hint, &res);
+ LOCK(&bp->mtx);
+ if (error) {
+ if (res != NULL)
+ freeaddrinfo(res);
+ return(gai_strerror(error));
+ }
+ bes->dnsseq++;
+ old = bes->addr;
+ bes->last_addr = res;
+ bes->addr = res;
+ if (old != NULL)
+ freeaddrinfo(old);
+ return (NULL);
+}
+
+/*--------------------------------------------------------------------*/
+
static int
bes_conn_try(struct sess *sp, struct backend *bp)
{
int s;
struct bes *bes;
- struct addrinfo *res, hint, *old;
- int error;
CAST_OBJ_NOTNULL(bes, bp->priv, BES_MAGIC);
@@ -148,32 +175,8 @@
return (-1);
}
- /* Then do another lookup to catch DNS changes */
- bes->dnstime = TIM_mono();
- UNLOCK(&bp->mtx);
+ (void)bes_dns_lookup(bp);
- memset(&hint, 0, sizeof hint);
- hint.ai_family = PF_UNSPEC;
- hint.ai_socktype = SOCK_STREAM;
- res = NULL;
- error = getaddrinfo(bes->hostname,
- bes->portname == NULL ? "http" : bes->portname,
- &hint, &res);
- if (error) {
- if (res != NULL)
- freeaddrinfo(res);
- printf("getaddrinfo: %s\n", gai_strerror(error)); /* XXX */
- LOCK(&bp->mtx);
- } else {
- LOCK(&bp->mtx);
- bes->dnsseq++;
- old = bes->addr;
- bes->last_addr = res;
- bes->addr = res;
- if (old != NULL)
- freeaddrinfo(old);
- }
-
/* And try the entire list */
s = bes_conn_try_list(sp, bes);
if (s >= 0) {
@@ -363,6 +366,7 @@
{
struct backend *b;
struct bes *bes;
+ const char *p;
/*
* Scan existing backends to see if we can recycle one of them.
@@ -402,5 +406,16 @@
AN(t->host);
REPLACE(bes->hostname, t->host);
+ /*
+ * The VCL compiler already did a lookup, but we'll do another one
+ * here, just in case...
+ */
+ LOCK(&b->mtx);
+ p = bes_dns_lookup(b);
+ UNLOCK(&b->mtx);
+ if (p != NULL)
+ printf("Warning: could not lookup backend %s (%s:%s): %s",
+ t->name, t->host, t->port, p);
+
*bp = b;
}
From phk at projects.linpro.no Thu Sep 20 08:22:59 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 10:22:59 +0200 (CEST)
Subject: r1965 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920082259.32DE91EC2B2@projects.linpro.no>
Author: phk
Date: 2007-09-20 10:22:59 +0200 (Thu, 20 Sep 2007)
New Revision: 1965
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_backend.c
Log:
Add a convenience function more for backend methods:
VBE_CheckFd(): Check that a filedescriptor is reusable.
Right now we simply poll it with a zero timeout, and if there are
any events, we can't reuse it.
This check may need refinement down the road.
One option would be to attempt to write a CRNL onto the fd and see
that it works.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-20 08:16:01 UTC (rev 1964)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-20 08:22:59 UTC (rev 1965)
@@ -400,7 +400,10 @@
struct vbe_conn *VBE_NewConn(void);
void VBE_ReleaseConn(struct vbe_conn *);
void VBE_UpdateHealth(struct sess *sp, struct vbe_conn *, int);
+
+/* convenience functions for backend methods */
int VBE_TryConnect(struct sess *sp, struct addrinfo *ai);
+int VBE_CheckFd(int fd);
/* cache_backend_simple.c */
extern struct backend_method backend_method_simple;
Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-20 08:16:01 UTC (rev 1964)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-20 08:22:59 UTC (rev 1965)
@@ -35,6 +35,7 @@
#include
#include
#include
+#include
#include
#include
@@ -106,8 +107,23 @@
return (s);
}
+/*--------------------------------------------------------------------
+ * Check that there is still something at the far end of a given fd.
+ * We poll the fd with instant timeout, if there are any events we can't
+ * use it (backends are not allowed to pipeline).
+ */
+int
+VBE_CheckFd(int fd)
+{
+ struct pollfd pfd;
+ pfd.fd = fd;
+ pfd.events = POLLIN;
+ pfd.revents = 0;
+ return(poll(&pfd, 1, 0) == 0);
+}
+
/*--------------------------------------------------------------------
* Get a http structure for talking to the backend.
*/
From phk at projects.linpro.no Thu Sep 20 08:23:21 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 10:23:21 +0200 (CEST)
Subject: r1966 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920082321.8DFC41EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-20 10:23:21 +0200 (Thu, 20 Sep 2007)
New Revision: 1966
Modified:
trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
Log:
Use VBE_CheckFd() convenience function
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-20 08:22:59 UTC (rev 1965)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-20 08:23:21 UTC (rev 1966)
@@ -39,7 +39,6 @@
#include
#include
#include
-#include
#include "shmlog.h"
#include "cache.h"
@@ -203,7 +202,6 @@
bes_nextfd(struct sess *sp)
{
struct vbe_conn *vc;
- struct pollfd pfd;
struct backend *bp;
int reuse = 0;
struct bes *bes;
@@ -225,11 +223,7 @@
if (vc == NULL)
break;
- /* Test the connection for remote close before we use it */
- pfd.fd = vc->fd;
- pfd.events = POLLIN;
- pfd.revents = 0;
- if (!poll(&pfd, 1, 0)) {
+ if (VBE_CheckFd(vc->fd)) {
/* XXX locking of stats */
VSL_stats->backend_reuse += reuse;
VSL_stats->backend_conn++;
From phk at projects.linpro.no Thu Sep 20 08:44:59 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 10:44:59 +0200 (CEST)
Subject: r1967 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920084459.E14801EC21C@projects.linpro.no>
Author: phk
Date: 2007-09-20 10:44:59 +0200 (Thu, 20 Sep 2007)
New Revision: 1967
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Add a http_GetProto() function
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-20 08:23:21 UTC (rev 1966)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-20 08:44:59 UTC (rev 1967)
@@ -463,6 +463,7 @@
int http_GetHdr(struct http *hp, const char *hdr, char **ptr);
int http_GetHdrField(struct http *hp, const char *hdr, const char *field, char **ptr);
int http_GetStatus(struct http *hp);
+const char *http_GetProto(struct http *hp);
int http_HdrIs(struct http *hp, const char *hdr, const char *val);
int http_GetTail(struct http *hp, unsigned len, char **b, char **e);
int http_Read(struct http *hp, int fd, void *b, unsigned len);
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-20 08:23:21 UTC (rev 1966)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-20 08:44:59 UTC (rev 1967)
@@ -381,6 +381,13 @@
NULL /* XXX */, 10));
}
+const char *
+http_GetProto(struct http *hp)
+{
+ AN(hp->hd[HTTP_HDR_PROTO].b);
+ return (hp->hd[HTTP_HDR_PROTO].b);
+}
+
/*--------------------------------------------------------------------
* Dissect the headers of the HTTP protocol message.
* Detect conditionals (headers which start with '^[Ii][Ff]-')
From phk at projects.linpro.no Thu Sep 20 08:46:25 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 10:46:25 +0200 (CEST)
Subject: r1968 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920084625.C37EA1EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-20 10:46:25 +0200 (Thu, 20 Sep 2007)
New Revision: 1968
Modified:
trunk/varnish-cache/bin/varnishd/cache_fetch.c
Log:
After we moved pass to use the same code as fetch, we have run into
a unnecessary connection timeout wait when the returned object does
not have a body.
Rework the "does this response have a body" logic to be more in line
with the RFC.
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-20 08:44:59 UTC (rev 1967)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-20 08:46:25 UTC (rev 1968)
@@ -260,7 +260,6 @@
struct worker *w;
char *b;
int cls;
- int body = 1; /* XXX */
struct http *hp, *hp2;
struct storage *st;
struct bereq *bereq;
@@ -338,17 +337,31 @@
http_CopyHome(sp->wrk, sp->fd, hp2);
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
- if (body) {
- if (http_GetHdr(hp, H_Content_Length, &b))
- cls = fetch_straight(sp, vc->fd, hp, b);
- else if (http_HdrIs(hp, H_Transfer_Encoding, "chunked"))
- cls = fetch_chunked(sp, vc->fd, hp);
- else
- cls = fetch_eof(sp, vc->fd, hp);
+
+ /* Determine if we have a body or not */
+ cls = 0;
+ if (http_GetHdr(hp, H_Content_Length, &b))
+ cls = fetch_straight(sp, vc->fd, hp, b);
+ else if (http_HdrIs(hp, H_Transfer_Encoding, "chunked"))
+ cls = fetch_chunked(sp, vc->fd, hp);
+ else if (http_GetHdr(hp, H_Transfer_Encoding, &b)) {
+ /* XXX: AUGH! */
+ VSL(SLT_Debug, vc->fd, "Invalid Transfer-Encoding");
+ VBE_ClosedFd(sp->wrk, vc);
+ return (-1);
+ } else if (strcmp(http_GetProto(hp), "HTTP/1.1")) {
+ switch (http_GetStatus(hp)) {
+ case 200:
+ cls = fetch_eof(sp, vc->fd, hp);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (cls > 0)
http_PrintfHeader(sp->wrk, sp->fd, hp2,
"Content-Length: %u", sp->obj->len);
- } else
- cls = 0;
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
if (cls < 0) {
From cecilihf at projects.linpro.no Thu Sep 20 08:58:54 2007
From: cecilihf at projects.linpro.no (cecilihf at projects.linpro.no)
Date: Thu, 20 Sep 2007 10:58:54 +0200 (CEST)
Subject: r1969 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920085854.C02871EC2AE@projects.linpro.no>
Author: cecilihf
Date: 2007-09-20 10:58:54 +0200 (Thu, 20 Sep 2007)
New Revision: 1969
Modified:
trunk/varnish-cache/bin/varnishd/cache_backend_random.c
trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
trunk/varnish-cache/bin/varnishd/cache_response.c
Log:
Added some checks for NULL-pointers.
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-20 08:46:25 UTC (rev 1968)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-20 08:58:54 UTC (rev 1969)
@@ -481,6 +481,7 @@
be = t->bentry;
while (be != NULL) {
bs = calloc(sizeof *bs, 1);
+ XXXAN(bs);
bs->magic = BRSPEC_MAGIC;
AN(be->port);
bs->portname = strdup(be->port);
@@ -506,7 +507,7 @@
bs_prev = bs;
be = be->next;
}
-
+ XXXAN(bs_first);
bs_first->next = bs;
ber->blist = bs;
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-20 08:46:25 UTC (rev 1968)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-20 08:58:54 UTC (rev 1969)
@@ -465,6 +465,7 @@
be = t->bentry;
while (be != NULL) {
bs = calloc(sizeof *bs, 1);
+ XXXAN(bs);
bs->magic = BSPEC_MAGIC;
AN(be->port);
bs->portname = strdup(be->port);
@@ -485,6 +486,7 @@
be = be->next;
}
+ XXXAN(bs_first);
bs_first->next = bs;
brr->blist = bs;
Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2007-09-20 08:46:25 UTC (rev 1968)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2007-09-20 08:58:54 UTC (rev 1969)
@@ -132,6 +132,7 @@
*/
http_Unset(sp->http, H_Date);
time_str = malloc(50);
+ XXXAN(time_str);
sprintf(time_str, "Date: ");
TIM_format(TIM_real(), &(time_str[6]));
http_SetHeader(sp->wrk, sp->fd, sp->http, time_str);
From phk at projects.linpro.no Thu Sep 20 10:44:19 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Thu, 20 Sep 2007 12:44:19 +0200 (CEST)
Subject: r1970 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920104419.1B7381EC21C@projects.linpro.no>
Author: phk
Date: 2007-09-20 12:44:18 +0200 (Thu, 20 Sep 2007)
New Revision: 1970
Modified:
trunk/varnish-cache/bin/varnishd/cache_fetch.c
Log:
Fix a brain-o in my last commit. "cls" is a flag for closing the fd,
not for generating Content-Length: header.
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-20 08:58:54 UTC (rev 1969)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-20 10:44:18 UTC (rev 1970)
@@ -263,7 +263,7 @@
struct http *hp, *hp2;
struct storage *st;
struct bereq *bereq;
- int len;
+ int len, mklen;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
@@ -340,11 +340,14 @@
/* Determine if we have a body or not */
cls = 0;
- if (http_GetHdr(hp, H_Content_Length, &b))
+ mklen = 0;
+ if (http_GetHdr(hp, H_Content_Length, &b)) {
cls = fetch_straight(sp, vc->fd, hp, b);
- else if (http_HdrIs(hp, H_Transfer_Encoding, "chunked"))
+ mklen = 1;
+ } else if (http_HdrIs(hp, H_Transfer_Encoding, "chunked")) {
cls = fetch_chunked(sp, vc->fd, hp);
- else if (http_GetHdr(hp, H_Transfer_Encoding, &b)) {
+ mklen = 1;
+ } else if (http_GetHdr(hp, H_Transfer_Encoding, &b)) {
/* XXX: AUGH! */
VSL(SLT_Debug, vc->fd, "Invalid Transfer-Encoding");
VBE_ClosedFd(sp->wrk, vc);
@@ -353,13 +356,14 @@
switch (http_GetStatus(hp)) {
case 200:
cls = fetch_eof(sp, vc->fd, hp);
+ mklen = 1;
break;
default:
break;
}
}
- if (cls > 0)
+ if (mklen > 0)
http_PrintfHeader(sp->wrk, sp->fd, hp2,
"Content-Length: %u", sp->obj->len);
From phk at projects.linpro.no Thu Sep 20 22:25:27 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 21 Sep 2007 00:25:27 +0200 (CEST)
Subject: r1971 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070920222527.B4E6D1EC290@projects.linpro.no>
Author: phk
Date: 2007-09-21 00:25:27 +0200 (Fri, 21 Sep 2007)
New Revision: 1971
Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
Don't core dump if VCL tries to compare NULL pointers, just let the
comparison fail. This typically happens if a paticular header is
not present.
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-20 10:44:18 UTC (rev 1970)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-20 22:25:27 UTC (rev 1971)
@@ -508,6 +508,8 @@
int
VRT_strcmp(const char *s1, const char *s2)
{
+ if (s1 == NULL || s2 == NULL)
+ return(1);
return (strcmp(s1, s2));
}
From phk at projects.linpro.no Thu Sep 20 22:26:31 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 21 Sep 2007 00:26:31 +0200 (CEST)
Subject: r1972 - trunk/varnish-cache/lib/libvcl
Message-ID: <20070920222631.52C061EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-21 00:26:31 +0200 (Fri, 21 Sep 2007)
New Revision: 1972
Modified:
trunk/varnish-cache/lib/libvcl/vcc_compile.c
Log:
Avoid a double free when we encounter a 'include' directive.
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c 2007-09-20 22:25:27 UTC (rev 1971)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c 2007-09-20 22:26:31 UTC (rev 1972)
@@ -461,9 +461,6 @@
TAILQ_REMOVE(&tl->tokens, t, list);
TAILQ_REMOVE(&tl->tokens, t1, list);
TAILQ_REMOVE(&tl->tokens, t2, list);
- vcc_FreeToken(t);
- vcc_FreeToken(t1);
- vcc_FreeToken(t2);
if (!tl->err)
vcc_resolve_includes(tl);
return;
From phk at projects.linpro.no Thu Sep 20 22:26:53 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 21 Sep 2007 00:26:53 +0200 (CEST)
Subject: r1973 - trunk/varnish-cache/lib/libvcl
Message-ID: <20070920222653.CF6201EC290@projects.linpro.no>
Author: phk
Date: 2007-09-21 00:26:53 +0200 (Fri, 21 Sep 2007)
New Revision: 1973
Modified:
trunk/varnish-cache/lib/libvcl/vcc_token.c
Log:
vcc_FreeToken() is no longer necessary
Modified: trunk/varnish-cache/lib/libvcl/vcc_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_token.c 2007-09-20 22:26:31 UTC (rev 1972)
+++ trunk/varnish-cache/lib/libvcl/vcc_token.c 2007-09-20 22:26:53 UTC (rev 1973)
@@ -275,19 +275,6 @@
}
/*--------------------------------------------------------------------
- * Free a token
- */
-
-void
-vcc_FreeToken(struct token *t)
-{
-
- if (t->dec != NULL)
- free(t->dec);
- free(t);
-}
-
-/*--------------------------------------------------------------------
* Lexical analysis and token generation
*/
From phk at projects.linpro.no Thu Sep 20 22:27:26 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 21 Sep 2007 00:27:26 +0200 (CEST)
Subject: r1974 - trunk/varnish-cache/lib/libvcl
Message-ID: <20070920222726.203C81EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-21 00:27:25 +0200 (Fri, 21 Sep 2007)
New Revision: 1974
Modified:
trunk/varnish-cache/lib/libvcl/vcc_compile.h
Log:
Fix an extremely fine C-standard point and remove the vcc_FreeToken()
prototype
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h 2007-09-20 22:26:53 UTC (rev 1973)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h 2007-09-20 22:27:25 UTC (rev 1974)
@@ -103,6 +103,12 @@
SET
};
+enum var_access {
+ V_RO,
+ V_RW,
+ V_WO
+};
+
enum ref_type {
R_FUNC,
R_ACL,
@@ -123,7 +129,7 @@
unsigned len;
const char *rname;
const char *lname;
- enum {V_RO, V_RW, V_WO} access;
+ enum var_access access;
const char *hdr;
unsigned methods;
};
@@ -187,7 +193,6 @@
void vcc_NextToken(struct tokenlist *tl);
void vcc__ErrInternal(struct tokenlist *tl, const char *func, unsigned line);
void vcc_AddToken(struct tokenlist *tl, unsigned tok, const char *b, const char *e);
-void vcc_FreeToken(struct token *t);
/* vcc_var.c */
struct var *vcc_FindVar(struct tokenlist *tl, const struct token *t, struct var *vl);
From phk at projects.linpro.no Fri Sep 21 08:16:02 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 21 Sep 2007 10:16:02 +0200 (CEST)
Subject: r1975 - trunk/varnish-cache/lib/libvcl
Message-ID: <20070921081602.C9CBA1EC290@projects.linpro.no>
Author: phk
Date: 2007-09-21 10:16:02 +0200 (Fri, 21 Sep 2007)
New Revision: 1975
Modified:
trunk/varnish-cache/lib/libvcl/vcc_backend.c
trunk/varnish-cache/lib/libvcl/vcc_xref.c
Log:
Move implicit reference to first backend to the xref code.
Don't panic if no backend.port is specified.
Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2007-09-20 22:27:25 UTC (rev 1974)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2007-09-21 08:16:02 UTC (rev 1975)
@@ -71,12 +71,6 @@
ExpectErr(tl, ID);
t_be = tl->t;
vcc_AddDef(tl, tl->t, R_BACKEND);
- /*
- * The first backend is always referenced because that is the default
- * at the beginning of vcl_recv
- */
- if (tl->nbackend == 0)
- vcc_AddRef(tl, tl->t, R_BACKEND);
/* In the compiled vcl we use these macros to refer to backends */
Fh(tl, 1, "#define VGC_backend_%.*s (VCL_conf.backend[%d])\n",
@@ -153,7 +147,10 @@
Fc(tl, 0, "\nstatic struct vrt_simple_backend sbe_%.*s = {\n",
PF(t_be));
Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(t_be));
- Fc(tl, 0, "\t.port = %.*s,\n", PF(t_port));
+ if (t_port != NULL)
+ Fc(tl, 0, "\t.port = %.*s,\n", PF(t_port));
+ else
+ Fc(tl, 0, "\t.port = \"http\",\n");
Fc(tl, 0, "\t.host = %.*s,\n", PF(t_host));
Fc(tl, 0, "};\n");
Fi(tl, 0, "\tVRT_init_simple_backend(&VGC_backend_%.*s , &sbe_%.*s);\n",
@@ -180,12 +177,6 @@
ExpectErr(tl, ID);
t_be = tl->t;
vcc_AddDef(tl, tl->t, R_BACKEND);
- /*
- * The first backend is always referenced because that is the default
- * at the beginning of vcl_recv
- */
- if (tl->nbackend == 0)
- vcc_AddRef(tl, tl->t, R_BACKEND);
/* In the compiled vcl we use these macros to refer to backends */
Fh(tl, 1, "#define VGC_backend_%.*s (VCL_conf.backend[%d])\n",
Modified: trunk/varnish-cache/lib/libvcl/vcc_xref.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_xref.c 2007-09-20 22:27:25 UTC (rev 1974)
+++ trunk/varnish-cache/lib/libvcl/vcc_xref.c 2007-09-21 08:16:02 UTC (rev 1975)
@@ -139,6 +139,10 @@
}
r->defcnt++;
r->name = t;
+
+ /* The first backend is the default and thus has an implicit ref */
+ if (type == R_BACKEND && tl->nbackend == 0)
+ r->refcnt++;
}
/*--------------------------------------------------------------------*/
From phk at projects.linpro.no Fri Sep 21 09:49:05 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 21 Sep 2007 11:49:05 +0200 (CEST)
Subject: r1976 - trunk/varnish-cache/include
Message-ID: <20070921094905.B55ED1EC290@projects.linpro.no>
Author: phk
Date: 2007-09-21 11:49:05 +0200 (Fri, 21 Sep 2007)
New Revision: 1976
Modified:
trunk/varnish-cache/include/http_headers.h
Log:
Don't copy the Date: header from the object to the reply
Modified: trunk/varnish-cache/include/http_headers.h
===================================================================
--- trunk/varnish-cache/include/http_headers.h 2007-09-21 08:16:02 UTC (rev 1975)
+++ trunk/varnish-cache/include/http_headers.h 2007-09-21 09:49:05 UTC (rev 1976)
@@ -32,7 +32,7 @@
* b session field name
* c Request(1)/Response(2) bitfield
* d (obsolete)
- * e Supress header in pass from client to backend
+ * e Supress header in filter ops
* f unused
* g unused
*
@@ -70,7 +70,7 @@
HTTPH("Content-MD5", H_Content_MD5, 2, 0, 0, 0, 0) /* RFC2616 14.15 */
HTTPH("Content-Range", H_Content_Range, 2, 3, HTTPH_R_PASS|HTTPH_A_PASS|HTTPH_R_FETCH|HTTPH_A_INS, 0, 0) /* RFC2616 14.16 */
HTTPH("Content-Type", H_Content_Type, 2, 0, 0, 0, 0) /* RFC2616 14.17 */
-HTTPH("Date", H_Date, 2, 0, 0, 0, 0) /* RFC2616 14.18 */
+HTTPH("Date", H_Date, 2, 0, HTTPH_A_DELIVER, 0, 0) /* RFC2616 14.18 */
HTTPH("ETag", H_ETag, 2, 0, 0, 0, 0) /* RFC2616 14.19 */
HTTPH("Expect", H_Expect, 1, 0, 0, 0, 0) /* RFC2616 14.20 */
HTTPH("Expires", H_Expires, 2, 0, 0, 0, 0) /* RFC2616 14.21 */
From phk at projects.linpro.no Fri Sep 21 09:49:44 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 21 Sep 2007 11:49:44 +0200 (CEST)
Subject: r1977 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070921094944.376041EC2B0@projects.linpro.no>
Author: phk
Date: 2007-09-21 11:49:44 +0200 (Fri, 21 Sep 2007)
New Revision: 1977
Modified:
trunk/varnish-cache/bin/varnishd/cache_response.c
Log:
Don't leak 50 bytes when creating the new Date: header.
Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2007-09-21 09:49:05 UTC (rev 1976)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2007-09-21 09:49:44 UTC (rev 1977)
@@ -111,7 +111,7 @@
void
RES_BuildHttp(struct sess *sp)
{
- char *time_str;
+ char time_str[30];
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -126,16 +126,8 @@
http_FilterFields(sp->wrk, sp->fd, sp->http, &sp->obj->http,
HTTPH_A_DELIVER);
- /* Replace Date header with current date instead of keeping the date
- * originally given by the backend when the object was fetched (which
- * could be a long time ago).
- */
- http_Unset(sp->http, H_Date);
- time_str = malloc(50);
- XXXAN(time_str);
- sprintf(time_str, "Date: ");
- TIM_format(TIM_real(), &(time_str[6]));
- http_SetHeader(sp->wrk, sp->fd, sp->http, time_str);
+ TIM_format(TIM_real(), time_str);
+ http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Date: %s", time_str);
if (sp->xid != sp->obj->xid)
http_PrintfHeader(sp->wrk, sp->fd, sp->http,
From phk at projects.linpro.no Fri Sep 21 10:38:01 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 21 Sep 2007 12:38:01 +0200 (CEST)
Subject: r1978 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070921103801.6AE771EC290@projects.linpro.no>
Author: phk
Date: 2007-09-21 12:38:01 +0200 (Fri, 21 Sep 2007)
New Revision: 1978
Modified:
trunk/varnish-cache/bin/varnishd/cache_center.c
Log:
A temporary work-around for #161
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-21 09:49:44 UTC (rev 1977)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-21 10:38:01 UTC (rev 1978)
@@ -429,6 +429,7 @@
/* Experimental. Reduce health parameter of backend towards zero
* if it has been more than a minute since it was checked. */
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
+if (0) {
time_diff = TIM_mono() - sp->backend->last_check;
minutes = time_diff / 60;
if (minutes > sp->backend->minute_limit) {
@@ -436,6 +437,7 @@
sp->backend->health = (int)((double)sp->backend->health / 2);
VBE_UpdateHealth(sp, NULL, 0);
}
+}
VCL_hit_method(sp);
From phk at projects.linpro.no Fri Sep 21 13:18:10 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 21 Sep 2007 15:18:10 +0200 (CEST)
Subject: r1979 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070921131810.EAA8C1EC2B2@projects.linpro.no>
Author: phk
Date: 2007-09-21 15:18:10 +0200 (Fri, 21 Sep 2007)
New Revision: 1979
Modified:
trunk/varnish-cache/bin/varnishd/heritage.h
trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
Add an experimental runtime parameter for the lru_timeout.
Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h 2007-09-21 10:38:01 UTC (rev 1978)
+++ trunk/varnish-cache/bin/varnishd/heritage.h 2007-09-21 13:18:10 UTC (rev 1979)
@@ -120,6 +120,9 @@
/* Ping interval */
unsigned ping_interval;
+ /* LRU list ordering interval */
+ unsigned lru_timeout;
+
};
extern volatile struct params *params;
Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-09-21 10:38:01 UTC (rev 1978)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-09-21 13:18:10 UTC (rev 1979)
@@ -328,6 +328,15 @@
/*--------------------------------------------------------------------*/
static void
+tweak_lru_timeout(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_timeout(cli, &master.lru_timeout, arg);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
tweak_auto_restart(struct cli *cli, struct parspec *par, const char *arg)
{
@@ -716,6 +725,14 @@
"it possible to attach a debugger to the child.\n"
MUST_RESTART,
"3", "seconds" },
+ { "lru_interval", tweak_lru_timeout,
+ "Grace period before object moves on LRU list.\n"
+ "Objects are only moved to the front of the LRU "
+ "list if they have not been moved there already inside "
+ "this timeout period. This reduces the amount of lock "
+ "operations necessary for LRU list access.\n"
+ EXPERIMENTAL,
+ "2", "seconds" },
{ "cc_command", tweak_cc_command,
"Command used for compiling the C source code to a "
"dlopen(3) loadable object.\n"
From phk at projects.linpro.no Sun Sep 23 12:39:28 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 23 Sep 2007 14:39:28 +0200 (CEST)
Subject: r1980 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070923123928.5DEA31EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-23 14:39:27 +0200 (Sun, 23 Sep 2007)
New Revision: 1980
Modified:
trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
Polish while reading review.
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-21 13:18:10 UTC (rev 1979)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-23 12:39:27 UTC (rev 1980)
@@ -183,7 +183,6 @@
struct workreq *wrq;
AN(w->wrq);
- w->used = NAN;
wrq = w->wrq;
CHECK_OBJ_NOTNULL(wrq->sess, SESS_MAGIC);
wrq->sess->wrk = w;
@@ -191,12 +190,13 @@
CHECK_OBJ(w->nobj, OBJECT_MAGIC);
if (w->nobjhead != NULL)
CHECK_OBJ(w->nobjhead, OBJHEAD_MAGIC);
+ w->used = NAN;
CNT_Session(wrq->sess);
+ assert(!isnan(w->used));
if (w->nobj != NULL)
CHECK_OBJ(w->nobj, OBJECT_MAGIC);
if (w->nobjhead != NULL)
CHECK_OBJ(w->nobjhead, OBJHEAD_MAGIC);
- assert(!isnan(w->used));
w->wrq = NULL;
}
@@ -220,48 +220,47 @@
LOCK(&tmtx);
VSL_stats->n_wrk_create++;
UNLOCK(&tmtx);
+
while (1) {
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
+ assert(!isnan(w->used));
+ LOCK(&tmtx);
+
/* Process overflow requests, if any */
w->wrq = TAILQ_FIRST(&overflow);
if (w->wrq != NULL) {
- LOCK(&tmtx);
- w->wrq = TAILQ_FIRST(&overflow);
- if (w->wrq != NULL) {
- VSL_stats->n_wrk_queue--;
- TAILQ_REMOVE(&overflow, w->wrq, list);
- UNLOCK(&tmtx);
- wrk_do_one(w);
- continue;
- }
- UNLOCK(&tmtx);
+ VSL_stats->n_wrk_queue--;
+ TAILQ_REMOVE(&overflow, w->wrq, list);
+ } else {
+ TAILQ_INSERT_HEAD(&qp->idle, w, list);
}
- LOCK(&qp->mtx);
- TAILQ_INSERT_HEAD(&qp->idle, w, list);
- assert(!isnan(w->used));
UNLOCK(&qp->mtx);
- assert(1 == read(w->pipe[0], &c, 1));
+
if (w->wrq == NULL)
+ assert(1 == read(w->pipe[0], &c, 1));
+ if (w->wrq == NULL)
break;
wrk_do_one(w);
}
+
LOCK(&tmtx);
VSL_stats->n_wrk--;
qp->nwrk--;
UNLOCK(&tmtx);
+
VSL(SLT_WorkThread, 0, "%p end", w);
if (w->vcl != NULL)
VCL_Rel(&w->vcl);
- close(w->pipe[0]);
- close(w->pipe[1]);
+ AZ(close(w->pipe[0]));
+ AZ(close(w->pipe[1]));
if (w->srcaddr != NULL)
free(w->srcaddr);
if (w->nobjhead != NULL)
- free(w->nobjhead);
+ FREE_OBJ(w->nobjhead);
if (w->nobj!= NULL)
- free(w->nobj);
+ FREE_OBJ(w->nobj);
return (NULL);
}
From phk at projects.linpro.no Sun Sep 23 12:44:13 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 23 Sep 2007 14:44:13 +0200 (CEST)
Subject: r1981 - trunk/varnish-cache/include
Message-ID: <20070923124413.277191EC2B1@projects.linpro.no>
Author: phk
Date: 2007-09-23 14:44:12 +0200 (Sun, 23 Sep 2007)
New Revision: 1981
Modified:
trunk/varnish-cache/include/miniobj.h
Log:
Add CHECK_OBJ_ORNULL() macro
Modified: trunk/varnish-cache/include/miniobj.h
===================================================================
--- trunk/varnish-cache/include/miniobj.h 2007-09-23 12:39:27 UTC (rev 1980)
+++ trunk/varnish-cache/include/miniobj.h 2007-09-23 12:44:12 UTC (rev 1981)
@@ -23,6 +23,12 @@
assert((ptr)->magic == type_magic); \
} while (0)
+#define CHECK_OBJ_ORNULL(ptr, type_magic) \
+ do { \
+ if ((ptr) != NULL) \
+ assert((ptr)->magic == type_magic); \
+ } while (0)
+
#define CAST_OBJ(to, from, type_magic) \
do { \
(to) = (from); \
From phk at projects.linpro.no Sun Sep 23 12:46:19 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 23 Sep 2007 14:46:19 +0200 (CEST)
Subject: r1982 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070923124619.B27871EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-23 14:46:19 +0200 (Sun, 23 Sep 2007)
New Revision: 1982
Modified:
trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
Use CHECK_OBJ_ORNULL() macro
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-23 12:44:12 UTC (rev 1981)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-23 12:46:19 UTC (rev 1982)
@@ -186,17 +186,13 @@
wrq = w->wrq;
CHECK_OBJ_NOTNULL(wrq->sess, SESS_MAGIC);
wrq->sess->wrk = w;
- if (w->nobj != NULL)
- CHECK_OBJ(w->nobj, OBJECT_MAGIC);
- if (w->nobjhead != NULL)
- CHECK_OBJ(w->nobjhead, OBJHEAD_MAGIC);
+ CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC);
+ CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
w->used = NAN;
CNT_Session(wrq->sess);
assert(!isnan(w->used));
- if (w->nobj != NULL)
- CHECK_OBJ(w->nobj, OBJECT_MAGIC);
- if (w->nobjhead != NULL)
- CHECK_OBJ(w->nobjhead, OBJHEAD_MAGIC);
+ CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC);
+ CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
w->wrq = NULL;
}
From phk at projects.linpro.no Sun Sep 23 12:46:52 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 23 Sep 2007 14:46:52 +0200 (CEST)
Subject: r1983 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070923124652.3DF0F1EC405@projects.linpro.no>
Author: phk
Date: 2007-09-23 14:46:52 +0200 (Sun, 23 Sep 2007)
New Revision: 1983
Modified:
trunk/varnish-cache/bin/varnishd/cache_center.c
Log:
Polish, including use of CHECK_OBJ_ORNULL()
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-23 12:46:19 UTC (rev 1982)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-23 12:46:52 UTC (rev 1983)
@@ -511,13 +511,14 @@
p = WS_Alloc(sp->http->ws,
sizeof(const char *) * (sp->nhashptr + 1));
XXXAN(p);
+ /* Align pointer properly (?) */
u = (uintptr_t)p;
u &= sizeof(const char *) - 1;
if (u)
p += sizeof(const char *) - u;
sp->hashptr = (void*)p;
- VCL_hash_method(sp); /* XXX: no-op for now */
+ VCL_hash_method(sp);
/* XXX check error */
}
@@ -818,15 +819,11 @@
* pointers still pointing to the things we expect.
*/
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- if (sp->obj != NULL)
- CHECK_OBJ(sp->obj, OBJECT_MAGIC);
+ CHECK_OBJ_ORNULL(sp->obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
- if (w->nobj != NULL)
- CHECK_OBJ(w->nobj, OBJECT_MAGIC);
- if (w->nobjhead != NULL)
- CHECK_OBJ(w->nobjhead, OBJHEAD_MAGIC);
- if (sp->backend != NULL)
- CHECK_OBJ(sp->backend, BACKEND_MAGIC);
+ CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC);
+ CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
+ CHECK_OBJ_ORNULL(sp->backend, BACKEND_MAGIC);
switch (sp->step) {
#define STEP(l,u) case STP_##u: done = cnt_##l(sp); break;
@@ -834,10 +831,8 @@
#undef STEP
default: INCOMPL();
}
- if (w->nobj != NULL)
- CHECK_OBJ(w->nobj, OBJECT_MAGIC);
- if (w->nobjhead != NULL)
- CHECK_OBJ(w->nobjhead, OBJHEAD_MAGIC);
+ CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC);
+ CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
}
assert(!isnan(w->used));
WSL_Flush(w);
From des at projects.linpro.no Sun Sep 23 13:01:21 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:01:21 +0200 (CEST)
Subject: r1984 - in branches/1.1: . bin/varnishd
Message-ID: <20070923130121.5F0ED1EC2AE@projects.linpro.no>
Author: des
Date: 2007-09-23 15:01:21 +0200 (Sun, 23 Sep 2007)
New Revision: 1984
Modified:
branches/1.1/
branches/1.1/bin/varnishd/mgt_param.c
Log:
Merged revisions 1796 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1796 | phk | 2007-08-05 21:52:23 +0200 (Sun, 05 Aug 2007) | 2 lines
Introduce a "replace()" function to replace a malloc'ed string.
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1795,1797-1798,1800-1808,1810-1815,1817,1819,1823,1831-1838,1846,1853-1855,1857-1859,1862,1865,1867-1868,1871,1873-1880,1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1831-1838,1846,1853-1855,1857-1859,1862,1865,1867-1868,1871,1873-1880,1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
Modified: branches/1.1/bin/varnishd/mgt_param.c
===================================================================
--- branches/1.1/bin/varnishd/mgt_param.c 2007-09-23 12:46:52 UTC (rev 1983)
+++ branches/1.1/bin/varnishd/mgt_param.c 2007-09-23 13:01:21 UTC (rev 1984)
@@ -67,6 +67,18 @@
static struct params master;
+/* XXX: Far too generic to live here ? */
+static void
+replace(char **p, const char *q)
+{
+
+ AN(*q);
+ if (*p != NULL)
+ free(*p);
+ *p = strdup(q);
+ AN(*p);
+}
+
/*--------------------------------------------------------------------*/
static void
@@ -172,22 +184,15 @@
cli_result(cli, CLIS_PARAM);
return;
}
- if (master.user)
- free(master.user);
- master.user = strdup(pw->pw_name);
- AN(master.user);
+ replace(&master.user, pw->pw_name);
master.uid = pw->pw_uid;
master.gid = pw->pw_gid;
/* set group to user's primary group */
- if (master.group)
- free(master.group);
if ((gr = getgrgid(pw->pw_gid)) != NULL &&
(gr = getgrnam(gr->gr_name)) != NULL &&
- gr->gr_gid == pw->pw_gid) {
- master.group = strdup(gr->gr_name);
- AN(master.group);
- }
+ gr->gr_gid == pw->pw_gid)
+ replace(&master.group, gr->gr_name);
} else if (master.user) {
cli_out(cli, "%s (%d)", master.user, (int)master.uid);
} else {
@@ -221,10 +226,7 @@
cli_result(cli, CLIS_PARAM);
return;
}
- if (master.group)
- free(master.group);
- master.group = strdup(gr->gr_name);
- AN(master.group);
+ replace(&master.group, gr->gr_name);
master.gid = gr->gr_gid;
} else if (master.group) {
cli_out(cli, "%s (%d)", master.group, (int)master.gid);
@@ -456,9 +458,7 @@
return;
}
- free(master.listen_address);
- master.listen_address = strdup(arg);
- AN(master.listen_address);
+ replace(&master.listen_address, arg);
clean_listen_sock_head(&heritage.socks);
heritage.nsocks = 0;
From phk at projects.linpro.no Sun Sep 23 13:04:20 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:04:20 +0200 (CEST)
Subject: r1985 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070923130420.D16AF1EC2B1@projects.linpro.no>
Author: phk
Date: 2007-09-23 15:04:20 +0200 (Sun, 23 Sep 2007)
New Revision: 1985
Modified:
trunk/varnish-cache/bin/varnishd/cache_pool.c
trunk/varnish-cache/bin/varnishd/hash_classic.c
Log:
Partially revert previous optimization: it wasn't.
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-23 13:01:21 UTC (rev 1984)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-23 13:04:20 UTC (rev 1985)
@@ -221,22 +221,25 @@
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
assert(!isnan(w->used));
- LOCK(&tmtx);
-
- /* Process overflow requests, if any */
w->wrq = TAILQ_FIRST(&overflow);
if (w->wrq != NULL) {
- VSL_stats->n_wrk_queue--;
- TAILQ_REMOVE(&overflow, w->wrq, list);
- } else {
+ LOCK(&tmtx);
+
+ /* Process overflow requests, if any */
+ w->wrq = TAILQ_FIRST(&overflow);
+ if (w->wrq != NULL) {
+ VSL_stats->n_wrk_queue--;
+ TAILQ_REMOVE(&overflow, w->wrq, list);
+ }
+ UNLOCK(&tmtx);
+ }
+ if (w->wrq == NULL) {
+ LOCK(&qp->mtx);
TAILQ_INSERT_HEAD(&qp->idle, w, list);
+ UNLOCK(&qp->mtx);
+ assert(1 == read(w->pipe[0], &c, 1));
}
-
- UNLOCK(&qp->mtx);
-
if (w->wrq == NULL)
- assert(1 == read(w->pipe[0], &c, 1));
- if (w->wrq == NULL)
break;
wrk_do_one(w);
}
Modified: trunk/varnish-cache/bin/varnishd/hash_classic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-09-23 13:01:21 UTC (rev 1984)
+++ trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-09-23 13:04:20 UTC (rev 1985)
@@ -121,13 +121,14 @@
static struct objhead *
hcl_lookup(struct sess *sp, struct objhead *noh)
{
+ struct objhead *roh;
struct hcl_entry *he, *he2;
struct hcl_hd *hp;
unsigned u1, digest, r;
unsigned u, v;
int i;
- CHECK_OBJ_NOTNULL(noh, OBJHEAD_MAGIC);
+ CHECK_OBJ_ORNULL(noh, OBJHEAD_MAGIC);
digest = ~0U;
for (u = 0; u < sp->ihashptr; u += 2) {
@@ -158,11 +159,15 @@
if (i > 0)
break;
he->refcnt++;
- noh = he->oh;
+ roh = he->oh;
UNLOCK(&hp->mtx);
if (he2 != NULL)
free(he2);
- return (noh);
+ if (noh->hash != NULL) {
+ free(noh->hash);
+ noh->hash = NULL;
+ }
+ return (roh);
}
if (noh == NULL) {
UNLOCK(&hp->mtx);
@@ -189,6 +194,7 @@
he2->head = hp;
noh->hashpriv = he2;
+ AZ(noh->hash);
noh->hash = malloc(sp->lhashptr);
XXXAN(noh->hash);
noh->hashlen = sp->lhashptr;
From des at projects.linpro.no Sun Sep 23 13:05:47 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:05:47 +0200 (CEST)
Subject: r1986 - in branches/1.1: . bin/varnishd include lib/libvcl
Message-ID: <20070923130547.27FE51EC2AE@projects.linpro.no>
Author: des
Date: 2007-09-23 15:05:46 +0200 (Sun, 23 Sep 2007)
New Revision: 1986
Modified:
branches/1.1/
branches/1.1/bin/varnishd/cache_vrt.c
branches/1.1/include/vrt.h
branches/1.1/lib/libvcl/vcc_fixed_token.c
branches/1.1/lib/libvcl/vcc_parse.c
Log:
Merged revisions 1830 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1830 | phk | 2007-08-10 12:28:08 +0200 (Fri, 10 Aug 2007) | 4 lines
Don't call functions outside the VRT namespace, even if this means
that we have to wrap strcmp().
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1831-1838,1846,1853-1855,1857-1859,1862,1865,1867-1868,1871,1873-1880,1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865,1867-1868,1871,1873-1880,1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
Modified: branches/1.1/bin/varnishd/cache_vrt.c
===================================================================
--- branches/1.1/bin/varnishd/cache_vrt.c 2007-09-23 13:04:20 UTC (rev 1985)
+++ branches/1.1/bin/varnishd/cache_vrt.c 2007-09-23 13:05:46 UTC (rev 1986)
@@ -532,3 +532,13 @@
AddBan(regexp);
}
+
+/*--------------------------------------------------------------------
+ * Simple stuff
+ */
+
+int
+VRT_strcmp(const char *s1, const char *s2)
+{
+ return (strcmp(s1, s2));
+}
Modified: branches/1.1/include/vrt.h
===================================================================
--- branches/1.1/include/vrt.h 2007-09-23 13:04:20 UTC (rev 1985)
+++ branches/1.1/include/vrt.h 2007-09-23 13:05:46 UTC (rev 1986)
@@ -82,6 +82,10 @@
void VRT_SetHdr(struct sess *, enum gethdr_e where, const char *, const char *, ...);
void VRT_handling(struct sess *sp, unsigned hand);
+/* Simple stuff */
+int VRT_strcmp(const char *s1, const char *s2);
+
+
/* Backend related */
void VRT_set_backend_name(struct backend *, const char *);
void VRT_alloc_backends(struct VCL_conf *cp);
Modified: branches/1.1/lib/libvcl/vcc_fixed_token.c
===================================================================
--- branches/1.1/lib/libvcl/vcc_fixed_token.c 2007-09-23 13:04:20 UTC (rev 1985)
+++ branches/1.1/lib/libvcl/vcc_fixed_token.c 2007-09-23 13:05:46 UTC (rev 1986)
@@ -440,6 +440,10 @@
vsb_cat(sb, "void VRT_SetHdr(struct sess *, enum gethdr_e where, const char *, const char *, ...);\n");
vsb_cat(sb, "void VRT_handling(struct sess *sp, unsigned hand);\n");
vsb_cat(sb, "\n");
+ vsb_cat(sb, "/* Simple stuff */\n");
+ vsb_cat(sb, "int VRT_strcmp(const char *s1, const char *s2);\n");
+ vsb_cat(sb, "\n");
+ vsb_cat(sb, "\n");
vsb_cat(sb, "/* Backend related */\n");
vsb_cat(sb, "void VRT_set_backend_name(struct backend *, const char *);\n");
vsb_cat(sb, "void VRT_alloc_backends(struct VCL_conf *cp);\n");
Modified: branches/1.1/lib/libvcl/vcc_parse.c
===================================================================
--- branches/1.1/lib/libvcl/vcc_parse.c 2007-09-23 13:04:20 UTC (rev 1985)
+++ branches/1.1/lib/libvcl/vcc_parse.c 2007-09-23 13:05:46 UTC (rev 1986)
@@ -232,7 +232,7 @@
break;
case T_EQ:
case T_NEQ:
- Fb(tl, 1, "%sstrcmp(%s, ",
+ Fb(tl, 1, "%sVRT_strcmp(%s, ",
tl->t->tok == T_EQ ? "!" : "", vp->rname);
vcc_NextToken(tl);
ExpectErr(tl, CSTR);
From des at projects.linpro.no Sun Sep 23 13:07:54 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:07:54 +0200 (CEST)
Subject: r1987 - branches/1.1/redhat
Message-ID: <20070923130754.A3B241EC405@projects.linpro.no>
Author: des
Date: 2007-09-23 15:07:54 +0200 (Sun, 23 Sep 2007)
New Revision: 1987
Modified:
branches/1.1/redhat/varnish.spec
Log:
Comment out the autogen.sh invocation to avoid accidentally including it
in a release.
Modified: branches/1.1/redhat/varnish.spec
===================================================================
--- branches/1.1/redhat/varnish.spec 2007-09-23 13:05:46 UTC (rev 1986)
+++ branches/1.1/redhat/varnish.spec 2007-09-23 13:07:54 UTC (rev 1987)
@@ -50,7 +50,7 @@
# The svn sources needs to generate a suitable configure script
# Release tarballs would not need this
-./autogen.sh
+# ./autogen.sh
%build
From des at projects.linpro.no Sun Sep 23 13:09:07 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:09:07 +0200 (CEST)
Subject: r1988 - in branches/1.1: . bin/varnishd
Message-ID: <20070923130907.BBF651EC2AE@projects.linpro.no>
Author: des
Date: 2007-09-23 15:09:07 +0200 (Sun, 23 Sep 2007)
New Revision: 1988
Modified:
branches/1.1/
branches/1.1/bin/varnishd/cache_session.c
Log:
Merged revisions 1866 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1866 | phk | 2007-08-20 10:55:13 +0200 (Mon, 20 Aug 2007) | 2 lines
Assert that the timestats we need for VSL_StatSess are valid.
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865,1867-1868,1871,1873-1880,1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871,1873-1880,1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
Modified: branches/1.1/bin/varnishd/cache_session.c
===================================================================
--- branches/1.1/bin/varnishd/cache_session.c 2007-09-23 13:07:54 UTC (rev 1987)
+++ branches/1.1/bin/varnishd/cache_session.c 2007-09-23 13:09:07 UTC (rev 1988)
@@ -340,6 +340,8 @@
AZ(sp->vcl);
VSL_stats->n_sess--;
ses_relsrcaddr(sp);
+ assert(!isnan(b->first));
+ assert(!isnan(sp->t_end));
VSL(SLT_StatSess, sp->id, "%s %s %.0f %ju %ju %ju %ju %ju %ju %ju",
sp->addr, sp->port, sp->t_end - b->first,
b->sess, b->req, b->pipe, b->pass,
From des at projects.linpro.no Sun Sep 23 13:09:38 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:09:38 +0200 (CEST)
Subject: r1989 - branches/1.1
Message-ID: <20070923130938.979211EC2B1@projects.linpro.no>
Author: des
Date: 2007-09-23 15:09:38 +0200 (Sun, 23 Sep 2007)
New Revision: 1989
Modified:
branches/1.1/
Log:
Null commit to remove r1872 from the avail list.
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871,1873-1880,1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
From phk at projects.linpro.no Sun Sep 23 13:09:56 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:09:56 +0200 (CEST)
Subject: r1990 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070923130956.66F7D1EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-23 15:09:56 +0200 (Sun, 23 Sep 2007)
New Revision: 1990
Modified:
trunk/varnish-cache/bin/varnishd/hash_classic.c
Log:
Part of this commit sneaked into the previous #1985:
Close a supposedly rare memory leak: when we loose the race to create
an objhead, we need to free the hash-string we created before our
second attempt.
Modified: trunk/varnish-cache/bin/varnishd/hash_classic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-09-23 13:09:38 UTC (rev 1989)
+++ trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-09-23 13:09:56 UTC (rev 1990)
@@ -161,6 +161,10 @@
he->refcnt++;
roh = he->oh;
UNLOCK(&hp->mtx);
+ /*
+ * If we loose the race, we need to clean up
+ * the work we did for our second attempt.
+ */
if (he2 != NULL)
free(he2);
if (noh->hash != NULL) {
From phk at projects.linpro.no Sun Sep 23 13:11:51 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:11:51 +0200 (CEST)
Subject: r1991 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070923131151.A67301EC2B1@projects.linpro.no>
Author: phk
Date: 2007-09-23 15:11:51 +0200 (Sun, 23 Sep 2007)
New Revision: 1991
Modified:
trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
When a workerthread dies of old age, make sure to nuke the mutex it may
have in its cached nobjhead.
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-23 13:09:56 UTC (rev 1990)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-23 13:11:51 UTC (rev 1991)
@@ -256,8 +256,10 @@
AZ(close(w->pipe[1]));
if (w->srcaddr != NULL)
free(w->srcaddr);
- if (w->nobjhead != NULL)
+ if (w->nobjhead != NULL) {
+ MTX_DESTROY(&w->nobjhead->mtx);
FREE_OBJ(w->nobjhead);
+ }
if (w->nobj!= NULL)
FREE_OBJ(w->nobj);
return (NULL);
From des at projects.linpro.no Sun Sep 23 13:15:04 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:15:04 +0200 (CEST)
Subject: r1992 - in branches/1.1: . bin/varnishd
Message-ID: <20070923131504.258A61EC405@projects.linpro.no>
Author: des
Date: 2007-09-23 15:15:03 +0200 (Sun, 23 Sep 2007)
New Revision: 1992
Modified:
branches/1.1/
branches/1.1/bin/varnishd/cache.h
Log:
Merged revisions 1883 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1883 | phk | 2007-08-20 12:36:16 +0200 (Mon, 20 Aug 2007) | 7 lines
Make the new FlexeLint 8.00w happy again.
It's a fine point of C-linguistics, but I have to admit that in
certain universes it would have a point. Not this one though.
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
Modified: branches/1.1/bin/varnishd/cache.h
===================================================================
--- branches/1.1/bin/varnishd/cache.h 2007-09-23 13:11:51 UTC (rev 1991)
+++ branches/1.1/bin/varnishd/cache.h 2007-09-23 13:15:03 UTC (rev 1992)
@@ -107,6 +107,12 @@
char *e;
};
+enum httpwhence {
+ HTTP_Rx,
+ HTTP_Tx,
+ HTTP_Obj
+};
+
struct http {
unsigned magic;
#define HTTP_MAGIC 0x6428b5c9
@@ -116,11 +122,7 @@
char *pl_s, *pl_e; /* Pipelined bytes */
unsigned char conds; /* If-* headers present */
- enum httpwhence {
- HTTP_Rx,
- HTTP_Tx,
- HTTP_Obj
- } logtag;
+ enum httpwhence logtag;
struct http_hdr hd[HTTP_HDR_MAX];
unsigned char hdf[HTTP_HDR_MAX];
From des at projects.linpro.no Sun Sep 23 13:16:17 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:16:17 +0200 (CEST)
Subject: r1993 - in branches/1.1: . bin/varnishd
Message-ID: <20070923131617.E35211EC2B1@projects.linpro.no>
Author: des
Date: 2007-09-23 15:16:17 +0200 (Sun, 23 Sep 2007)
New Revision: 1993
Modified:
branches/1.1/
branches/1.1/bin/varnishd/cache_fetch.c
Log:
Merged revisions 1886 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1886 | phk | 2007-08-20 12:52:59 +0200 (Mon, 20 Aug 2007) | 2 lines
polish
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
Modified: branches/1.1/bin/varnishd/cache_fetch.c
===================================================================
--- branches/1.1/bin/varnishd/cache_fetch.c 2007-09-23 13:15:03 UTC (rev 1992)
+++ branches/1.1/bin/varnishd/cache_fetch.c 2007-09-23 13:16:17 UTC (rev 1993)
@@ -345,8 +345,7 @@
TAILQ_REMOVE(&sp->obj->store, st, list);
STV_free(st);
}
- close(vc->fd);
- VBE_ClosedFd(sp->wrk, vc, 1);
+ VBE_ClosedFd(sp->wrk, vc, 0);
return (-1);
}
From des at projects.linpro.no Sun Sep 23 13:18:51 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:18:51 +0200 (CEST)
Subject: r1994 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070923131851.251D61EC2B1@projects.linpro.no>
Author: des
Date: 2007-09-23 15:18:50 +0200 (Sun, 23 Sep 2007)
New Revision: 1994
Modified:
trunk/varnish-cache/bin/varnishd/cache_response.c
Log:
Unbreak header ordering.
Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2007-09-23 13:16:17 UTC (rev 1993)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2007-09-23 13:18:50 UTC (rev 1994)
@@ -29,11 +29,12 @@
* $Id$
*/
-#include
-#include
#include
#include
+#include
+#include
+
#include "shmlog.h"
#include "heritage.h"
#include "cache.h"
From des at projects.linpro.no Sun Sep 23 13:20:12 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:20:12 +0200 (CEST)
Subject: r1995 - in branches/1.1: . bin/varnishd
Message-ID: <20070923132012.F13DD1EC2AE@projects.linpro.no>
Author: des
Date: 2007-09-23 15:20:12 +0200 (Sun, 23 Sep 2007)
New Revision: 1995
Modified:
branches/1.1/
branches/1.1/bin/varnishd/cache_response.c
Log:
Merged revisions 1955,1984,1986-1989,1992-1994 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1955 | cecilihf | 2007-09-18 13:40:44 +0200 (Tue, 18 Sep 2007) | 2 lines
Fixes #157. Always replace Date with current time on varnish server.
........
r1994 | des | 2007-09-23 15:18:50 +0200 (Sun, 23 Sep 2007) | 2 lines
Unbreak header ordering.
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1984,1986-1989,1992-1994
Modified: branches/1.1/bin/varnishd/cache_response.c
===================================================================
--- branches/1.1/bin/varnishd/cache_response.c 2007-09-23 13:18:50 UTC (rev 1994)
+++ branches/1.1/bin/varnishd/cache_response.c 2007-09-23 13:20:12 UTC (rev 1995)
@@ -32,6 +32,9 @@
#include
#include
+#include
+#include
+
#include "shmlog.h"
#include "heritage.h"
#include "cache.h"
@@ -109,6 +112,8 @@
void
RES_BuildHttp(struct sess *sp)
{
+ char *time_str;
+
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (sp->obj->response == 200 && sp->http->conds && res_do_conds(sp))
@@ -121,6 +126,17 @@
http_CopyResp(sp->http, &sp->obj->http);
http_FilterFields(sp->wrk, sp->fd, sp->http, &sp->obj->http,
HTTPH_A_DELIVER);
+
+ /* Replace Date header with current date instead of keeping the date
+ * originally given by the backend when the object was fetched (which
+ * could be a long time ago).
+ */
+ http_Unset(sp->http, H_Date);
+ time_str = malloc(50);
+ sprintf(time_str, "Date: ");
+ TIM_format(TIM_real(), &(time_str[6]));
+ http_SetHeader(sp->wrk, sp->fd, sp->http, time_str);
+
if (sp->xid != sp->obj->xid)
http_PrintfHeader(sp->wrk, sp->fd, sp->http,
"X-Varnish: %u %u", sp->xid, sp->obj->xid);
From des at projects.linpro.no Sun Sep 23 13:22:11 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:22:11 +0200 (CEST)
Subject: r1996 - in branches/1.1: . bin/varnishd include
Message-ID: <20070923132211.538B61EC405@projects.linpro.no>
Author: des
Date: 2007-09-23 15:22:11 +0200 (Sun, 23 Sep 2007)
New Revision: 1996
Modified:
branches/1.1/
branches/1.1/bin/varnishd/mgt_param.c
branches/1.1/include/miniobj.h
Log:
Merged revisions 1957-1958 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1957 | phk | 2007-09-20 09:02:35 +0200 (Thu, 20 Sep 2007) | 2 lines
Add a REPLACE() macro, for manipulating malloced string variables.
........
r1958 | phk | 2007-09-20 09:03:09 +0200 (Thu, 20 Sep 2007) | 2 lines
Use REPLACE macro to manipulate malloc'ed string variables.
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1984,1986-1989,1992-1994
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1984,1986-1989,1992-1994
Modified: branches/1.1/bin/varnishd/mgt_param.c
===================================================================
--- branches/1.1/bin/varnishd/mgt_param.c 2007-09-23 13:20:12 UTC (rev 1995)
+++ branches/1.1/bin/varnishd/mgt_param.c 2007-09-23 13:22:11 UTC (rev 1996)
@@ -67,18 +67,6 @@
static struct params master;
-/* XXX: Far too generic to live here ? */
-static void
-replace(char **p, const char *q)
-{
-
- AN(*q);
- if (*p != NULL)
- free(*p);
- *p = strdup(q);
- AN(*p);
-}
-
/*--------------------------------------------------------------------*/
static void
@@ -184,7 +172,7 @@
cli_result(cli, CLIS_PARAM);
return;
}
- replace(&master.user, pw->pw_name);
+ REPLACE(master.user, pw->pw_name);
master.uid = pw->pw_uid;
master.gid = pw->pw_gid;
@@ -192,7 +180,7 @@
if ((gr = getgrgid(pw->pw_gid)) != NULL &&
(gr = getgrnam(gr->gr_name)) != NULL &&
gr->gr_gid == pw->pw_gid)
- replace(&master.group, gr->gr_name);
+ REPLACE(master.group, gr->gr_name);
} else if (master.user) {
cli_out(cli, "%s (%d)", master.user, (int)master.uid);
} else {
@@ -226,7 +214,7 @@
cli_result(cli, CLIS_PARAM);
return;
}
- replace(&master.group, gr->gr_name);
+ REPLACE(master.group, gr->gr_name);
master.gid = gr->gr_gid;
} else if (master.group) {
cli_out(cli, "%s (%d)", master.group, (int)master.gid);
@@ -458,7 +446,7 @@
return;
}
- replace(&master.listen_address, arg);
+ REPLACE(master.listen_address, arg);
clean_listen_sock_head(&heritage.socks);
heritage.nsocks = 0;
Modified: branches/1.1/include/miniobj.h
===================================================================
--- branches/1.1/include/miniobj.h 2007-09-23 13:20:12 UTC (rev 1995)
+++ branches/1.1/include/miniobj.h 2007-09-23 13:22:11 UTC (rev 1996)
@@ -30,10 +30,21 @@
CHECK_OBJ((to), (type_magic)); \
} while (0);
-#define CAST_OBJ_NOTNULL(to, from, type_magic) \
+#define CAST_OBJ_NOTNULL(to, from, type_magic) \
do { \
(to) = (from); \
assert((to) != NULL); \
CHECK_OBJ((to), (type_magic)); \
} while (0);
+#define REPLACE(ptr, val) \
+ do { \
+ if ((ptr) != NULL) \
+ free(ptr); \
+ if ((val) != NULL) { \
+ ptr = strdup(val); \
+ AN((ptr)); \
+ } else { \
+ ptr = NULL; \
+ } \
+ } while (0);
From phk at projects.linpro.no Sun Sep 23 13:46:43 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 23 Sep 2007 15:46:43 +0200 (CEST)
Subject: r1997 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070923134643.74E4C1EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-23 15:46:43 +0200 (Sun, 23 Sep 2007)
New Revision: 1997
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Fix another cornercase that fell out as part of the pass->fetch rewrite:
If we pass a HEAD request, we should not rewrite it to GET and not expect
a body either.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-23 13:22:11 UTC (rev 1996)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-23 13:46:43 UTC (rev 1997)
@@ -463,6 +463,7 @@
int http_GetHdr(struct http *hp, const char *hdr, char **ptr);
int http_GetHdrField(struct http *hp, const char *hdr, const char *field, char **ptr);
int http_GetStatus(struct http *hp);
+const char *http_GetReq(struct http *hp);
const char *http_GetProto(struct http *hp);
int http_HdrIs(struct http *hp, const char *hdr, const char *val);
int http_GetTail(struct http *hp, unsigned len, char **b, char **e);
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-23 13:22:11 UTC (rev 1996)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-23 13:46:43 UTC (rev 1997)
@@ -263,7 +263,7 @@
struct http *hp, *hp2;
struct storage *st;
struct bereq *bereq;
- int len, mklen;
+ int len, mklen, is_get;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
@@ -272,6 +272,7 @@
w = sp->wrk;
bereq = sp->bereq;
hp = bereq->http;
+ is_get = !strcasecmp(http_GetReq(hp), "get");
sp->obj->xid = sp->xid;
@@ -341,7 +342,9 @@
/* Determine if we have a body or not */
cls = 0;
mklen = 0;
- if (http_GetHdr(hp, H_Content_Length, &b)) {
+ if (!is_get) {
+ /* nothing */
+ } else if (http_GetHdr(hp, H_Content_Length, &b)) {
cls = fetch_straight(sp, vc->fd, hp, b);
mklen = 1;
} else if (http_HdrIs(hp, H_Transfer_Encoding, "chunked")) {
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-23 13:22:11 UTC (rev 1996)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-23 13:46:43 UTC (rev 1997)
@@ -388,6 +388,13 @@
return (hp->hd[HTTP_HDR_PROTO].b);
}
+const char *
+http_GetReq(struct http *hp)
+{
+ AN(hp->hd[HTTP_HDR_REQ].b);
+ return (hp->hd[HTTP_HDR_REQ].b);
+}
+
/*--------------------------------------------------------------------
* Dissect the headers of the HTTP protocol message.
* Detect conditionals (headers which start with '^[Ii][Ff]-')
@@ -802,7 +809,8 @@
hp = bereq->http;
hp->logtag = HTTP_Tx;
- http_copyreq(hp, sp->http, how == HTTPH_R_PIPE);
+ http_copyreq(hp, sp->http,
+ (how == HTTPH_R_PIPE) || (how == HTTPH_R_PASS));
http_FilterFields(sp->wrk, sp->fd, hp, sp->http, how);
http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Varnish: %u", sp->xid);
http_PrintfHeader(sp->wrk, sp->fd, hp,
From des at projects.linpro.no Sun Sep 23 14:19:42 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 16:19:42 +0200 (CEST)
Subject: r1998 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070923141942.543281EC2B1@projects.linpro.no>
Author: des
Date: 2007-09-23 16:19:42 +0200 (Sun, 23 Sep 2007)
New Revision: 1998
Modified:
trunk/varnish-cache/bin/varnishd/cache_fetch.c
Log:
Reverse the logic in r1997 from !is_get to is_head.
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-23 13:46:43 UTC (rev 1997)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-23 14:19:42 UTC (rev 1998)
@@ -263,7 +263,7 @@
struct http *hp, *hp2;
struct storage *st;
struct bereq *bereq;
- int len, mklen, is_get;
+ int len, mklen, is_head;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
@@ -272,7 +272,7 @@
w = sp->wrk;
bereq = sp->bereq;
hp = bereq->http;
- is_get = !strcasecmp(http_GetReq(hp), "get");
+ is_head = (strcasecmp(http_GetReq(hp), "head") == 0);
sp->obj->xid = sp->xid;
@@ -286,7 +286,6 @@
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
if (WRK_Flush(w)) {
/* XXX: cleanup */
-
return (1);
}
@@ -342,7 +341,7 @@
/* Determine if we have a body or not */
cls = 0;
mklen = 0;
- if (!is_get) {
+ if (is_head) {
/* nothing */
} else if (http_GetHdr(hp, H_Content_Length, &b)) {
cls = fetch_straight(sp, vc->fd, hp, b);
@@ -366,7 +365,7 @@
}
}
- if (mklen > 0)
+ if (mklen > 0)
http_PrintfHeader(sp->wrk, sp->fd, hp2,
"Content-Length: %u", sp->obj->len);
@@ -397,12 +396,12 @@
cls = 1;
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
-
+
if (http_GetStatus(sp->bereq->http) == 200)
VBE_UpdateHealth(sp, vc, 1);
else if(http_GetStatus(sp->bereq->http) == 504)
VBE_UpdateHealth(sp, vc, -1);
-
+
if (cls)
VBE_ClosedFd(sp->wrk, vc);
else
From des at projects.linpro.no Sun Sep 23 14:23:57 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 16:23:57 +0200 (CEST)
Subject: r1999 - in branches/1.1: . bin/varnishd
Message-ID: <20070923142357.1AEC11EC2AE@projects.linpro.no>
Author: des
Date: 2007-09-23 16:23:56 +0200 (Sun, 23 Sep 2007)
New Revision: 1999
Modified:
branches/1.1/
branches/1.1/bin/varnishd/cache.h
branches/1.1/bin/varnishd/cache_fetch.c
branches/1.1/bin/varnishd/cache_http.c
Log:
Merged revisions 1967-1968,1970,1984,1986-1989,1992-1993,1995-1998 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1967 | phk | 2007-09-20 10:44:59 +0200 (Thu, 20 Sep 2007) | 2 lines
Add a http_GetProto() function
........
r1968 | phk | 2007-09-20 10:46:25 +0200 (Thu, 20 Sep 2007) | 8 lines
After we moved pass to use the same code as fetch, we have run into
a unnecessary connection timeout wait when the returned object does
not have a body.
Rework the "does this response have a body" logic to be more in line
with the RFC.
........
r1970 | phk | 2007-09-20 12:44:18 +0200 (Thu, 20 Sep 2007) | 4 lines
Fix a brain-o in my last commit. "cls" is a flag for closing the fd,
not for generating Content-Length: header.
........
r1997 | phk | 2007-09-23 15:46:43 +0200 (Sun, 23 Sep 2007) | 6 lines
Fix another cornercase that fell out as part of the pass->fetch rewrite:
If we pass a HEAD request, we should not rewrite it to GET and not expect
a body either.
........
r1998 | des | 2007-09-23 16:19:42 +0200 (Sun, 23 Sep 2007) | 2 lines
Reverse the logic in r1997 from !is_get to is_head.
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1984,1986-1989,1992-1994
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970,1984,1986-1989,1992-1998
Modified: branches/1.1/bin/varnishd/cache.h
===================================================================
--- branches/1.1/bin/varnishd/cache.h 2007-09-23 14:19:42 UTC (rev 1998)
+++ branches/1.1/bin/varnishd/cache.h 2007-09-23 14:23:56 UTC (rev 1999)
@@ -427,6 +427,8 @@
int http_GetHdr(struct http *hp, const char *hdr, char **ptr);
int http_GetHdrField(struct http *hp, const char *hdr, const char *field, char **ptr);
int http_GetStatus(struct http *hp);
+const char *http_GetReq(struct http *hp);
+const char *http_GetProto(struct http *hp);
int http_HdrIs(struct http *hp, const char *hdr, const char *val);
int http_GetTail(struct http *hp, unsigned len, char **b, char **e);
int http_Read(struct http *hp, int fd, void *b, unsigned len);
Modified: branches/1.1/bin/varnishd/cache_fetch.c
===================================================================
--- branches/1.1/bin/varnishd/cache_fetch.c 2007-09-23 14:19:42 UTC (rev 1998)
+++ branches/1.1/bin/varnishd/cache_fetch.c 2007-09-23 14:23:56 UTC (rev 1999)
@@ -259,11 +259,10 @@
struct worker *w;
char *b;
int cls;
- int body = 1; /* XXX */
struct http *hp, *hp2;
struct storage *st;
struct bereq *bereq;
- int len;
+ int len, mklen, is_head;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
@@ -272,6 +271,7 @@
w = sp->wrk;
bereq = sp->bereq;
hp = bereq->http;
+ is_head = (strcasecmp(http_GetReq(hp), "head") == 0);
sp->obj->xid = sp->xid;
@@ -282,7 +282,6 @@
http_Write(w, hp, 0);
if (WRK_Flush(w)) {
/* XXX: cleanup */
-
return (1);
}
@@ -327,17 +326,37 @@
http_FilterFields(sp->wrk, sp->fd, hp2, hp, HTTPH_A_INS);
http_CopyHome(sp->wrk, sp->fd, hp2);
- if (body) {
- if (http_GetHdr(hp, H_Content_Length, &b))
- cls = fetch_straight(sp, vc->fd, hp, b);
- else if (http_HdrIs(hp, H_Transfer_Encoding, "chunked"))
- cls = fetch_chunked(sp, vc->fd, hp);
- else
- cls = fetch_eof(sp, vc->fd, hp);
+
+ /* Determine if we have a body or not */
+ cls = 0;
+ mklen = 0;
+ if (is_head) {
+ /* nothing */
+ } else if (http_GetHdr(hp, H_Content_Length, &b)) {
+ cls = fetch_straight(sp, vc->fd, hp, b);
+ mklen = 1;
+ } else if (http_HdrIs(hp, H_Transfer_Encoding, "chunked")) {
+ cls = fetch_chunked(sp, vc->fd, hp);
+ mklen = 1;
+ } else if (http_GetHdr(hp, H_Transfer_Encoding, &b)) {
+ /* XXX: AUGH! */
+ VSL(SLT_Debug, vc->fd, "Invalid Transfer-Encoding");
+ VBE_ClosedFd(sp->wrk, vc);
+ return (-1);
+ } else if (strcmp(http_GetProto(hp), "HTTP/1.1")) {
+ switch (http_GetStatus(hp)) {
+ case 200:
+ cls = fetch_eof(sp, vc->fd, hp);
+ mklen = 1;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (mklen > 0)
http_PrintfHeader(sp->wrk, sp->fd, hp2,
"Content-Length: %u", sp->obj->len);
- } else
- cls = 0;
if (cls < 0) {
while (!TAILQ_EMPTY(&sp->obj->store)) {
Modified: branches/1.1/bin/varnishd/cache_http.c
===================================================================
--- branches/1.1/bin/varnishd/cache_http.c 2007-09-23 14:19:42 UTC (rev 1998)
+++ branches/1.1/bin/varnishd/cache_http.c 2007-09-23 14:23:56 UTC (rev 1999)
@@ -381,6 +381,20 @@
NULL /* XXX */, 10));
}
+const char *
+http_GetProto(struct http *hp)
+{
+ AN(hp->hd[HTTP_HDR_PROTO].b);
+ return (hp->hd[HTTP_HDR_PROTO].b);
+}
+
+const char *
+http_GetReq(struct http *hp)
+{
+ AN(hp->hd[HTTP_HDR_REQ].b);
+ return (hp->hd[HTTP_HDR_REQ].b);
+}
+
/*--------------------------------------------------------------------
* Dissect the headers of the HTTP protocol message.
* Detect conditionals (headers which start with '^[Ii][Ff]-')
@@ -792,7 +806,8 @@
hp = bereq->http;
hp->logtag = HTTP_Tx;
- http_copyreq(hp, sp->http, how != HTTPH_R_PIPE);
+ http_copyreq(hp, sp->http,
+ (how == HTTPH_R_PIPE) || (how == HTTPH_R_PASS));
http_FilterFields(sp->wrk, sp->fd, hp, sp->http, how);
http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Varnish: %u", sp->xid);
http_PrintfHeader(sp->wrk, sp->fd, hp,
From des at projects.linpro.no Sun Sep 23 14:26:03 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 16:26:03 +0200 (CEST)
Subject: r2000 - branches/1.1/bin/varnishd
Message-ID: <20070923142603.92C221EC2B1@projects.linpro.no>
Author: des
Date: 2007-09-23 16:26:03 +0200 (Sun, 23 Sep 2007)
New Revision: 2000
Modified:
branches/1.1/bin/varnishd/cache_fetch.c
Log:
Fix build
Modified: branches/1.1/bin/varnishd/cache_fetch.c
===================================================================
--- branches/1.1/bin/varnishd/cache_fetch.c 2007-09-23 14:23:56 UTC (rev 1999)
+++ branches/1.1/bin/varnishd/cache_fetch.c 2007-09-23 14:26:03 UTC (rev 2000)
@@ -341,7 +341,7 @@
} else if (http_GetHdr(hp, H_Transfer_Encoding, &b)) {
/* XXX: AUGH! */
VSL(SLT_Debug, vc->fd, "Invalid Transfer-Encoding");
- VBE_ClosedFd(sp->wrk, vc);
+ VBE_ClosedFd(sp->wrk, vc, 0);
return (-1);
} else if (strcmp(http_GetProto(hp), "HTTP/1.1")) {
switch (http_GetStatus(hp)) {
From des at projects.linpro.no Sun Sep 23 14:26:59 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 16:26:59 +0200 (CEST)
Subject: r2001 - in branches/1.1: . bin/varnishd lib/libvcl
Message-ID: <20070923142659.4C1261EC2B2@projects.linpro.no>
Author: des
Date: 2007-09-23 16:26:59 +0200 (Sun, 23 Sep 2007)
New Revision: 2001
Modified:
branches/1.1/
branches/1.1/bin/varnishd/cache_vrt.c
branches/1.1/lib/libvcl/vcc_compile.c
branches/1.1/lib/libvcl/vcc_compile.h
branches/1.1/lib/libvcl/vcc_token.c
Log:
Merged revisions 1971-1974 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1971 | phk | 2007-09-21 00:25:27 +0200 (Fri, 21 Sep 2007) | 4 lines
Don't core dump if VCL tries to compare NULL pointers, just let the
comparison fail. This typically happens if a paticular header is
not present.
........
r1972 | phk | 2007-09-21 00:26:31 +0200 (Fri, 21 Sep 2007) | 2 lines
Avoid a double free when we encounter a 'include' directive.
........
r1973 | phk | 2007-09-21 00:26:53 +0200 (Fri, 21 Sep 2007) | 2 lines
vcc_FreeToken() is no longer necessary
........
r1974 | phk | 2007-09-21 00:27:25 +0200 (Fri, 21 Sep 2007) | 3 lines
Fix an extremely fine C-standard point and remove the vcc_FreeToken()
prototype
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970,1984,1986-1989,1992-1998
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1984,1986-1989,1992-1998
Modified: branches/1.1/bin/varnishd/cache_vrt.c
===================================================================
--- branches/1.1/bin/varnishd/cache_vrt.c 2007-09-23 14:26:03 UTC (rev 2000)
+++ branches/1.1/bin/varnishd/cache_vrt.c 2007-09-23 14:26:59 UTC (rev 2001)
@@ -540,5 +540,7 @@
int
VRT_strcmp(const char *s1, const char *s2)
{
+ if (s1 == NULL || s2 == NULL)
+ return(1);
return (strcmp(s1, s2));
}
Modified: branches/1.1/lib/libvcl/vcc_compile.c
===================================================================
--- branches/1.1/lib/libvcl/vcc_compile.c 2007-09-23 14:26:03 UTC (rev 2000)
+++ branches/1.1/lib/libvcl/vcc_compile.c 2007-09-23 14:26:59 UTC (rev 2001)
@@ -458,9 +458,6 @@
TAILQ_REMOVE(&tl->tokens, t, list);
TAILQ_REMOVE(&tl->tokens, t1, list);
TAILQ_REMOVE(&tl->tokens, t2, list);
- vcc_FreeToken(t);
- vcc_FreeToken(t1);
- vcc_FreeToken(t2);
if (!tl->err)
vcc_resolve_includes(tl);
return;
Modified: branches/1.1/lib/libvcl/vcc_compile.h
===================================================================
--- branches/1.1/lib/libvcl/vcc_compile.h 2007-09-23 14:26:03 UTC (rev 2000)
+++ branches/1.1/lib/libvcl/vcc_compile.h 2007-09-23 14:26:59 UTC (rev 2001)
@@ -102,6 +102,12 @@
HEADER
};
+enum var_access {
+ V_RO,
+ V_RW,
+ V_WO
+};
+
enum ref_type {
R_FUNC,
R_ACL,
@@ -122,7 +128,7 @@
unsigned len;
const char *rname;
const char *lname;
- enum {V_RO, V_RW, V_WO} access;
+ enum var_access access;
const char *hdr;
unsigned methods;
};
@@ -185,7 +191,6 @@
void vcc_NextToken(struct tokenlist *tl);
void vcc__ErrInternal(struct tokenlist *tl, const char *func, unsigned line);
void vcc_AddToken(struct tokenlist *tl, unsigned tok, const char *b, const char *e);
-void vcc_FreeToken(struct token *t);
/* vcc_var.c */
struct var *vcc_FindVar(struct tokenlist *tl, const struct token *t, struct var *vl);
Modified: branches/1.1/lib/libvcl/vcc_token.c
===================================================================
--- branches/1.1/lib/libvcl/vcc_token.c 2007-09-23 14:26:03 UTC (rev 2000)
+++ branches/1.1/lib/libvcl/vcc_token.c 2007-09-23 14:26:59 UTC (rev 2001)
@@ -275,19 +275,6 @@
}
/*--------------------------------------------------------------------
- * Free a token
- */
-
-void
-vcc_FreeToken(struct token *t)
-{
-
- if (t->dec != NULL)
- free(t->dec);
- free(t);
-}
-
-/*--------------------------------------------------------------------
* Lexical analysis and token generation
*/
From des at projects.linpro.no Sun Sep 23 14:36:05 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Sun, 23 Sep 2007 16:36:05 +0200 (CEST)
Subject: r2002 - in branches/1.1: . bin/varnishd
Message-ID: <20070923143605.C89181EC2B1@projects.linpro.no>
Author: des
Date: 2007-09-23 16:36:05 +0200 (Sun, 23 Sep 2007)
New Revision: 2002
Modified:
branches/1.1/
branches/1.1/bin/varnishd/cache_pool.c
Log:
Merged revisions 1991 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1991 | phk | 2007-09-23 15:11:51 +0200 (Sun, 23 Sep 2007) | 4 lines
When a workerthread dies of old age, make sure to nuke the mutex it may
have in its cached nobjhead.
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1984,1986-1989,1992-1998
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1984,1986-1989,1991-1998
Modified: branches/1.1/bin/varnishd/cache_pool.c
===================================================================
--- branches/1.1/bin/varnishd/cache_pool.c 2007-09-23 14:26:59 UTC (rev 2001)
+++ branches/1.1/bin/varnishd/cache_pool.c 2007-09-23 14:36:05 UTC (rev 2002)
@@ -258,8 +258,10 @@
close(w->pipe[1]);
if (w->srcaddr != NULL)
free(w->srcaddr);
- if (w->nobjhead != NULL)
+ if (w->nobjhead != NULL) {
+ MTX_DESTROY(&w->nobjhead->mtx);
free(w->nobjhead);
+ }
if (w->nobj!= NULL)
free(w->nobj);
return (NULL);
From des at projects.linpro.no Mon Sep 24 07:37:30 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Mon, 24 Sep 2007 09:37:30 +0200 (CEST)
Subject: r2003 - in branches/1.1: . bin/varnishd include
Message-ID: <20070924073730.2E6751EC2B2@projects.linpro.no>
Author: des
Date: 2007-09-24 09:37:29 +0200 (Mon, 24 Sep 2007)
New Revision: 2003
Modified:
branches/1.1/
branches/1.1/bin/varnishd/cache_response.c
branches/1.1/include/http_headers.h
Log:
Merged revisions 1976-1977 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1976 | phk | 2007-09-21 11:49:05 +0200 (Fri, 21 Sep 2007) | 2 lines
Don't copy the Date: header from the object to the reply
........
r1977 | phk | 2007-09-21 11:49:44 +0200 (Fri, 21 Sep 2007) | 2 lines
Don't leak 50 bytes when creating the new Date: header.
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1984,1986-1989,1991-1998
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998
Modified: branches/1.1/bin/varnishd/cache_response.c
===================================================================
--- branches/1.1/bin/varnishd/cache_response.c 2007-09-23 14:36:05 UTC (rev 2002)
+++ branches/1.1/bin/varnishd/cache_response.c 2007-09-24 07:37:29 UTC (rev 2003)
@@ -112,7 +112,7 @@
void
RES_BuildHttp(struct sess *sp)
{
- char *time_str;
+ char time_str[30];
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -127,15 +127,8 @@
http_FilterFields(sp->wrk, sp->fd, sp->http, &sp->obj->http,
HTTPH_A_DELIVER);
- /* Replace Date header with current date instead of keeping the date
- * originally given by the backend when the object was fetched (which
- * could be a long time ago).
- */
- http_Unset(sp->http, H_Date);
- time_str = malloc(50);
- sprintf(time_str, "Date: ");
- TIM_format(TIM_real(), &(time_str[6]));
- http_SetHeader(sp->wrk, sp->fd, sp->http, time_str);
+ TIM_format(TIM_real(), time_str);
+ http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Date: %s", time_str);
if (sp->xid != sp->obj->xid)
http_PrintfHeader(sp->wrk, sp->fd, sp->http,
Modified: branches/1.1/include/http_headers.h
===================================================================
--- branches/1.1/include/http_headers.h 2007-09-23 14:36:05 UTC (rev 2002)
+++ branches/1.1/include/http_headers.h 2007-09-24 07:37:29 UTC (rev 2003)
@@ -32,7 +32,7 @@
* b session field name
* c Request(1)/Response(2) bitfield
* d (obsolete)
- * e Supress header in pass from client to backend
+ * e Supress header in filter ops
* f unused
* g unused
*
@@ -70,7 +70,7 @@
HTTPH("Content-MD5", H_Content_MD5, 2, 0, 0, 0, 0) /* RFC2616 14.15 */
HTTPH("Content-Range", H_Content_Range, 2, 3, HTTPH_R_PASS|HTTPH_A_PASS|HTTPH_R_FETCH|HTTPH_A_INS, 0, 0) /* RFC2616 14.16 */
HTTPH("Content-Type", H_Content_Type, 2, 0, 0, 0, 0) /* RFC2616 14.17 */
-HTTPH("Date", H_Date, 2, 0, 0, 0, 0) /* RFC2616 14.18 */
+HTTPH("Date", H_Date, 2, 0, HTTPH_A_DELIVER, 0, 0) /* RFC2616 14.18 */
HTTPH("ETag", H_ETag, 2, 0, 0, 0, 0) /* RFC2616 14.19 */
HTTPH("Expect", H_Expect, 1, 0, 0, 0, 0) /* RFC2616 14.20 */
HTTPH("Expires", H_Expires, 2, 0, 0, 0, 0) /* RFC2616 14.21 */
From phk at projects.linpro.no Mon Sep 24 07:37:41 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Mon, 24 Sep 2007 09:37:41 +0200 (CEST)
Subject: r2004 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070924073741.350341EC2B1@projects.linpro.no>
Author: phk
Date: 2007-09-24 09:37:40 +0200 (Mon, 24 Sep 2007)
New Revision: 2004
Modified:
trunk/varnish-cache/bin/varnishd/hash_classic.c
Log:
Fix a NULL pointer dereference which cannot currently happen.
Modified: trunk/varnish-cache/bin/varnishd/hash_classic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-09-24 07:37:29 UTC (rev 2003)
+++ trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-09-24 07:37:40 UTC (rev 2004)
@@ -167,7 +167,7 @@
*/
if (he2 != NULL)
free(he2);
- if (noh->hash != NULL) {
+ if (noh != NULL && noh->hash != NULL) {
free(noh->hash);
noh->hash = NULL;
}
From phk at projects.linpro.no Mon Sep 24 08:01:07 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Mon, 24 Sep 2007 10:01:07 +0200 (CEST)
Subject: r2005 - trunk/varnish-cache/include
Message-ID: <20070924080107.A16381EC2B2@projects.linpro.no>
Author: phk
Date: 2007-09-24 10:01:07 +0200 (Mon, 24 Sep 2007)
New Revision: 2005
Modified:
trunk/varnish-cache/include/stat_field.h
Log:
Add a couple of statistics counters for LRU
Modified: trunk/varnish-cache/include/stat_field.h
===================================================================
--- trunk/varnish-cache/include/stat_field.h 2007-09-24 07:37:40 UTC (rev 2004)
+++ trunk/varnish-cache/include/stat_field.h 2007-09-24 08:01:07 UTC (rev 2005)
@@ -61,6 +61,8 @@
MAC_STAT(n_wrk_drop, uint64_t, 'a', "N dropped work requests")
MAC_STAT(n_expired, uint64_t, 'i', "N expired objects")
+MAC_STAT(n_lru_nuked, uint64_t, 'i', "N LRU nuked objects")
+MAC_STAT(n_lru_saved, uint64_t, 'i', "N LRU saved objects")
MAC_STAT(n_deathrow, uint64_t, 'i', "N objects on deathrow")
MAC_STAT(losthdr, uint64_t, 'a', "HTTP header overflows")
From phk at projects.linpro.no Mon Sep 24 08:23:34 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Mon, 24 Sep 2007 10:23:34 +0200 (CEST)
Subject: r2006 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070924082334.4530A1EC2B1@projects.linpro.no>
Author: phk
Date: 2007-09-24 10:23:34 +0200 (Mon, 24 Sep 2007)
New Revision: 2006
Removed:
trunk/varnish-cache/bin/varnishd/cache_lru.c
Modified:
trunk/varnish-cache/bin/varnishd/Makefile.am
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_expire.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/cache_synthetic.c
trunk/varnish-cache/bin/varnishd/stevedore.c
trunk/varnish-cache/bin/varnishd/stevedore.h
Log:
Our first cut at a LRU processing contained a three way race and can
cause Really Weird Problems if you really provoke it.
+++ Redo from start +++
LRU processing is only relevant for objects which are in the cache and
on the EXP binary heap so we merge the LRU functionality with the EXP
code in order to share locks and object reference counts.
Another thing we overlooked in the first implementation is that the VCL
callout for LRU should be able to examine the client information for
the session which tries to push stuff out, so that QoS/DoS issues can be
considered:
sub vcl_dicard {
if (client.bandwidth > 10 mb/s) {
keep;
}
}
(which sort of indicates that "error" should be a legal action as well)
To enable this, pass the session into the stevedore when we try to
allocate space and temporarily substitute the target object for its
own object while we call vcl_discard().
The outcome of an attempt to make space can take three values, did,
didn't and couldn't. In the latter case there is no point in trying
again and again, in particular if the cause is incurable, such as
the requested size being larger than the storage. We still need to
handle failure to allocate storage for that case rather than core dump.
When looking for targets to nuke, we only consider objects on the
binheap which has reference count of 1, objects with higher reference
counts would not free space.
We take prospective targets off the binheap, but retain their
refcount, and tag them with a magic marker while we ponder their
destiny.
It is quite possible that another session could pick the object up
via the cache while we do so, and therefore attempts to update the
ttl or shift them in the lru chain must ignore objects which has
the magic marker. If the object is kept, the updated ttl will
automatically take effect when we reinsert it in the binheap.
Modified: trunk/varnish-cache/bin/varnishd/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishd/Makefile.am 2007-09-24 08:01:07 UTC (rev 2005)
+++ trunk/varnish-cache/bin/varnishd/Makefile.am 2007-09-24 08:23:34 UTC (rev 2006)
@@ -22,7 +22,6 @@
cache_fetch.c \
cache_hash.c \
cache_http.c \
- cache_lru.c \
cache_main.c \
cache_pool.c \
cache_pipe.c \
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-24 08:01:07 UTC (rev 2005)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-24 08:23:34 UTC (rev 2006)
@@ -247,7 +247,6 @@
TAILQ_HEAD(, sess) waitinglist;
double lru_stamp;
- TAILQ_ENTRY(object) lru;
};
struct objhead {
@@ -429,7 +428,8 @@
void EXP_Insert(struct object *o);
void EXP_Init(void);
void EXP_TTLchange(struct object *o);
-void EXP_Terminate(struct object *o);
+void EXP_Touch(struct object *o, double now);
+int EXP_NukeOne(struct sess *sp);
/* cache_fetch.c */
int Fetch(struct sess *sp);
@@ -538,14 +538,6 @@
void VCL_Rel(struct VCL_conf **vcc);
void VCL_Get(struct VCL_conf **vcc);
-/* cache_lru.c */
-// void LRU_Init(void);
-void LRU_Enter(struct object *o, double stamp);
-void LRU_Remove(struct object *o);
-int LRU_DiscardOne(void);
-int LRU_DiscardSpace(int64_t quota);
-int LRU_DiscardTime(double cutoff);
-
#define VCL_RET_MAC(l,u,b,n)
#define VCL_MET_MAC(l,u,b) void VCL_##l##_method(struct sess *);
#include "vcl_returns.h"
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-24 08:01:07 UTC (rev 2005)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-24 08:23:34 UTC (rev 2006)
@@ -147,6 +147,8 @@
{
sp->t_resp = TIM_real();
+ if (sp->obj->objhead != NULL)
+ EXP_Touch(sp->obj, sp->t_resp);
RES_BuildHttp(sp);
VCL_deliver_method(sp);
switch (sp->handling) {
Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-09-24 08:01:07 UTC (rev 2005)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-09-24 08:23:34 UTC (rev 2006)
@@ -45,53 +45,64 @@
#include "shmlog.h"
#include "binary_heap.h"
#include "cache.h"
+#include "heritage.h"
static pthread_t exp_thread;
static struct binheap *exp_heap;
static MTX exp_mtx;
static unsigned expearly = 30;
static TAILQ_HEAD(,object) exp_deathrow = TAILQ_HEAD_INITIALIZER(exp_deathrow);
+static TAILQ_HEAD(,object) exp_lru = TAILQ_HEAD_INITIALIZER(exp_lru);
+/*
+ * This is a magic marker for the objects currently on the SIOP [look it up]
+ * so that other users of the object will not stumble trying to change the
+ * ttl or lru position.
+ */
+static const unsigned lru_target = (unsigned)(-3);
+
/*--------------------------------------------------------------------*/
void
EXP_Insert(struct object *o)
{
+ CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
assert(o->heap_idx == 0);
LOCK(&exp_mtx);
binheap_insert(exp_heap, o);
+ TAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
UNLOCK(&exp_mtx);
}
void
-EXP_TTLchange(struct object *o)
+EXP_Touch(struct object *o, double now)
{
- assert(o->heap_idx != 0);
- LOCK(&exp_mtx);
- binheap_delete(exp_heap, o->heap_idx);
- binheap_insert(exp_heap, o);
- UNLOCK(&exp_mtx);
+
+ CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
+ if (o->lru_stamp + params->lru_timeout < now) {
+ LOCK(&exp_mtx); /* XXX: should be ..._TRY */
+ if (o->heap_idx != lru_target) {
+ assert(o->heap_idx != 0);
+ TAILQ_REMOVE(&exp_lru, o, deathrow);
+ TAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
+ o->lru_stamp = now;
+ }
+ UNLOCK(&exp_mtx);
+ }
}
-/*
- * Immediately destroy an object. Do not wait for it to expire or trickle
- * through death row; yank it
- */
void
-EXP_Terminate(struct object *o)
+EXP_TTLchange(struct object *o)
{
+
LOCK(&exp_mtx);
- LRU_Remove(o);
- if (o->heap_idx)
+ if (o->heap_idx != lru_target) {
+ assert(o->heap_idx != 0);
binheap_delete(exp_heap, o->heap_idx);
- if (o->deathrow.tqe_next) {
- TAILQ_REMOVE(&exp_deathrow, o, deathrow);
- VSL_stats->n_deathrow--;
+ binheap_insert(exp_heap, o);
}
UNLOCK(&exp_mtx);
- VSL(SLT_Terminate, 0, "%u", o->xid);
- HSH_Deref(o);
}
/*--------------------------------------------------------------------
@@ -181,6 +192,7 @@
continue;
}
binheap_delete(exp_heap, o->heap_idx);
+ assert(o->heap_idx == 0);
/* Sanity check */
o2 = binheap_root(exp_heap);
@@ -195,6 +207,7 @@
if (sp->handling == VCL_RET_DISCARD) {
LOCK(&exp_mtx);
+ TAILQ_REMOVE(&exp_lru, o, deathrow);
TAILQ_INSERT_TAIL(&exp_deathrow, o, deathrow);
VSL_stats->n_deathrow++;
UNLOCK(&exp_mtx);
@@ -227,6 +240,69 @@
o->heap_idx = u;
}
+/*--------------------------------------------------------------------
+ * Attempt to make space by nuking, with VCLs permission, the oldest
+ * object on the LRU list which isn't in use.
+ * Returns: 1: did, 0: didn't, -1: can't
+ */
+
+int
+EXP_NukeOne(struct sess *sp)
+{
+ struct object *o, *o2;
+
+ /* Find the first currently unused object on the LRU */
+ LOCK(&exp_mtx);
+ TAILQ_FOREACH(o, &exp_lru, deathrow)
+ if (o->refcnt == 1)
+ break;
+ if (o != NULL) {
+ /*
+ * Take it off the binheap while we chew. This effectively
+ * means that we own the EXP refcnt on this object.
+ */
+ TAILQ_REMOVE(&exp_lru, o, deathrow);
+ binheap_delete(exp_heap, o->heap_idx);
+ assert(o->heap_idx == 0);
+ o->heap_idx = lru_target;
+ VSL_stats->n_lru_nuked++; /* May be premature */
+ }
+ UNLOCK(&exp_mtx);
+
+ if (o == NULL)
+ return (-1);
+
+ /*
+ * Ask VCL in the context of the requestors session, in order to
+ * allow client QoS considerations to inform the decision.
+ * Temporarily substitute the object we want to nuke for the sessions
+ * own object.
+ */
+ o2 = sp->obj;
+ sp->obj = o;
+ VCL_discard_method(sp);
+ sp->obj = o2;
+
+ if (sp->handling == VCL_RET_DISCARD) {
+ VSL(SLT_ExpKill, 0, "%u LRU", o->xid);
+ HSH_Deref(o);
+ return (1);
+ }
+
+ assert(sp->handling == VCL_RET_KEEP);
+
+ /* Insert in binheap and lru again */
+ LOCK(&exp_mtx);
+ VSL_stats->n_lru_nuked--; /* It was premature */
+ VSL_stats->n_lru_saved++;
+ o->heap_idx = 0;
+ o->lru_stamp = sp->wrk->used;
+ binheap_insert(exp_heap, o);
+ TAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
+ UNLOCK(&exp_mtx);
+ return (0);
+}
+
/*--------------------------------------------------------------------*/
void
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-24 08:01:07 UTC (rev 2005)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-24 08:23:34 UTC (rev 2006)
@@ -49,7 +49,7 @@
/*--------------------------------------------------------------------*/
static int
-fetch_straight(const struct sess *sp, int fd, struct http *hp, char *b)
+fetch_straight(struct sess *sp, int fd, struct http *hp, char *b)
{
int i;
unsigned char *p;
@@ -60,7 +60,7 @@
if (cl == 0)
return (0);
- st = STV_alloc(cl);
+ st = STV_alloc(sp, cl);
TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
st->len = cl;
sp->obj->len = cl;
@@ -84,7 +84,7 @@
/* XXX: Cleanup. It must be possible somehow :-( */
static int
-fetch_chunked(const struct sess *sp, int fd, struct http *hp)
+fetch_chunked(struct sess *sp, int fd, struct http *hp)
{
int i;
char *q;
@@ -149,7 +149,7 @@
v = u;
if (u < params->fetch_chunksize * 1024)
v = params->fetch_chunksize * 1024;
- st = STV_alloc(v);
+ st = STV_alloc(sp, v);
TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
}
v = st->space - st->len;
@@ -208,7 +208,7 @@
#include
static int
-fetch_eof(const struct sess *sp, int fd, struct http *hp)
+fetch_eof(struct sess *sp, int fd, struct http *hp)
{
int i;
unsigned char *p;
@@ -224,7 +224,7 @@
st = NULL;
while (1) {
if (v == 0) {
- st = STV_alloc(params->fetch_chunksize * 1024);
+ st = STV_alloc(sp, params->fetch_chunksize * 1024);
TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
p = st->ptr + st->len;
v = st->space - st->len;
Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-24 08:01:07 UTC (rev 2005)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-24 08:23:34 UTC (rev 2006)
@@ -214,7 +214,6 @@
if (o != NULL) {
UNLOCK(&oh->mtx);
(void)hash->deref(oh);
- LRU_Enter(o, sp->t_req);
return (o);
}
@@ -226,7 +225,11 @@
/* NB: do not deref objhead the new object inherits our reference */
UNLOCK(&oh->mtx);
BAN_NewObj(o);
- LRU_Enter(o, sp->t_req);
+ /*
+ * It's cheaper to copy the timestamp here, than to get a new one
+ * in EXP_Insert().
+ */
+ o->lru_stamp = w->used;
return (o);
}
@@ -307,7 +310,6 @@
if (o->vary != NULL)
free(o->vary);
- LRU_Remove(o);
HSH_Freestore(o);
FREE_OBJ(o);
VSL_stats->n_object--;
Deleted: trunk/varnish-cache/bin/varnishd/cache_lru.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_lru.c 2007-09-24 08:01:07 UTC (rev 2005)
+++ trunk/varnish-cache/bin/varnishd/cache_lru.c 2007-09-24 08:23:34 UTC (rev 2006)
@@ -1,219 +0,0 @@
-/*-
- * Copyright (c) 2007 Linpro AS
- * All rights reserved.
- *
- * Author: Dag-Erling Sm?rgav
- *
- * 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$
- */
-
-#include "shmlog.h"
-#include "cache.h"
-#include "queue.h"
-
-/*
- * For performance reasons, objects are only moved to the head of the LRU
- * list when they've been in their current position for at least LRU_DELAY
- * seconds, rather than on every access. This should probably be a
- * run-time parameter.
- */
-#define LRU_DELAY 2
-
-TAILQ_HEAD(lru_head, object);
-
-static struct lru_head lru_list = TAILQ_HEAD_INITIALIZER(lru_list);
-static pthread_mutex_t lru_mtx = PTHREAD_MUTEX_INITIALIZER;
-static struct sess *lru_session;
-static struct worker lru_worker;
-
-/*
- * Initialize the LRU data structures.
- */
-static inline void
-LRU_Init(void)
-{
- if (lru_session == NULL) {
- lru_session = SES_New(NULL, 0);
- XXXAN(lru_session);
- lru_session->wrk = &lru_worker;
- lru_worker.magic = WORKER_MAGIC;
- lru_worker.wlp = lru_worker.wlog;
- lru_worker.wle = lru_worker.wlog + sizeof lru_worker.wlog;
- VCL_Get(&lru_session->vcl);
- } else {
- VCL_Refresh(&lru_session->vcl);
- }
-}
-
-/*
- * Enter an object into the LRU list, or move it to the head of the list
- * if it's already in it and hasn't moved in a while.
- */
-void
-LRU_Enter(struct object *o, double stamp)
-{
-
- CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- assert(stamp > 0);
- if (o->lru_stamp < stamp - LRU_DELAY && o != lru_list.tqh_first) {
- // VSL(SLT_LRU_enter, 0, "%u %u %u", o->xid, o->lru_stamp, stamp);
- LOCK(&lru_mtx);
- if (o->lru_stamp != 0)
- TAILQ_REMOVE(&lru_list, o, lru);
- TAILQ_INSERT_HEAD(&lru_list, o, lru);
- o->lru_stamp = stamp;
- UNLOCK(&lru_mtx);
- }
-}
-
-/*
- * Remove an object from the LRU list.
- */
-void
-LRU_Remove(struct object *o)
-{
-
- CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- if (o->lru_stamp != 0) {
- // VSL(SLT_LRU_remove, 0, "%u", o->xid);
- LOCK(&lru_mtx);
- TAILQ_REMOVE(&lru_list, o, lru);
- UNLOCK(&lru_mtx);
- }
-}
-
-/*
- * With the LRU lock held, call VCL_discard(). Depending on the result,
- * either insert the object at the head of the list or dereference it.
- */
-static int
-LRU_DiscardLocked(struct object *o)
-{
- struct object *so;
-
- if (o->busy)
- return (0);
-
- /* XXX this is a really bad place to do this */
- LRU_Init();
-
- CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- TAILQ_REMOVE(&lru_list, o, lru);
-
- lru_session->obj = o;
- VCL_discard_method(lru_session);
-
- if (lru_session->handling == VCL_RET_DISCARD) {
- /* discard: release object */
- VSL(SLT_ExpKill, 0, "%u %d", o->xid, o->lru_stamp);
- o->lru_stamp = 0;
- EXP_Terminate(o);
- return (1);
- } else {
- /* keep: move to front of list */
- if ((so = TAILQ_FIRST(&lru_list)))
- o->lru_stamp = so->lru_stamp;
- TAILQ_INSERT_HEAD(&lru_list, o, lru);
- return (0);
- }
-}
-
-/*
- * Walk through the LRU list, starting at the back, and check each object
- * until we find one that can be retired. Return the number of objects
- * that were discarded.
- */
-int
-LRU_DiscardOne(void)
-{
- struct object *first = TAILQ_FIRST(&lru_list);
- struct object *o;
- int count = 0;
-
- LOCK(&lru_mtx);
- while (!count && (o = TAILQ_LAST(&lru_list, lru_head))) {
- if (LRU_DiscardLocked(o))
- ++count;
- if (o == first) {
- /* full circle */
- break;
- }
- }
- UNLOCK(&lru_mtx);
- return (count);
-}
-
-/*
- * Walk through the LRU list, starting at the back, and retire objects
- * until our quota is reached or we run out of objects to retire. Return
- * the number of objects that were discarded.
- */
-int
-LRU_DiscardSpace(int64_t quota)
-{
- struct object *first = TAILQ_FIRST(&lru_list);
- struct object *o;
- unsigned int len;
- int count = 0;
-
- LOCK(&lru_mtx);
- while (quota > 0 && (o = TAILQ_LAST(&lru_list, lru_head))) {
- len = o->len;
- if (LRU_DiscardLocked(o)) {
- quota -= len;
- ++count;
- }
- if (o == first) {
- /* full circle */
- break;
- }
- }
- UNLOCK(&lru_mtx);
- return (count);
-}
-
-/*
- * Walk through the LRU list, starting at the back, and retire objects
- * that haven't been accessed since the specified cutoff date. Return the
- * number of objects that were discarded.
- */
-int
-LRU_DiscardTime(double cutoff)
-{
- struct object *first = TAILQ_FIRST(&lru_list);
- struct object *o;
- int count = 0;
-
- LOCK(&lru_mtx);
- while ((o = TAILQ_LAST(&lru_list, lru_head)) && o->lru_stamp <= cutoff) {
- if (LRU_DiscardLocked(o))
- ++count;
- if (o == first) {
- /* full circle */
- break;
- }
- }
- UNLOCK(&lru_mtx);
- return (count);
-}
Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-09-24 08:01:07 UTC (rev 2005)
+++ trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-09-24 08:23:34 UTC (rev 2006)
@@ -87,7 +87,7 @@
/* allocate space for body */
/* XXX what if the object already has a body? */
- st = STV_alloc(1024);
+ st = STV_alloc(sp, 1024);
TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
/* generate body */
Modified: trunk/varnish-cache/bin/varnishd/stevedore.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.c 2007-09-24 08:01:07 UTC (rev 2005)
+++ trunk/varnish-cache/bin/varnishd/stevedore.c 2007-09-24 08:23:34 UTC (rev 2006)
@@ -47,24 +47,28 @@
static struct stevedore * volatile stevedores;
struct storage *
-STV_alloc(size_t size)
+STV_alloc(struct sess *sp, size_t size)
{
struct storage *st;
struct stevedore *stv;
for (;;) {
+
/* pick a stevedore and bump the head along */
+ /* XXX: only safe as long as pointer writes are atomic */
stv = stevedores = stevedores->next;
/* try to allocate from it */
- if ((st = stv->alloc(stv, size)) != NULL) {
- CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
- return (st);
- }
+ st = stv->alloc(stv, size);
+ if (st != NULL)
+ break;
- /* no luck; free some space and keep trying */
- AN(LRU_DiscardOne());
+ /* no luck; try to free some space and keep trying */
+ if (EXP_NukeOne(sp) == -1)
+ break;
}
+ CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
+ return (st);
}
void
Modified: trunk/varnish-cache/bin/varnishd/stevedore.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.h 2007-09-24 08:01:07 UTC (rev 2005)
+++ trunk/varnish-cache/bin/varnishd/stevedore.h 2007-09-24 08:23:34 UTC (rev 2006)
@@ -55,7 +55,7 @@
struct stevedore *next, *prev;
};
-struct storage *STV_alloc(size_t size);
+struct storage *STV_alloc(struct sess *sp, size_t size);
void STV_trim(struct storage *st, size_t size);
void STV_free(struct storage *st);
void STV_add(const char *spec);
From phk at projects.linpro.no Mon Sep 24 11:25:16 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Mon, 24 Sep 2007 13:25:16 +0200 (CEST)
Subject: r2007 - in trunk/varnish-cache: bin/varnishd include lib/libvcl
Message-ID: <20070924112516.16B391EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-24 13:25:15 +0200 (Mon, 24 Sep 2007)
New Revision: 2007
Modified:
trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
trunk/varnish-cache/include/vrt.h
trunk/varnish-cache/lib/libvcl/vcc_backend.c
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Add code to VCC to output an identifier for each simple backend which
varnishd can use to decide if a backend state can be shared between
multiple VCL programs.
Originally the idea was to calculate a strong hash over the tokens
which define the backend.
Considering the relatively short lengths of backend declarations
and the infrequency of comparisons, we have opted for an extremely
weak hash instead: We simply output the space separted tokens as
a string.
The net change in code for simple backends is marginal, but for
complex backends this will be a lot simpler to implement.
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-24 08:23:34 UTC (rev 2006)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-24 11:25:15 UTC (rev 2007)
@@ -49,6 +49,7 @@
#define BES_MAGIC 0x015e17ac
char *hostname;
char *portname;
+ char *ident;
struct addrinfo *addr;
struct addrinfo *last_addr;
double dnsttl;
@@ -369,13 +370,9 @@
CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
if (b->method != &backend_method_simple)
continue;
- if (strcmp(b->vcl_name, t->name))
- continue;
CAST_OBJ_NOTNULL(bes, b->priv, BES_MAGIC);
- if (strcmp(bes->portname, t->port))
+ if (strcmp(bes->ident, t->ident))
continue;
- if (strcmp(bes->hostname, t->host))
- continue;
b->refcount++;
*bp = b;
return;
@@ -391,6 +388,9 @@
bes->dnsttl = 300;
+ AN(t->ident);
+ REPLACE(bes->ident, t->ident);
+
AN(t->name);
REPLACE(b->vcl_name, t->name);
Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2007-09-24 08:23:34 UTC (rev 2006)
+++ trunk/varnish-cache/include/vrt.h 2007-09-24 11:25:15 UTC (rev 2007)
@@ -41,6 +41,7 @@
struct sockaddr;
struct vrt_simple_backend {
+ const char *ident;
const char *name;
const char *port;
const char *host;
Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2007-09-24 08:23:34 UTC (rev 2006)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2007-09-24 11:25:15 UTC (rev 2007)
@@ -58,6 +58,32 @@
return (NULL);
}
+/*--------------------------------------------------------------------
+ * When a new VCL is loaded, it is likely to contain backend declarations
+ * identical to other loaded VCL programs, and we want to reuse the state
+ * of those in order to not have to relearn statistics, DNS etc.
+ *
+ * This function emits a space separated text-string of the tokens which
+ * define a given backend which can be used to determine "identical backend"
+ * in that context.
+ */
+
+static void
+vcc_EmitBeIdent(struct tokenlist *tl, struct token *first, struct token *last)
+{
+
+ Fc(tl, 0, "\t.ident =");
+ while (first != last) {
+ if (first->dec != NULL)
+ Fc(tl, 0, "\n\t \"\\\"\" %.*s \"\\\" \"",
+ PF(first));
+ else
+ Fc(tl, 0, "\n\t \"%.*s \"", PF(first));
+ first = TAILQ_NEXT(first, list);
+ }
+ Fc(tl, 0, ",\n");
+}
+
void
vcc_ParseSimpleBackend(struct tokenlist *tl)
{
@@ -65,8 +91,10 @@
struct token *t_be = NULL;
struct token *t_host = NULL;
struct token *t_port = NULL;
+ struct token *t_first;
const char *ep;
+ t_first = tl->t;
vcc_NextToken(tl);
ExpectErr(tl, ID);
t_be = tl->t;
@@ -152,6 +180,7 @@
else
Fc(tl, 0, "\t.port = \"http\",\n");
Fc(tl, 0, "\t.host = %.*s,\n", PF(t_host));
+ vcc_EmitBeIdent(tl, t_first, tl->t);
Fc(tl, 0, "};\n");
Fi(tl, 0, "\tVRT_init_simple_backend(&VGC_backend_%.*s , &sbe_%.*s);\n",
PF(t_be), PF(t_be));
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-24 08:23:34 UTC (rev 2006)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-24 11:25:15 UTC (rev 2007)
@@ -419,6 +419,7 @@
vsb_cat(sb, "struct sockaddr;\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "struct vrt_simple_backend {\n");
+ vsb_cat(sb, " const char *ident;\n");
vsb_cat(sb, " const char *name;\n");
vsb_cat(sb, " const char *port;\n");
vsb_cat(sb, " const char *host;\n");
From cecilihf at projects.linpro.no Mon Sep 24 12:06:20 2007
From: cecilihf at projects.linpro.no (cecilihf at projects.linpro.no)
Date: Mon, 24 Sep 2007 14:06:20 +0200 (CEST)
Subject: r2008 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070924120620.6689B1EC2B2@projects.linpro.no>
Author: cecilihf
Date: 2007-09-24 14:06:20 +0200 (Mon, 24 Sep 2007)
New Revision: 2008
Modified:
trunk/varnish-cache/bin/varnishd/cache_backend_random.c
trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
Log:
Update random and round-robin backends to use the new convenience functions.
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-24 11:25:15 UTC (rev 2007)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-24 12:06:20 UTC (rev 2008)
@@ -39,7 +39,6 @@
#include
#include
#include
-#include
#include "shmlog.h"
#include "cache.h"
@@ -76,90 +75,74 @@
int health;
};
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Try to get a socket connected to one of the addresses on the list.
+ * We start from the cached "last good" address and try all items on
+ * the list exactly once.
+ * If a new DNS lookup is made while we try, we start over and try the
+ * new list exactly once.
+ */
static int
ber_conn_try_list(struct sess *sp, struct brspec *bs)
{
struct addrinfo *ai, *from;
- struct sockaddr_storage ss;
- int fam, sockt, proto;
- socklen_t alen;
int s, loops;
- char abuf1[TCP_ADDRBUFSIZE], abuf2[TCP_ADDRBUFSIZE];
- char pbuf1[TCP_PORTBUFSIZE], pbuf2[TCP_PORTBUFSIZE];
unsigned myseq;
+ CHECK_OBJ_NOTNULL(bs, BRSPEC_MAGIC);
+ if (bs->addr == NULL)
+ return (-1);
+ AN(bs->last_addr);
+
/* Called with lock held */
myseq = bs->dnsseq;
loops = 0;
- from = bs->last_addr;
- for (ai = from; ai != NULL && (loops != 1 || ai != from);) {
- fam = ai->ai_family;
- sockt = ai->ai_socktype;
- proto = ai->ai_protocol;
- alen = ai->ai_addrlen;
- assert(alen <= sizeof ss);
- memcpy(&ss, ai->ai_addr, alen);
- UNLOCK(&sp->backend->mtx);
- s = socket(fam, sockt, proto);
- if (s >= 0 && connect(s, (void *)&ss, alen)) {
- AZ(close(s));
- s = -1;
- }
- if (s >= 0) {
- TCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1);
- TCP_name((void*)&ss, alen,
- abuf2, sizeof abuf2, pbuf2, sizeof pbuf2);
- WSL(sp->wrk, SLT_BackendOpen, s, "%s %s %s %s %s",
- sp->backend->vcl_name, abuf1, pbuf1, abuf2, pbuf2);
- }
- LOCK(&sp->backend->mtx);
- if (s >= 0) {
+ ai = from = bs->last_addr;
+ while (1) {
+
+ /* NB: releases/acquires lock */
+ s = VBE_TryConnect(sp, ai);
+
+ if (s >= 0) {
+ /* Update cached "last good" if still valid */
if (myseq == bs->dnsseq)
bs->last_addr = ai;
return (s);
}
+
if (myseq != bs->dnsseq) {
+ /* A DNS-lookup happended, try again from start */
loops = 0;
from = bs->last_addr;
ai = from;
} else {
+ /* Try next one */
ai = ai->ai_next;
if (ai == NULL) {
loops++;
ai = bs->addr;
}
}
+ if (loops == 1 && ai == from)
+ return (-1);
}
- return (-1);
}
/*--------------------------------------------------------------------*/
-static int
-ber_conn_try(struct sess *sp, struct backend *bp, struct brspec *bs)
+static const char *
+ber_dns_lookup(struct backend *bp, struct brspec *bs)
{
- int s;
struct addrinfo *res, hint, *old;
int error;
- LOCK(&bp->mtx);
+ CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
+ CHECK_OBJ_NOTNULL(bs, BRSPEC_MAGIC);
- s = ber_conn_try_list(sp, bs);
- if (s >= 0) {
- bp->refcount++;
- UNLOCK(&bp->mtx);
- return (s);
- }
-
- if (bs->dnstime + bs->dnsttl >= TIM_mono()) {
- UNLOCK(&bp->mtx);
- return (-1);
- }
-
- /* Then do another lookup to catch DNS changes */
bs->dnstime = TIM_mono();
+
+ /* Let go of lock while we do sleepable stuff */
UNLOCK(&bp->mtx);
memset(&hint, 0, sizeof hint);
@@ -169,21 +152,44 @@
error = getaddrinfo(bs->hostname,
bs->portname == NULL ? "http" : bs->portname,
&hint, &res);
+ LOCK(&bp->mtx);
if (error) {
if (res != NULL)
freeaddrinfo(res);
- printf("getaddrinfo: %s\n", gai_strerror(error)); /* XXX */
- LOCK(&bp->mtx);
- } else {
- LOCK(&bp->mtx);
- bs->dnsseq++;
- old = bs->addr;
- bs->last_addr = res;
- bs->addr = res;
- if (old != NULL)
- freeaddrinfo(old);
+ return(gai_strerror(error));
+ }
+ bs->dnsseq++;
+ old = bs->addr;
+ bs->last_addr = res;
+ bs->addr = res;
+ if (old != NULL)
+ freeaddrinfo(old);
+ return (NULL);
+}
+
+/*--------------------------------------------------------------------*/
+
+static int
+ber_conn_try(struct sess *sp, struct backend *bp, struct brspec *bs)
+{
+ int s;
+
+ LOCK(&bp->mtx);
+
+ s = ber_conn_try_list(sp, bs);
+ if (s >= 0) {
+ bp->refcount++;
+ UNLOCK(&bp->mtx);
+ return (s);
}
+ if (bs->dnstime + bs->dnsttl >= TIM_mono()) {
+ UNLOCK(&bp->mtx);
+ return (-1);
+ }
+
+ (void)ber_dns_lookup(bp, bs);
+
/* And try the entire list */
s = ber_conn_try_list(sp, bs);
if (s >= 0) {
@@ -194,6 +200,7 @@
UNLOCK(&bp->mtx);
return (-1);
+
}
@@ -213,14 +220,13 @@
ber_nextfd(struct sess *sp)
{
struct vbe_conn *vc;
- struct pollfd pfd;
struct backend *bp;
int reuse = 0;
struct ber *ber;
struct brspec *bs;
- double r;
int min_health = -10;
int num = 0;
+ double r = 0;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
@@ -245,8 +251,8 @@
min_health *= 10;
num = 0;
}
- }
-
+ }
+
while (1) {
LOCK(&bp->mtx);
vc = TAILQ_FIRST(&bs->connlist);
@@ -255,17 +261,12 @@
assert(vc->backend == bp);
assert(vc->fd >= 0);
TAILQ_REMOVE(&bs->connlist, vc, list);
- vc->priv = bs;
}
UNLOCK(&bp->mtx);
if (vc == NULL)
break;
- /* Test the connection for remote close before we use it */
- pfd.fd = vc->fd;
- pfd.events = POLLIN;
- pfd.revents = 0;
- if (!poll(&pfd, 1, 0)) {
+ if (VBE_CheckFd(vc->fd)) {
/* XXX locking of stats */
VSL_stats->backend_reuse += reuse;
VSL_stats->backend_conn++;
@@ -287,6 +288,7 @@
vc->priv = bs;
VSL_stats->backend_conn++;
return (vc);
+
}
static struct vbe_conn *
@@ -419,14 +421,6 @@
/*--------------------------------------------------------------------*/
-static void
-ber_Init(void)
-{
-
-}
-
-/*--------------------------------------------------------------------*/
-
struct backend_method backend_method_random = {
.name = "random",
.getfd = ber_GetFd,
@@ -435,7 +429,6 @@
.gethostname = ber_GetHostname,
.updatehealth = ber_UpdateHealth,
.cleanup = ber_Cleanup,
- .init = ber_Init
};
/*--------------------------------------------------------------------*/
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-24 11:25:15 UTC (rev 2007)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-24 12:06:20 UTC (rev 2008)
@@ -39,7 +39,6 @@
#include
#include
#include
-#include
#include "shmlog.h"
#include "cache.h"
@@ -75,90 +74,74 @@
int health;
};
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Try to get a socket connected to one of the addresses on the list.
+ * We start from the cached "last good" address and try all items on
+ * the list exactly once.
+ * If a new DNS lookup is made while we try, we start over and try the
+ * new list exactly once.
+ */
static int
brr_conn_try_list(struct sess *sp, struct bspec *bs)
{
struct addrinfo *ai, *from;
- struct sockaddr_storage ss;
- int fam, sockt, proto;
- socklen_t alen;
int s, loops;
- char abuf1[TCP_ADDRBUFSIZE], abuf2[TCP_ADDRBUFSIZE];
- char pbuf1[TCP_PORTBUFSIZE], pbuf2[TCP_PORTBUFSIZE];
unsigned myseq;
+ CHECK_OBJ_NOTNULL(bs, BSPEC_MAGIC);
+ if (bs->addr == NULL)
+ return (-1);
+ AN(bs->last_addr);
+
/* Called with lock held */
myseq = bs->dnsseq;
loops = 0;
- from = bs->last_addr;
- for (ai = from; ai != NULL && (loops != 1 || ai != from);) {
- fam = ai->ai_family;
- sockt = ai->ai_socktype;
- proto = ai->ai_protocol;
- alen = ai->ai_addrlen;
- assert(alen <= sizeof ss);
- memcpy(&ss, ai->ai_addr, alen);
- UNLOCK(&sp->backend->mtx);
- s = socket(fam, sockt, proto);
- if (s >= 0 && connect(s, (void *)&ss, alen)) {
- AZ(close(s));
- s = -1;
- }
- if (s >= 0) {
- TCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1);
- TCP_name((void*)&ss, alen,
- abuf2, sizeof abuf2, pbuf2, sizeof pbuf2);
- WSL(sp->wrk, SLT_BackendOpen, s, "%s %s %s %s %s",
- sp->backend->vcl_name, abuf1, pbuf1, abuf2, pbuf2);
- }
- LOCK(&sp->backend->mtx);
- if (s >= 0) {
+ ai = from = bs->last_addr;
+ while (1) {
+
+ /* NB: releases/acquires lock */
+ s = VBE_TryConnect(sp, ai);
+
+ if (s >= 0) {
+ /* Update cached "last good" if still valid */
if (myseq == bs->dnsseq)
bs->last_addr = ai;
return (s);
}
+
if (myseq != bs->dnsseq) {
+ /* A DNS-lookup happended, try again from start */
loops = 0;
from = bs->last_addr;
ai = from;
} else {
+ /* Try next one */
ai = ai->ai_next;
if (ai == NULL) {
loops++;
ai = bs->addr;
}
}
+ if (loops == 1 && ai == from)
+ return (-1);
}
- return (-1);
}
/*--------------------------------------------------------------------*/
-static int
-brr_conn_try(struct sess *sp, struct backend *bp, struct bspec *bs)
+static const char *
+brr_dns_lookup(struct backend *bp, struct bspec *bs)
{
- int s;
struct addrinfo *res, hint, *old;
int error;
- LOCK(&bp->mtx);
+ CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
+ CHECK_OBJ_NOTNULL(bs, BSPEC_MAGIC);
- s = brr_conn_try_list(sp, bs);
- if (s >= 0) {
- bp->refcount++;
- UNLOCK(&bp->mtx);
- return (s);
- }
-
- if (bs->dnstime + bs->dnsttl >= TIM_mono()) {
- UNLOCK(&bp->mtx);
- return (-1);
- }
-
- /* Then do another lookup to catch DNS changes */
bs->dnstime = TIM_mono();
+
+ /* Let go of lock while we do sleepable stuff */
UNLOCK(&bp->mtx);
memset(&hint, 0, sizeof hint);
@@ -168,21 +151,44 @@
error = getaddrinfo(bs->hostname,
bs->portname == NULL ? "http" : bs->portname,
&hint, &res);
+ LOCK(&bp->mtx);
if (error) {
if (res != NULL)
freeaddrinfo(res);
- printf("getaddrinfo: %s\n", gai_strerror(error)); /* XXX */
- LOCK(&bp->mtx);
- } else {
- LOCK(&bp->mtx);
- bs->dnsseq++;
- old = bs->addr;
- bs->last_addr = res;
- bs->addr = res;
- if (old != NULL)
- freeaddrinfo(old);
+ return(gai_strerror(error));
+ }
+ bs->dnsseq++;
+ old = bs->addr;
+ bs->last_addr = res;
+ bs->addr = res;
+ if (old != NULL)
+ freeaddrinfo(old);
+ return (NULL);
+}
+
+/*--------------------------------------------------------------------*/
+
+static int
+brr_conn_try(struct sess *sp, struct backend *bp, struct bspec *bs)
+{
+ int s;
+
+ LOCK(&bp->mtx);
+
+ s = brr_conn_try_list(sp, bs);
+ if (s >= 0) {
+ bp->refcount++;
+ UNLOCK(&bp->mtx);
+ return (s);
}
+ if (bs->dnstime + bs->dnsttl >= TIM_mono()) {
+ UNLOCK(&bp->mtx);
+ return (-1);
+ }
+
+ (void)brr_dns_lookup(bp, bs);
+
/* And try the entire list */
s = brr_conn_try_list(sp, bs);
if (s >= 0) {
@@ -212,7 +218,6 @@
brr_nextfd(struct sess *sp)
{
struct vbe_conn *vc;
- struct pollfd pfd;
struct backend *bp;
int reuse = 0;
struct brr *brr;
@@ -233,7 +238,7 @@
num = 0;
}
} while (bs->health < min_health);
-
+
while (1) {
LOCK(&bp->mtx);
vc = TAILQ_FIRST(&bs->connlist);
@@ -242,17 +247,12 @@
assert(vc->backend == bp);
assert(vc->fd >= 0);
TAILQ_REMOVE(&bs->connlist, vc, list);
- vc->priv = bs;
}
UNLOCK(&bp->mtx);
if (vc == NULL)
break;
- /* Test the connection for remote close before we use it */
- pfd.fd = vc->fd;
- pfd.events = POLLIN;
- pfd.revents = 0;
- if (!poll(&pfd, 1, 0)) {
+ if (VBE_CheckFd(vc->fd)) {
/* XXX locking of stats */
VSL_stats->backend_reuse += reuse;
VSL_stats->backend_conn++;
@@ -407,14 +407,6 @@
/*--------------------------------------------------------------------*/
-static void
-brr_Init(void)
-{
-
-}
-
-/*--------------------------------------------------------------------*/
-
struct backend_method backend_method_round_robin = {
.name = "round_robin",
.getfd = brr_GetFd,
@@ -423,7 +415,6 @@
.gethostname = brr_GetHostname,
.updatehealth = brr_UpdateHealth,
.cleanup = brr_Cleanup,
- .init = brr_Init
};
/*--------------------------------------------------------------------*/
From phk at projects.linpro.no Mon Sep 24 12:27:55 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Mon, 24 Sep 2007 14:27:55 +0200 (CEST)
Subject: r2009 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070924122755.22F031EC2B1@projects.linpro.no>
Author: phk
Date: 2007-09-24 14:27:54 +0200 (Mon, 24 Sep 2007)
New Revision: 2009
Modified:
trunk/varnish-cache/bin/varnishd/heritage.h
trunk/varnish-cache/bin/varnishd/mgt_cli.c
trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
Make the cli_timeout a parameter. The master will wait this long
for the client to reply on the internal CLI pipe.
Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h 2007-09-24 12:06:20 UTC (rev 2008)
+++ trunk/varnish-cache/bin/varnishd/heritage.h 2007-09-24 12:27:54 UTC (rev 2009)
@@ -117,7 +117,8 @@
unsigned backend_http11;
unsigned client_http11;
- /* Ping interval */
+ /* CLI related */
+ unsigned cli_timeout;
unsigned ping_interval;
/* LRU list ordering interval */
Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2007-09-24 12:06:20 UTC (rev 2008)
+++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2007-09-24 12:27:54 UTC (rev 2009)
@@ -49,6 +49,7 @@
#include "cli.h"
#include "vsb.h"
#include "cli_common.h"
+#include "heritage.h"
#include "mgt.h"
#include "mgt_cli.h"
#include "mgt_event.h"
@@ -126,7 +127,7 @@
xxxassert(i == vsb_len(sb));
vsb_delete(sb);
- i = cli_readres(cli_i, &u, &p, 3.0);
+ i = cli_readres(cli_i, &u, &p, params->cli_timeout);
cli_result(cli, u);
cli_out(cli, "%s", p);
free(p);
@@ -247,7 +248,7 @@
return (CLIS_COMMS);
}
- i = cli_readres(cli_i, &u, resp, 5.0);
+ i = cli_readres(cli_i, &u, resp, params->cli_timeout);
if (status != NULL)
*status = u;
return (u == CLIS_OK ? 0 : u);
Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-09-24 12:06:20 UTC (rev 2008)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-09-24 12:27:54 UTC (rev 2009)
@@ -516,6 +516,15 @@
/*--------------------------------------------------------------------*/
static void
+tweak_cli_timeout(struct cli *cli, struct parspec *par, const char *arg)
+{
+ (void)par;
+ tweak_generic_timeout(cli, &master.cli_timeout, arg);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
tweak_ping_interval(struct cli *cli, struct parspec *par, const char *arg)
{
(void)par;
@@ -719,6 +728,10 @@
"backend response."
EXPERIMENTAL,
"off", "bool" },
+ { "cli_timeout", tweak_cli_timeout,
+ "Timeout for the childs replies to CLI requests from "
+ "the master.\n",
+ "5", "seconds" },
{ "ping_interval", tweak_ping_interval,
"Interval between pings from parent to child.\n"
"Zero will disable pinging entirely, which makes "
From phk at projects.linpro.no Mon Sep 24 12:58:14 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Mon, 24 Sep 2007 14:58:14 +0200 (CEST)
Subject: r2010 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070924125814.66BD71EC2B1@projects.linpro.no>
Author: phk
Date: 2007-09-24 14:58:14 +0200 (Mon, 24 Sep 2007)
New Revision: 2010
Modified:
trunk/varnish-cache/bin/varnishd/cache_expire.c
Log:
Remove an assert which isn't valid: we could try to LRU_Touch an
object on deathrow.
Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-09-24 12:27:54 UTC (rev 2009)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-09-24 12:58:14 UTC (rev 2010)
@@ -83,7 +83,6 @@
if (o->lru_stamp + params->lru_timeout < now) {
LOCK(&exp_mtx); /* XXX: should be ..._TRY */
if (o->heap_idx != lru_target) {
- assert(o->heap_idx != 0);
TAILQ_REMOVE(&exp_lru, o, deathrow);
TAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
o->lru_stamp = now;
From phk at projects.linpro.no Mon Sep 24 13:00:33 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Mon, 24 Sep 2007 15:00:33 +0200 (CEST)
Subject: r2011 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070924130033.CD2CB1EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-24 15:00:33 +0200 (Mon, 24 Sep 2007)
New Revision: 2011
Modified:
trunk/varnish-cache/bin/varnishd/cache_expire.c
Log:
Actually, we cannot touch objects on deathrow, so just ignore
any object with heap_idx == 0.
Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-09-24 12:58:14 UTC (rev 2010)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-09-24 13:00:33 UTC (rev 2011)
@@ -82,7 +82,7 @@
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
if (o->lru_stamp + params->lru_timeout < now) {
LOCK(&exp_mtx); /* XXX: should be ..._TRY */
- if (o->heap_idx != lru_target) {
+ if (o->heap_idx != lru_target && o->heap_idx != 0) {
TAILQ_REMOVE(&exp_lru, o, deathrow);
TAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
o->lru_stamp = now;
From cecilihf at projects.linpro.no Mon Sep 24 13:18:04 2007
From: cecilihf at projects.linpro.no (cecilihf at projects.linpro.no)
Date: Mon, 24 Sep 2007 15:18:04 +0200 (CEST)
Subject: r2012 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070924131804.A43B71EC2B2@projects.linpro.no>
Author: cecilihf
Date: 2007-09-24 15:18:04 +0200 (Mon, 24 Sep 2007)
New Revision: 2012
Modified:
trunk/varnish-cache/bin/varnishd/cache_backend.c
trunk/varnish-cache/bin/varnishd/cache_backend_random.c
trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
Log:
Fixes bug #161.
Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-24 13:00:33 UTC (rev 2011)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-24 13:18:04 UTC (rev 2012)
@@ -309,16 +309,25 @@
CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
}
-/* Update health ----------------------------------------------*/
-
+/* Update health ----------------------------------------------------*/
+/* See cache_backend_random.c and/or cache_backend_round_robin.c for
+ * details and comments about this function.
+ */
void
VBE_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int a)
{
struct backend *b;
- CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
- CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
- b = vc->backend;
+ if (vc != NULL) {
+ CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
+ CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC);
+ b = vc->backend;
+ }
+ else {
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
+ b = sp->backend;
+ }
AN(b->method);
if(b->method->updatehealth != NULL)
b->method->updatehealth(sp, vc, a);
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-24 13:00:33 UTC (rev 2011)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-24 13:18:04 UTC (rev 2012)
@@ -397,6 +397,10 @@
/*--------------------------------------------------------------------*/
+/* This should maybe be divided into two separate functions. One for
+ * increasing/decreasing health, and one for "pulling" the health
+ * towards neutral (0) as time passes
+ */
static void
ber_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int add)
{
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-24 13:00:33 UTC (rev 2011)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-24 13:18:04 UTC (rev 2012)
@@ -382,6 +382,10 @@
/*--------------------------------------------------------------------*/
+/* This should maybe be divided into two separate functions. One for
+ * increasing/decreasing health, and one for "pulling" the health
+ * towards neutral (0) as time passes
+ */
static void
brr_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int add)
{
From cecilihf at projects.linpro.no Mon Sep 24 13:21:28 2007
From: cecilihf at projects.linpro.no (cecilihf at projects.linpro.no)
Date: Mon, 24 Sep 2007 15:21:28 +0200 (CEST)
Subject: r2013 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070924132128.204D61EC2B1@projects.linpro.no>
Author: cecilihf
Date: 2007-09-24 15:21:27 +0200 (Mon, 24 Sep 2007)
New Revision: 2013
Modified:
trunk/varnish-cache/bin/varnishd/cache_center.c
Log:
Re-enable the code causing bug #161 (which is now fixed)
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-24 13:18:04 UTC (rev 2012)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-24 13:21:27 UTC (rev 2013)
@@ -431,7 +431,6 @@
/* Experimental. Reduce health parameter of backend towards zero
* if it has been more than a minute since it was checked. */
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
-if (0) {
time_diff = TIM_mono() - sp->backend->last_check;
minutes = time_diff / 60;
if (minutes > sp->backend->minute_limit) {
@@ -439,7 +438,6 @@
sp->backend->health = (int)((double)sp->backend->health / 2);
VBE_UpdateHealth(sp, NULL, 0);
}
-}
VCL_hit_method(sp);
From phk at projects.linpro.no Tue Sep 25 06:44:27 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 08:44:27 +0200 (CEST)
Subject: r2014 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925064427.693A31EC2B2@projects.linpro.no>
Author: phk
Date: 2007-09-25 08:44:27 +0200 (Tue, 25 Sep 2007)
New Revision: 2014
Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
The first of a long sequence of committs, inspired by cranking up FlexeLints
nitpicking to new heights:
Make sure VRT_int_string() has enough room and assert that this was the case.
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-24 13:21:27 UTC (rev 2013)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-25 06:44:27 UTC (rev 2014)
@@ -484,11 +484,11 @@
VRT_int_string(struct sess *sp, int num)
{
char *p;
- int size = 10;
+ int size = 12;
p = WS_Alloc(sp->http->ws, size);
AN(p);
- snprintf(p, size, "%d", num);
+ assert(snprintf(p, size, "%d", num) < size);
return (p);
}
From phk at projects.linpro.no Tue Sep 25 06:46:57 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 08:46:57 +0200 (CEST)
Subject: r2015 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925064657.A4E5C1EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-25 08:46:57 +0200 (Tue, 25 Sep 2007)
New Revision: 2015
Modified:
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Use the correct shmlog function.
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 06:44:27 UTC (rev 2014)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 06:46:57 UTC (rev 2015)
@@ -769,7 +769,7 @@
to->nhd++;
} else {
VSL_stats->losthdr++;
- WSLH(w, SLT_LostHeader, fd, fm, n);
+ WSLR(w, SLT_LostHeader, fd, fm->hd[n].b, fm->hd[n].e);
}
}
@@ -865,7 +865,7 @@
hp->hd[u].b = p;
hp->hd[u].e = p + l;
} else {
- WSLH(w, SLT_LostHeader, fd, hp, u);
+ WSLR(w, SLT_LostHeader, fd, hp->hd[u].b, hp->hd[u].e);
hp->hd[u].b = NULL;
hp->hd[u].e = NULL;
}
From phk at projects.linpro.no Tue Sep 25 06:51:04 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 08:51:04 +0200 (CEST)
Subject: r2016 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925065104.DB29F1EC405@projects.linpro.no>
Author: phk
Date: 2007-09-25 08:51:04 +0200 (Tue, 25 Sep 2007)
New Revision: 2016
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
Log:
When we take the difference between two pointers, the result is technically
signed. pdiff() makes sure we never get a negative value.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 06:46:57 UTC (rev 2015)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 06:51:04 UTC (rev 2016)
@@ -587,3 +587,17 @@
__func__, __FILE__, __LINE__); \
} while (0);
#endif
+
+/*
+ * A normal pointer difference is signed, but we never want a negative value
+ * so this little tool will make sure we don't get that.
+ */
+
+static inline unsigned
+pdiff(const void *b, const void *e)
+{
+
+ assert(b <= e);
+ return
+ ((unsigned)((const unsigned char *)e - (const unsigned char *)b));
+}
From phk at projects.linpro.no Tue Sep 25 06:56:23 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 08:56:23 +0200 (CEST)
Subject: r2017 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925065623.D62841EC2B2@projects.linpro.no>
Author: phk
Date: 2007-09-25 08:56:23 +0200 (Tue, 25 Sep 2007)
New Revision: 2017
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/shmlog.c
Log:
Polish shmlog:
The id argument is a file descriptor, so it should be typed "int".
We must have a fmt argument.
Use pdiff.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 06:51:04 UTC (rev 2016)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 06:56:23 UTC (rev 2017)
@@ -508,10 +508,10 @@
void VSL_Init(void);
#ifdef SHMLOGHEAD_MAGIC
-void VSLR(enum shmlogtag tag, unsigned id, const char *b, const char *e);
-void VSL(enum shmlogtag tag, unsigned id, const char *fmt, ...);
-void WSLR(struct worker *w, enum shmlogtag tag, unsigned id, const char *b, const char *e);
-void WSL(struct worker *w, enum shmlogtag tag, unsigned id, const char *fmt, ...);
+void VSLR(enum shmlogtag tag, int id, const char *b, const char *e);
+void VSL(enum shmlogtag tag, int id, const char *fmt, ...);
+void WSLR(struct worker *w, enum shmlogtag tag, int id, const char *b, const char *e);
+void WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...);
void WSL_Flush(struct worker *w);
#define INCOMPL() do { \
VSL(SLT_Debug, 0, "INCOMPLETE AT: %s(%d)", __func__, __LINE__); \
Modified: trunk/varnish-cache/bin/varnishd/shmlog.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/shmlog.c 2007-09-25 06:51:04 UTC (rev 2016)
+++ trunk/varnish-cache/bin/varnishd/shmlog.c 2007-09-25 06:56:23 UTC (rev 2017)
@@ -83,7 +83,7 @@
/*--------------------------------------------------------------------*/
void
-VSLR(enum shmlogtag tag, unsigned id, const char *b, const char *e)
+VSLR(enum shmlogtag tag, int id, const char *b, const char *e)
{
unsigned char *p;
unsigned l;
@@ -93,7 +93,7 @@
e = strchr(b, '\0');
/* Truncate */
- l = e - b;
+ l = pdiff(b, e);
if (l > 255) {
l = 255;
e = b + l;
@@ -126,12 +126,13 @@
/*--------------------------------------------------------------------*/
void
-VSL(enum shmlogtag tag, unsigned id, const char *fmt, ...)
+VSL(enum shmlogtag tag, int id, const char *fmt, ...)
{
va_list ap;
unsigned char *p;
unsigned n;
+ AN(fmt);
va_start(ap, fmt);
if (strchr(fmt, '%') == NULL) {
@@ -150,11 +151,9 @@
p = logstart + loghead->ptr;
n = 0;
- if (fmt != NULL) {
- n = vsnprintf((char *)(p + 4), 256, fmt, ap);
- if (n > 255)
- n = 255; /* we truncate long fields */
- }
+ n = vsnprintf((char *)(p + 4), 256, fmt, ap);
+ if (n > 255)
+ n = 255; /* we truncate long fields */
p[1] = n & 0xff;
p[2] = (id >> 8) & 0xff;
p[3] = id & 0xff;
@@ -181,7 +180,7 @@
if (w->wlp == w->wlog)
return;
- l = w->wlp - w->wlog;
+ l = pdiff(w->wlog, w->wlp);
LOCKSHM(&vsl_mtx);
VSL_stats->shm_writes++;
VSL_stats->shm_records += w->wlr;
@@ -201,7 +200,7 @@
/*--------------------------------------------------------------------*/
void
-WSLR(struct worker *w, enum shmlogtag tag, unsigned id, const char *b, const char *e)
+WSLR(struct worker *w, enum shmlogtag tag, int id, const char *b, const char *e)
{
unsigned char *p;
unsigned l;
@@ -211,7 +210,7 @@
e = strchr(b, '\0');
/* Truncate */
- l = e - b;
+ l = pdiff(b, e);
if (l > 255) {
l = 255;
e = b + l;
@@ -239,12 +238,13 @@
/*--------------------------------------------------------------------*/
void
-WSL(struct worker *w, enum shmlogtag tag, unsigned id, const char *fmt, ...)
+WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...)
{
va_list ap;
unsigned char *p;
unsigned n;
+ AN(fmt);
va_start(ap, fmt);
if (strchr(fmt, '%') == NULL) {
@@ -260,11 +260,9 @@
p = w->wlp;
n = 0;
- if (fmt != NULL) {
- n = vsnprintf((char *)(p + 4), 256, fmt, ap);
- if (n > 255)
- n = 255; /* we truncate long fields */
- }
+ n = vsnprintf((char *)(p + 4), 256, fmt, ap);
+ if (n > 255)
+ n = 255; /* we truncate long fields */
p[1] = n & 0xff;
p[2] = (id >> 8) & 0xff;
p[3] = id & 0xff;
From phk at projects.linpro.no Tue Sep 25 07:06:19 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 09:06:19 +0200 (CEST)
Subject: r2018 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925070619.330A11EC405@projects.linpro.no>
Author: phk
Date: 2007-09-25 09:06:18 +0200 (Tue, 25 Sep 2007)
New Revision: 2018
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_backend.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/cache_http.c
trunk/varnish-cache/bin/varnishd/cache_vrt.c
trunk/varnish-cache/bin/varnishd/rfc2616.c
trunk/varnish-cache/bin/varnishd/stevedore.c
Log:
Const'ifcation
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 06:56:23 UTC (rev 2017)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 07:06:18 UTC (rev 2018)
@@ -401,7 +401,7 @@
void VBE_UpdateHealth(struct sess *sp, struct vbe_conn *, int);
/* convenience functions for backend methods */
-int VBE_TryConnect(struct sess *sp, struct addrinfo *ai);
+int VBE_TryConnect(const struct sess *sp, const struct addrinfo *ai);
int VBE_CheckFd(int fd);
/* cache_backend_simple.c */
@@ -435,9 +435,9 @@
int Fetch(struct sess *sp);
/* cache_hash.c */
-void HSH_Prealloc(struct sess *sp);
-int HSH_Compare(struct sess *sp, struct objhead *o);
-void HSH_Copy(struct sess *sp, struct objhead *o);
+void HSH_Prealloc(const struct sess *sp);
+int HSH_Compare(const struct sess *sp, const struct objhead *o);
+void HSH_Copy(struct sess *sp, const struct objhead *o);
struct object *HSH_Lookup(struct sess *sp);
void HSH_Unbusy(struct object *o);
void HSH_Ref(struct object *o);
@@ -449,9 +449,9 @@
void HTTP_Init(void);
void http_ClrHeader(struct http *to);
unsigned http_Write(struct worker *w, struct http *hp, int resp);
-void http_CopyResp(struct http *to, struct http *fm);
+void http_CopyResp(struct http *to, const struct http *fm);
void http_SetResp(struct http *to, const char *proto, const char *status, const char *response);
-void http_FilterFields(struct worker *w, int fd, struct http *to, struct http *fm, unsigned how);
+void http_FilterFields(struct worker *w, int fd, struct http *to, const struct http *fm, unsigned how);
void http_FilterHeader(struct sess *sp, unsigned how);
void http_PutProtocol(struct worker *w, int fd, struct http *to, const char *protocol);
void http_PutStatus(struct worker *w, int fd, struct http *to, int status);
@@ -460,11 +460,11 @@
void http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr);
void http_SetH(struct http *to, unsigned n, const char *fm);
void http_Setup(struct http *ht, void *space, unsigned len);
-int http_GetHdr(struct http *hp, const char *hdr, char **ptr);
-int http_GetHdrField(struct http *hp, const char *hdr, const char *field, char **ptr);
-int http_GetStatus(struct http *hp);
-const char *http_GetReq(struct http *hp);
-const char *http_GetProto(struct http *hp);
+int http_GetHdr(const struct http *hp, const char *hdr, char **ptr);
+int http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr);
+int http_GetStatus(const struct http *hp);
+const char *http_GetReq(const struct http *hp);
+const char *http_GetProto(const struct http *hp);
int http_HdrIs(struct http *hp, const char *hdr, const char *val);
int http_GetTail(struct http *hp, unsigned len, char **b, char **e);
int http_Read(struct http *hp, int fd, void *b, unsigned len);
Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-25 06:56:23 UTC (rev 2017)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-25 07:06:18 UTC (rev 2018)
@@ -62,7 +62,7 @@
*/
int
-VBE_TryConnect(struct sess *sp, struct addrinfo *ai)
+VBE_TryConnect(const struct sess *sp, const struct addrinfo *ai)
{
struct sockaddr_storage ss;
int fam, sockt, proto;
@@ -337,7 +337,7 @@
/*--------------------------------------------------------------------*/
static void
-VBE_AddBackendMethod(struct backend_method *bem)
+VBE_AddBackendMethod(const struct backend_method *bem)
{
if (bem->init != NULL)
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-25 06:56:23 UTC (rev 2017)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-25 07:06:18 UTC (rev 2018)
@@ -49,7 +49,7 @@
/*--------------------------------------------------------------------*/
static int
-fetch_straight(struct sess *sp, int fd, struct http *hp, char *b)
+fetch_straight(struct sess *sp, int fd, struct http *hp, const char *b)
{
int i;
unsigned char *p;
Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-25 06:56:23 UTC (rev 2017)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-25 07:06:18 UTC (rev 2018)
@@ -67,7 +67,7 @@
/* Precreate an objhead and object for later use */
void
-HSH_Prealloc(struct sess *sp)
+HSH_Prealloc(const struct sess *sp)
{
struct worker *w;
@@ -110,7 +110,7 @@
}
int
-HSH_Compare(struct sess *sp, struct objhead *obj)
+HSH_Compare(const struct sess *sp, const struct objhead *obj)
{
int i;
unsigned u, v;
@@ -138,7 +138,7 @@
}
void
-HSH_Copy(struct sess *sp, struct objhead *obj)
+HSH_Copy(struct sess *sp, const struct objhead *obj)
{
unsigned u, v;
char *b;
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 06:56:23 UTC (rev 2017)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 07:06:18 UTC (rev 2018)
@@ -79,7 +79,7 @@
};
static enum shmlogtag
-http2shmlog(struct http *hp, enum httptag t)
+http2shmlog(const struct http *hp, enum httptag t)
{
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
@@ -89,7 +89,7 @@
}
static void
-WSLH(struct worker *w, enum httptag t, unsigned fd, struct http *hp, int hdr)
+WSLH(struct worker *w, enum httptag t, unsigned fd, const struct http *hp, int hdr)
{
WSLR(w, http2shmlog(hp, t), fd, hp->hd[hdr].b, hp->hd[hdr].e);
@@ -174,7 +174,7 @@
static int
-http_IsHdr(struct http_hdr *hh, const char *hdr)
+http_IsHdr(const struct http_hdr *hh, const char *hdr)
{
unsigned l;
@@ -191,7 +191,7 @@
/*--------------------------------------------------------------------*/
static unsigned
-http_findhdr(struct http *hp, unsigned l, const char *hdr)
+http_findhdr(const struct http *hp, unsigned l, const char *hdr)
{
unsigned u;
@@ -210,7 +210,7 @@
}
int
-http_GetHdr(struct http *hp, const char *hdr, char **ptr)
+http_GetHdr(const struct http *hp, const char *hdr, char **ptr)
{
unsigned u, l;
char *p;
@@ -234,7 +234,7 @@
/*--------------------------------------------------------------------*/
int
-http_GetHdrField(struct http *hp, const char *hdr, const char *field, char **ptr)
+http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr)
{
char *h;
int fl;
@@ -373,7 +373,7 @@
/*--------------------------------------------------------------------*/
int
-http_GetStatus(struct http *hp)
+http_GetStatus(const struct http *hp)
{
AN(hp->hd[HTTP_HDR_STATUS].b);
@@ -382,14 +382,14 @@
}
const char *
-http_GetProto(struct http *hp)
+http_GetProto(const struct http *hp)
{
AN(hp->hd[HTTP_HDR_PROTO].b);
return (hp->hd[HTTP_HDR_PROTO].b);
}
const char *
-http_GetReq(struct http *hp)
+http_GetReq(const struct http *hp)
{
AN(hp->hd[HTTP_HDR_REQ].b);
return (hp->hd[HTTP_HDR_REQ].b);
@@ -704,7 +704,7 @@
}
static void
-http_copyh(struct http *to, struct http *fm, unsigned n)
+http_copyh(struct http *to, const struct http *fm, unsigned n)
{
assert(n < HTTP_HDR_MAX);
@@ -715,7 +715,7 @@
}
static void
-http_copyreq(struct http *to, struct http *fm, int transparent)
+http_copyreq(struct http *to, const struct http *fm, int transparent)
{
CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
@@ -732,7 +732,7 @@
}
void
-http_CopyResp(struct http *to, struct http *fm)
+http_CopyResp(struct http *to, const struct http *fm)
{
CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
@@ -756,7 +756,7 @@
}
static void
-http_copyheader(struct worker *w, int fd, struct http *to, struct http *fm, unsigned n)
+http_copyheader(struct worker *w, int fd, struct http *to, const struct http *fm, unsigned n)
{
CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
@@ -776,7 +776,7 @@
/*--------------------------------------------------------------------*/
void
-http_FilterFields(struct worker *w, int fd, struct http *to, struct http *fm, unsigned how)
+http_FilterFields(struct worker *w, int fd, struct http *to, const struct http *fm, unsigned how)
{
unsigned u;
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-25 06:56:23 UTC (rev 2017)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-25 07:06:18 UTC (rev 2018)
@@ -75,7 +75,7 @@
/*--------------------------------------------------------------------*/
static struct http *
-vrt_selecthttp(struct sess *sp, enum gethdr_e where)
+vrt_selecthttp(const struct sess *sp, enum gethdr_e where)
{
struct http *hp;
Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/rfc2616.c 2007-09-25 06:56:23 UTC (rev 2017)
+++ trunk/varnish-cache/bin/varnishd/rfc2616.c 2007-09-25 07:06:18 UTC (rev 2018)
@@ -99,7 +99,7 @@
#endif
static double
-RFC2616_Ttl(struct sess *sp, struct http *hp, struct object *obj)
+RFC2616_Ttl(const struct sess *sp, struct http *hp, struct object *obj)
{
int retirement_age;
unsigned u1, u2;
Modified: trunk/varnish-cache/bin/varnishd/stevedore.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.c 2007-09-25 06:56:23 UTC (rev 2017)
+++ trunk/varnish-cache/bin/varnishd/stevedore.c 2007-09-25 07:06:18 UTC (rev 2018)
@@ -92,7 +92,7 @@
}
static int
-cmp_storage(struct stevedore *s, const char *p, const char *q)
+cmp_storage(const struct stevedore *s, const const char *p, const char *q)
{
if (strlen(s->name) != q - p)
return (1);
From phk at projects.linpro.no Tue Sep 25 07:08:07 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 09:08:07 +0200 (CEST)
Subject: r2019 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925070807.91DD71EC514@projects.linpro.no>
Author: phk
Date: 2007-09-25 09:08:07 +0200 (Tue, 25 Sep 2007)
New Revision: 2019
Modified:
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Make id type "int"
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 07:06:18 UTC (rev 2018)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 07:08:07 UTC (rev 2019)
@@ -89,7 +89,7 @@
}
static void
-WSLH(struct worker *w, enum httptag t, unsigned fd, const struct http *hp, int hdr)
+WSLH(struct worker *w, enum httptag t, int fd, const struct http *hp, int hdr)
{
WSLR(w, http2shmlog(hp, t), fd, hp->hd[hdr].b, hp->hd[hdr].e);
From phk at projects.linpro.no Tue Sep 25 07:11:33 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 09:11:33 +0200 (CEST)
Subject: r2020 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925071133.46C331EC405@projects.linpro.no>
Author: phk
Date: 2007-09-25 09:11:33 +0200 (Tue, 25 Sep 2007)
New Revision: 2020
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/cache_http.c
trunk/varnish-cache/bin/varnishd/stevedore.c
Log:
More const polishing
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 07:08:07 UTC (rev 2019)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 07:11:33 UTC (rev 2020)
@@ -437,7 +437,7 @@
/* cache_hash.c */
void HSH_Prealloc(const struct sess *sp);
int HSH_Compare(const struct sess *sp, const struct objhead *o);
-void HSH_Copy(struct sess *sp, const struct objhead *o);
+void HSH_Copy(const struct sess *sp, const struct objhead *o);
struct object *HSH_Lookup(struct sess *sp);
void HSH_Unbusy(struct object *o);
void HSH_Ref(struct object *o);
@@ -465,7 +465,7 @@
int http_GetStatus(const struct http *hp);
const char *http_GetReq(const struct http *hp);
const char *http_GetProto(const struct http *hp);
-int http_HdrIs(struct http *hp, const char *hdr, const char *val);
+int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
int http_GetTail(struct http *hp, unsigned len, char **b, char **e);
int http_Read(struct http *hp, int fd, void *b, unsigned len);
void http_RecvPrep(struct http *hp);
Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-25 07:08:07 UTC (rev 2019)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-25 07:11:33 UTC (rev 2020)
@@ -138,7 +138,7 @@
}
void
-HSH_Copy(struct sess *sp, const struct objhead *obj)
+HSH_Copy(const struct sess *sp, const struct objhead *obj)
{
unsigned u, v;
char *b;
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 07:08:07 UTC (rev 2019)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 07:11:33 UTC (rev 2020)
@@ -304,7 +304,7 @@
/*--------------------------------------------------------------------*/
int
-http_HdrIs(struct http *hp, const char *hdr, const char *val)
+http_HdrIs(const struct http *hp, const const char *hdr, const char *val)
{
char *p;
Modified: trunk/varnish-cache/bin/varnishd/stevedore.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.c 2007-09-25 07:08:07 UTC (rev 2019)
+++ trunk/varnish-cache/bin/varnishd/stevedore.c 2007-09-25 07:11:33 UTC (rev 2020)
@@ -92,7 +92,7 @@
}
static int
-cmp_storage(const struct stevedore *s, const const char *p, const char *q)
+cmp_storage(const struct stevedore *s, const char *p, const char *q)
{
if (strlen(s->name) != q - p)
return (1);
From phk at projects.linpro.no Tue Sep 25 07:12:18 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 09:12:18 +0200 (CEST)
Subject: r2021 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925071218.D74611EC514@projects.linpro.no>
Author: phk
Date: 2007-09-25 09:12:18 +0200 (Tue, 25 Sep 2007)
New Revision: 2021
Modified:
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Two consts is one const too many.
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 07:11:33 UTC (rev 2020)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 07:12:18 UTC (rev 2021)
@@ -304,7 +304,7 @@
/*--------------------------------------------------------------------*/
int
-http_HdrIs(const struct http *hp, const const char *hdr, const char *val)
+http_HdrIs(const struct http *hp, const char *hdr, const char *val)
{
char *p;
From phk at projects.linpro.no Tue Sep 25 07:19:54 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 09:19:54 +0200 (CEST)
Subject: r2022 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925071954.F1F271EC405@projects.linpro.no>
Author: phk
Date: 2007-09-25 09:19:54 +0200 (Tue, 25 Sep 2007)
New Revision: 2022
Modified:
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/cache_http.c
trunk/varnish-cache/bin/varnishd/hash_classic.c
Log:
Use pdiff() to guard against negative point differences
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-25 07:12:18 UTC (rev 2021)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-25 07:19:54 UTC (rev 2022)
@@ -157,7 +157,7 @@
v = u;
/* Handle anything left in our buffer first */
- i = bp - q;
+ i = pdiff(q, bp);
assert(i >= 0);
if (i > v)
i = v;
@@ -188,7 +188,7 @@
assert(u == 0);
/* We might still have stuff in our buffer */
- v = bp - q;
+ v = pdiff(q, bp);
if (v > 0)
memcpy(buf, q, v);
q = bp = buf + v;
@@ -322,7 +322,7 @@
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
/* Filter into object */
hp2 = &sp->obj->http;
- len = hp->rx_e - hp->rx_s;
+ len = pdiff(hp->rx_s, hp->rx_e);
len += 256; /* margin for content-length etc */
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-25 07:12:18 UTC (rev 2021)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-25 07:19:54 UTC (rev 2022)
@@ -121,7 +121,7 @@
return (i);
b = obj->hash;
for (u = 0; u < sp->ihashptr; u += 2) {
- v = sp->hashptr[u + 1] - sp->hashptr[u];
+ v = pdiff(sp->hashptr[u], sp->hashptr[u + 1]);
i = memcmp(sp->hashptr[u], b, v);
if (i)
return (i);
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 07:12:18 UTC (rev 2021)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 07:19:54 UTC (rev 2022)
@@ -289,7 +289,7 @@
for (q = p + 1; *q; q++)
if (*q == ',' || isspace(*q))
break;
- i = q - p;
+ i = pdiff(p, q);
if (i == 5 && !strncasecmp(p, "close", i))
sp->doclose = "Connection: close";
u = http_findhdr(hp, i, p);
@@ -326,10 +326,10 @@
return (0);
if (len == 0)
- len = hp->pl_e - hp->pl_s;
+ len = pdiff(hp->pl_s, hp->pl_e);
if (hp->pl_s + len > hp->pl_e)
- len = hp->pl_e - hp->pl_s;
+ len = pdiff(hp->pl_s, hp->pl_e);
if (len == 0)
return (0);
*b = hp->pl_s;
@@ -351,7 +351,7 @@
u = 0;
if (hp->pl_s < hp->pl_e) {
- u = hp->pl_e - hp->pl_s;
+ u = pdiff(hp->pl_s, hp->pl_e);
if (u > len)
u = len;
memcpy(b, hp->pl_s, u);
@@ -617,7 +617,7 @@
hp->rx_e = hp->rx_s;
if (hp->pl_s != NULL) {
assert(hp->pl_s < hp->pl_e);
- l = hp->pl_e - hp->pl_s;
+ l = pdiff(hp->pl_s, hp->pl_s);
memmove(hp->rx_s, hp->pl_s, l);
hp->rx_e = hp->rx_s + l;
hp->pl_s = hp->pl_e = NULL;
@@ -642,7 +642,7 @@
unsigned l;
int i;
- l = (hp->ws->e - hp->rx_e) - 1;
+ l = pdiff(hp->rx_e, hp->ws->e) - 1;
l /= 2; /* Don't fill all of workspace with read-ahead */
if (l <= 1) {
VSL(SLT_HttpError, fd, "Received too much");
@@ -857,7 +857,7 @@
WSLH(w, htt, fd, hp, u);
continue;
}
- l = hp->hd[u].e - hp->hd[u].b;
+ l = pdiff(hp->hd[u].b, hp->hd[u].e);
p = WS_Alloc(hp->ws, l + 1);
if (p != NULL) {
WSLH(w, htt, fd, hp, u);
Modified: trunk/varnish-cache/bin/varnishd/hash_classic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-09-25 07:12:18 UTC (rev 2021)
+++ trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-09-25 07:19:54 UTC (rev 2022)
@@ -132,7 +132,7 @@
digest = ~0U;
for (u = 0; u < sp->ihashptr; u += 2) {
- v = sp->hashptr[u + 1] - sp->hashptr[u];
+ v = pdiff(sp->hashptr[u], sp->hashptr[u + 1]);
digest = crc32(digest, sp->hashptr[u], v);
}
digest ^= ~0U;
From phk at projects.linpro.no Tue Sep 25 07:21:40 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 09:21:40 +0200 (CEST)
Subject: r2023 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925072140.D09731EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-25 09:21:40 +0200 (Tue, 25 Sep 2007)
New Revision: 2023
Modified:
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Polish
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 07:19:54 UTC (rev 2022)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 07:21:40 UTC (rev 2023)
@@ -616,7 +616,6 @@
hp->rx_s = hp->ws->f;
hp->rx_e = hp->rx_s;
if (hp->pl_s != NULL) {
- assert(hp->pl_s < hp->pl_e);
l = pdiff(hp->pl_s, hp->pl_s);
memmove(hp->rx_s, hp->pl_s, l);
hp->rx_e = hp->rx_s + l;
@@ -857,7 +856,7 @@
WSLH(w, htt, fd, hp, u);
continue;
}
- l = pdiff(hp->hd[u].b, hp->hd[u].e);
+ l = pdiff(hp->hd[u].b, hp->hd[u].e);
p = WS_Alloc(hp->ws, l + 1);
if (p != NULL) {
WSLH(w, htt, fd, hp, u);
From phk at projects.linpro.no Tue Sep 25 07:22:58 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 09:22:58 +0200 (CEST)
Subject: r2024 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925072258.DF2281EC514@projects.linpro.no>
Author: phk
Date: 2007-09-25 09:22:58 +0200 (Tue, 25 Sep 2007)
New Revision: 2024
Modified:
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
typo
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 07:21:40 UTC (rev 2023)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 07:22:58 UTC (rev 2024)
@@ -616,7 +616,7 @@
hp->rx_s = hp->ws->f;
hp->rx_e = hp->rx_s;
if (hp->pl_s != NULL) {
- l = pdiff(hp->pl_s, hp->pl_s);
+ l = pdiff(hp->pl_s, hp->pl_e);
memmove(hp->rx_s, hp->pl_s, l);
hp->rx_e = hp->rx_s + l;
hp->pl_s = hp->pl_e = NULL;
From phk at projects.linpro.no Tue Sep 25 07:30:38 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 09:30:38 +0200 (CEST)
Subject: r2025 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925073038.B13721EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-25 09:30:38 +0200 (Tue, 25 Sep 2007)
New Revision: 2025
Modified:
trunk/varnish-cache/bin/varnishd/cache_backend.c
trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
trunk/varnish-cache/bin/varnishd/cache_expire.c
trunk/varnish-cache/bin/varnishd/cache_pipe.c
trunk/varnish-cache/bin/varnishd/mgt_cli.c
trunk/varnish-cache/bin/varnishd/mgt_vcc.c
Log:
Assert return values of system{calls,functions}
Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-25 07:22:58 UTC (rev 2024)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-25 07:30:38 UTC (rev 2025)
@@ -92,7 +92,7 @@
}
if (connect(s, (void *)&ss, alen) != 0) {
- close(s);
+ AZ(close(s));
LOCK(&sp->backend->mtx);
return (-1);
}
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-25 07:22:58 UTC (rev 2024)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-25 07:30:38 UTC (rev 2025)
@@ -257,7 +257,7 @@
for (n = 1; n < 5; n++) {
vc = bes_nextfd(sp);
if (vc == NULL) {
- usleep(100000 * n);
+ AZ(usleep(100000 * n));
continue;
}
assert(vc->fd >= 0);
@@ -325,7 +325,7 @@
break;
TAILQ_REMOVE(&bes->connlist, vbe, list);
if (vbe->fd >= 0)
- close(vbe->fd);
+ AZ(close(vbe->fd));
FREE_OBJ(vbe);
}
FREE_OBJ(bes);
Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-09-25 07:22:58 UTC (rev 2024)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-09-25 07:30:38 UTC (rev 2025)
@@ -175,7 +175,7 @@
ww.wlp = ww.wlog;
ww.wle = ww.wlog + sizeof ww.wlog;
- sleep(10); /* Takes time for VCL to arrive */
+ AZ(sleep(10)); /* XXX: Takes time for VCL to arrive */
VCL_Get(&sp->vcl);
t = TIM_real();
while (1) {
Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-09-25 07:22:58 UTC (rev 2024)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-09-25 07:30:38 UTC (rev 2025)
@@ -50,16 +50,16 @@
i = read(fds[idx].fd, buf, sizeof buf);
if (i <= 0 || fds[1-idx].events == 0) {
- shutdown(fds[idx].fd, SHUT_RD);
- shutdown(fds[1-idx].fd, SHUT_WR);
+ AZ(shutdown(fds[idx].fd, SHUT_RD));
+ AZ(shutdown(fds[1-idx].fd, SHUT_WR));
fds[idx].events = 0;
return;
}
for (p = buf; i > 0; i -= j, p += j) {
j = write(fds[1-idx].fd, p, i);
if (j != i) {
- shutdown(fds[idx].fd, SHUT_WR);
- shutdown(fds[1-idx].fd, SHUT_RD);
+ AZ(shutdown(fds[idx].fd, SHUT_WR));
+ AZ(shutdown(fds[1-idx].fd, SHUT_RD));
fds[1-idx].events = 0;
return;
}
Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2007-09-25 07:22:58 UTC (rev 2024)
+++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2007-09-25 07:30:38 UTC (rev 2025)
@@ -345,14 +345,14 @@
cli_close:
vsb_delete(cp->cli->sb);
free(cp->buf);
- close(cp->fdi);
+ AZ(close(cp->fdi));
if (cp->fdi == 0)
- open("/dev/null", O_RDONLY);
- close(cp->fdo);
+ assert(open("/dev/null", O_RDONLY) == 0);
+ AZ(close(cp->fdo));
if (cp->fdo == 1) {
+ assert(open("/dev/null", O_WRONLY) == 1);
close(2);
- open("/dev/null", O_WRONLY);
- open("/dev/null", O_WRONLY);
+ assert(open("/dev/null", O_WRONLY) == 2);
}
free(cp);
return (1);
Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-09-25 07:22:58 UTC (rev 2024)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-09-25 07:30:38 UTC (rev 2025)
@@ -173,8 +173,8 @@
vsb_printf(sb,
"Write error to C source file: %s\n",
strerror(errno));
- unlink(sf);
- fclose(fs);
+ AZ(unlink(sf));
+ AZ(fclose(fs));
return (NULL);
}
rewind(fs);
@@ -216,8 +216,8 @@
"\tcommand attempted: %s\n",
strerror(errno), vsb_data(cccmd));
free(of);
- unlink(sf);
- fclose(fs);
+ AZ(unlink(sf));
+ AZ(fclose(fs));
vsb_delete(cccmd);
return (NULL);
}
@@ -241,8 +241,8 @@
i = pclose(fo);
- unlink(sf);
- fclose(fs);
+ AZ(unlink(sf));
+ AZ(fclose(fs));
if (j == 0 && i != 0) {
vsb_printf(sb,
@@ -262,7 +262,7 @@
/* If the compiler complained, or exited non-zero, fail */
if (i || j) {
- unlink(of);
+ AZ(unlink(of));
free(of);
return (NULL);
}
@@ -272,12 +272,12 @@
if (p == NULL) {
vsb_printf(sb, "Problem loading compiled VCL program:\n\t%s\n",
dlerror());
- unlink(of);
+ AZ(unlink(of));
free(of);
return (NULL);
}
- (void)dlclose(p);
+ AZ(dlclose(p));
return (of);
}
@@ -328,6 +328,7 @@
vp = calloc(sizeof *vp, 1);
XXXAN(vp);
vp->name = strdup(name);
+ XXXAN(vp->name);
vp->fname = file;
TAILQ_INSERT_TAIL(&vclhead, vp, list);
return (vp);
From phk at projects.linpro.no Tue Sep 25 07:32:15 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 09:32:15 +0200 (CEST)
Subject: r2026 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925073215.D61801EC514@projects.linpro.no>
Author: phk
Date: 2007-09-25 09:32:15 +0200 (Tue, 25 Sep 2007)
New Revision: 2026
Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
Bail if we get unknown address families
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-25 07:30:38 UTC (rev 2025)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-25 07:32:15 UTC (rev 2026)
@@ -469,6 +469,8 @@
case AF_INET6:
len = sizeof(struct sockaddr_in6);
break;
+ default:
+ INCOMPL();
}
XXXAN(len);
TCP_name(sa, len, h, sizeof h, p, sizeof p);
From phk at projects.linpro.no Tue Sep 25 07:33:08 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 09:33:08 +0200 (CEST)
Subject: r2027 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925073308.18B691EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-25 09:33:07 +0200 (Tue, 25 Sep 2007)
New Revision: 2027
Modified:
trunk/varnish-cache/bin/varnishd/cache_session.c
Log:
Unnecessary check
Modified: trunk/varnish-cache/bin/varnishd/cache_session.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_session.c 2007-09-25 07:32:15 UTC (rev 2026)
+++ trunk/varnish-cache/bin/varnishd/cache_session.c 2007-09-25 07:33:07 UTC (rev 2027)
@@ -296,8 +296,6 @@
sm->workspace = u;
VSL_stats->n_sess_mem++;
}
- if (sm == NULL)
- return (NULL);
CHECK_OBJ_NOTNULL(sm, SESSMEM_MAGIC);
VSL_stats->n_sess++;
sp = &sm->sess;
From phk at projects.linpro.no Tue Sep 25 07:40:01 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 09:40:01 +0200 (CEST)
Subject: r2028 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925074001.AAA641EC405@projects.linpro.no>
Author: phk
Date: 2007-09-25 09:40:01 +0200 (Tue, 25 Sep 2007)
New Revision: 2028
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/cache_pool.c
trunk/varnish-cache/bin/varnishd/cache_synthetic.c
trunk/varnish-cache/bin/varnishd/mgt_vcc.c
trunk/varnish-cache/bin/varnishd/stevedore.c
Log:
Misc changes:
A couple of XXX comments
Some returnvalue asserts
Some pdiff() uses
Change WRK_Flush() to return unsigned
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 07:33:07 UTC (rev 2027)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 07:40:01 UTC (rev 2028)
@@ -490,7 +490,7 @@
void WRK_Init(void);
void WRK_QueueSession(struct sess *sp);
void WRK_Reset(struct worker *w, int *fd);
-int WRK_Flush(struct worker *w);
+unsigned WRK_Flush(struct worker *w);
unsigned WRK_Write(struct worker *w, const void *ptr, int len);
unsigned WRK_WriteH(struct worker *w, struct http_hdr *hh, const char *suf);
#ifdef HAVE_SENDFILE
Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-25 07:33:07 UTC (rev 2027)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-25 07:40:01 UTC (rev 2028)
@@ -146,7 +146,7 @@
assert(obj->hashlen >= sp->lhashptr);
b = obj->hash;
for (u = 0; u < sp->ihashptr; u += 2) {
- v = sp->hashptr[u + 1] - sp->hashptr[u];
+ v = pdiff(sp->hashptr[u], sp->hashptr[u + 1]);
memcpy(b, sp->hashptr[u], v);
b += v;
*b++ = '#';
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-25 07:33:07 UTC (rev 2027)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-25 07:40:01 UTC (rev 2028)
@@ -91,7 +91,7 @@
w->wfd = fd;
}
-int
+unsigned
WRK_Flush(struct worker *w)
{
int i;
Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-09-25 07:33:07 UTC (rev 2027)
+++ trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-09-25 07:40:01 UTC (rev 2028)
@@ -91,7 +91,7 @@
TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
/* generate body */
- vsb_new(&vsb, (char *)st->ptr, st->space, VSB_FIXEDLEN);
+ AN(vsb_new(&vsb, (char *)st->ptr, st->space, VSB_FIXEDLEN));
vsb_printf(&vsb,
"\n"
"name, dlerror());
cli_result(cli, CLIS_CANT);
- dlclose(dlh);
+ AZ(dlclose(dlh));
} else {
src = sym;
cli_out(cli, src[0]);
/* cli_out(cli, src[1]); */
- dlclose(dlh);
+ AZ(dlclose(dlh));
}
}
}
Modified: trunk/varnish-cache/bin/varnishd/stevedore.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.c 2007-09-25 07:33:07 UTC (rev 2027)
+++ trunk/varnish-cache/bin/varnishd/stevedore.c 2007-09-25 07:40:01 UTC (rev 2028)
@@ -94,9 +94,12 @@
static int
cmp_storage(const struct stevedore *s, const char *p, const char *q)
{
- if (strlen(s->name) != q - p)
+ unsigned u;
+
+ u = pdiff(p, q);
+ if (strlen(s->name) != u)
return (1);
- if (strncmp(s->name, p, q - p))
+ if (strncmp(s->name, p, u))
return (1);
return (0);
}
From phk at projects.linpro.no Tue Sep 25 07:57:07 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 09:57:07 +0200 (CEST)
Subject: r2029 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925075707.0E4A31EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-25 09:57:06 +0200 (Tue, 25 Sep 2007)
New Revision: 2029
Modified:
trunk/varnish-cache/bin/varnishd/shmlog.c
Log:
Make the logic visible for FlexeLint
Modified: trunk/varnish-cache/bin/varnishd/shmlog.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/shmlog.c 2007-09-25 07:40:01 UTC (rev 2028)
+++ trunk/varnish-cache/bin/varnishd/shmlog.c 2007-09-25 07:57:06 UTC (rev 2029)
@@ -178,9 +178,9 @@
unsigned char *p;
unsigned l;
- if (w->wlp == w->wlog)
+ l = pdiff(w->wlog, w->wlp);
+ if (l == 0)
return;
- l = pdiff(w->wlog, w->wlp);
LOCKSHM(&vsl_mtx);
VSL_stats->shm_writes++;
VSL_stats->shm_records += w->wlr;
From phk at projects.linpro.no Tue Sep 25 07:57:22 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 09:57:22 +0200 (CEST)
Subject: r2030 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925075722.06F4A1EC51C@projects.linpro.no>
Author: phk
Date: 2007-09-25 09:57:21 +0200 (Tue, 25 Sep 2007)
New Revision: 2030
Modified:
trunk/varnish-cache/bin/varnishd/flint.lnt
Log:
New more paranoid settings for FlexeLint
Modified: trunk/varnish-cache/bin/varnishd/flint.lnt
===================================================================
--- trunk/varnish-cache/bin/varnishd/flint.lnt 2007-09-25 07:57:06 UTC (rev 2029)
+++ trunk/varnish-cache/bin/varnishd/flint.lnt 2007-09-25 07:57:21 UTC (rev 2030)
@@ -17,6 +17,7 @@
-sem(lbv_assert, r_no)
-sem(lbv_xxxassert, r_no)
-sem(WS_Init, custodial(2))
+-sem(http_Setup, custodial(2))
-ffc // No automatic custody
@@ -33,6 +34,8 @@
-emacro((826), TAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small)
+-esym(534, sprintf) // Ignoring return value of function
+-esym(534, asprintf) // Ignoring return value of function
-esym(534, printf) // Ignoring return value of function
-esym(534, fprintf) // Ignoring return value of function
-esym(534, memset) // Ignoring return value of function
@@ -41,7 +44,17 @@
-esym(534, strcpy) // Ignoring return value of function
-esym(534, vsb_printf) // Ignoring return value of function
-esym(534, vsb_cat) // Ignoring return value of function
+-esym(534, vsb_bcat) // Ignoring return value of function
+-esym(534, vsb_putc) // Ignoring return value of function
+-esym(534, strcat) // Ignoring return value of function
+-esym(534, strcpy) // Ignoring return value of function
+-esym(534, strlcpy) // Ignoring return value of function
+-emacro(506, isnan) // constant value boolean
+-emacro(747, isnan) // significant coersion
+-emacro(506, assert) // constant value boolean
+-emacro(774, HTTPH) // always false
+
// cache.h
-emacro(506, INCOMPL) // Constant value Boolean
@@ -57,6 +70,8 @@
// Review all below this line ///////////////////////////////////////////////
+/*
+
-e767 // Macro redef (system queue.h vs ours )
-e574 // Signed-unsigned mix with relational
@@ -71,3 +86,4 @@
-e732 // Loss of sign (arg. no. 2) (int to unsigned
-e737 // [45] Loss of sign in promotion from int to unsigned
+*/
From des at projects.linpro.no Tue Sep 25 08:20:12 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Tue, 25 Sep 2007 10:20:12 +0200 (CEST)
Subject: r2031 - trunk/varnish-cache
Message-ID: <20070925082014.000891EC6F2@projects.linpro.no>
Author: des
Date: 2007-09-25 10:19:50 +0200 (Tue, 25 Sep 2007)
New Revision: 2031
Modified:
trunk/varnish-cache/autogen.des
Log:
Use a config cache.
Modified: trunk/varnish-cache/autogen.des
===================================================================
--- trunk/varnish-cache/autogen.des 2007-09-25 07:57:21 UTC (rev 2030)
+++ trunk/varnish-cache/autogen.des 2007-09-25 08:19:50 UTC (rev 2031)
@@ -11,6 +11,7 @@
export CONFIG_SHELL=/bin/sh
./configure \
+ --config-cache \
--enable-developer-warnings \
--enable-debugging-symbols \
--enable-dependency-tracking \
From des at projects.linpro.no Tue Sep 25 08:21:39 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Tue, 25 Sep 2007 10:21:39 +0200 (CEST)
Subject: r2032 - in trunk/varnish-cache: . bin/varnishadm bin/varnishd
bin/varnishreplay bin/varnishtop lib/libvarnish lib/libvcl
Message-ID: <20070925082139.D7CFF1EC405@projects.linpro.no>
Author: des
Date: 2007-09-25 10:21:28 +0200 (Tue, 25 Sep 2007)
New Revision: 2032
Modified:
trunk/varnish-cache/bin/varnishadm/Makefile.am
trunk/varnish-cache/bin/varnishd/Makefile.am
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/heritage.h
trunk/varnish-cache/bin/varnishd/mgt_event.h
trunk/varnish-cache/bin/varnishd/mgt_vcc.c
trunk/varnish-cache/bin/varnishd/stevedore.h
trunk/varnish-cache/bin/varnishreplay/Makefile.am
trunk/varnish-cache/bin/varnishreplay/varnishreplay.c
trunk/varnish-cache/bin/varnishtop/varnishtop.c
trunk/varnish-cache/configure.ac
trunk/varnish-cache/lib/libvarnish/Makefile.am
trunk/varnish-cache/lib/libvcl/vcc_compile.c
trunk/varnish-cache/lib/libvcl/vcc_compile.h
trunk/varnish-cache/lib/libvcl/vcc_token.c
Log:
Portability: use -lsocket / -lns on systems that need it (read Solaris),
use instead of our own if present.
Modified: trunk/varnish-cache/bin/varnishadm/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishadm/Makefile.am 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/bin/varnishadm/Makefile.am 2007-09-25 08:21:28 UTC (rev 2032)
@@ -13,4 +13,5 @@
varnishadm_LDADD = \
$(top_builddir)/lib/libvarnish/libvarnish.la \
- $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la
+ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
+ ${NET_LIBS}
Modified: trunk/varnish-cache/bin/varnishd/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishd/Makefile.am 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/bin/varnishd/Makefile.am 2007-09-25 08:21:28 UTC (rev 2032)
@@ -70,4 +70,4 @@
$(top_builddir)/lib/libvarnish/libvarnish.la \
$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
$(top_builddir)/lib/libvcl/libvcl.la \
- ${DL_LIBS} ${PTHREAD_LIBS} ${LIBM}
+ ${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${LIBM}
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 08:21:28 UTC (rev 2032)
@@ -36,7 +36,12 @@
#include
#include
+#ifdef HAVE_SYS_QUEUE_H
+#include
+#else
#include "queue.h"
+#endif
+
#include "vsb.h"
#include "libvarnish.h"
Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/bin/varnishd/heritage.h 2007-09-25 08:21:28 UTC (rev 2032)
@@ -32,7 +32,12 @@
*/
#include
+
+#ifdef HAVE_SYS_QUEUE_H
+#include
+#else
#include "queue.h"
+#endif
struct listen_sock {
TAILQ_ENTRY(listen_sock) list;
Modified: trunk/varnish-cache/bin/varnishd/mgt_event.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_event.h 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/bin/varnishd/mgt_event.h 2007-09-25 08:21:28 UTC (rev 2032)
@@ -30,7 +30,12 @@
*/
#include
+
+#ifdef HAVE_SYS_QUEUE_H
+#include
+#else
#include "queue.h"
+#endif
struct ev;
struct evbase;
Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-09-25 08:21:28 UTC (rev 2032)
@@ -44,7 +44,12 @@
#include "compat/asprintf.h"
#endif
#include "vsb.h"
+
+#ifdef HAVE_SYS_QUEUE_H
+#include
+#else
#include "queue.h"
+#endif
#include "libvcl.h"
#include "cli.h"
Modified: trunk/varnish-cache/bin/varnishd/stevedore.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.h 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/bin/varnishd/stevedore.h 2007-09-25 08:21:28 UTC (rev 2032)
@@ -29,7 +29,11 @@
* $Id$
*/
+#ifdef HAVE_SYS_QUEUE_H
+#include
+#else
#include "queue.h"
+#endif
struct stevedore;
struct sess;
Modified: trunk/varnish-cache/bin/varnishreplay/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishreplay/Makefile.am 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/bin/varnishreplay/Makefile.am 2007-09-25 08:21:28 UTC (rev 2032)
@@ -15,5 +15,4 @@
$(top_builddir)/lib/libvarnish/libvarnish.la \
$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
- ${PTHREAD_LIBS}
-
+ ${PTHREAD_LIBS} ${NET_LIBS}
Modified: trunk/varnish-cache/bin/varnishreplay/varnishreplay.c
===================================================================
--- trunk/varnish-cache/bin/varnishreplay/varnishreplay.c 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/bin/varnishreplay/varnishreplay.c 2007-09-25 08:21:28 UTC (rev 2032)
@@ -38,8 +38,13 @@
#include
#include
+#ifdef HAVE_SYS_QUEUE_H
+#include
+#else
+#include "queue.h"
+#endif
+
#include "libvarnish.h"
-#include "queue.h"
#include "varnishapi.h"
#include "vss.h"
Modified: trunk/varnish-cache/bin/varnishtop/varnishtop.c
===================================================================
--- trunk/varnish-cache/bin/varnishtop/varnishtop.c 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/bin/varnishtop/varnishtop.c 2007-09-25 08:21:28 UTC (rev 2032)
@@ -43,11 +43,16 @@
#include
#include
+#ifdef HAVE_SYS_QUEUE_H
+#include
+#else
+#include "queue.h"
+#endif
+
#include "vsb.h"
#include "libvarnish.h"
#include "shmlog.h"
-#include "queue.h"
#include "varnishapi.h"
struct top {
Modified: trunk/varnish-cache/configure.ac
===================================================================
--- trunk/varnish-cache/configure.ac 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/configure.ac 2007-09-25 08:21:28 UTC (rev 2032)
@@ -50,6 +50,14 @@
LIBS="${save_LIBS}"
AC_SUBST(PTHREAD_LIBS)
+save_LIBS="${LIBS}"
+LIBS=""
+AC_CHECK_LIB(socket, socket)
+AC_CHECK_LIB(getaddrinfo, ns)
+NET_LIBS="${LIBS}"
+LIBS="${save_LIBS}"
+AC_SUBST(NET_LIBS)
+
AC_CHECK_LIBM
AC_SUBST(LIBM)
@@ -57,6 +65,7 @@
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
+AC_CHECK_HEADERS([sys/queue.h])
AC_CHECK_HEADERS([sys/socket.h])
AC_CHECK_HEADERS([sys/mount.h])
AC_CHECK_HEADERS([sys/vfs.h])
Modified: trunk/varnish-cache/lib/libvarnish/Makefile.am
===================================================================
--- trunk/varnish-cache/lib/libvarnish/Makefile.am 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/lib/libvarnish/Makefile.am 2007-09-25 08:21:28 UTC (rev 2032)
@@ -20,4 +20,4 @@
libvarnish_la_CFLAGS = -include config.h
-libvarnish_la_LIBADD = ${RT_LIBS}
+libvarnish_la_LIBADD = ${RT_LIBS} ${NET_LIBS}
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c 2007-09-25 08:21:28 UTC (rev 2032)
@@ -60,6 +60,8 @@
* and all the rest...
*/
+#include
+
#include
#include
#include
@@ -69,10 +71,13 @@
#include
#include
-#include
+#ifdef HAVE_SYS_QUEUE_H
+#include
+#else
+#include "queue.h"
+#endif
#include "vsb.h"
-#include "queue.h"
#include "vcc_priv.h"
#include "vcc_compile.h"
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h 2007-09-25 08:21:28 UTC (rev 2032)
@@ -29,7 +29,12 @@
* $Id$
*/
+#ifdef HAVE_SYS_QUEUE_H
+#include
+#else
#include "queue.h"
+#endif
+
#include "vcl_returns.h"
#define INDENT 2
Modified: trunk/varnish-cache/lib/libvcl/vcc_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_token.c 2007-09-25 08:19:50 UTC (rev 2031)
+++ trunk/varnish-cache/lib/libvcl/vcc_token.c 2007-09-25 08:21:28 UTC (rev 2032)
@@ -34,9 +34,14 @@
#include
#include
-#include "vsb.h"
+#ifdef HAVE_SYS_QUEUE_H
+#include
+#else
#include "queue.h"
+#endif
+#include "vsb.h"
+
#include "libvarnish.h"
#include "vcc_priv.h"
#include "vcc_compile.h"
From des at projects.linpro.no Tue Sep 25 08:48:15 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Tue, 25 Sep 2007 10:48:15 +0200 (CEST)
Subject: r2033 - in trunk/varnish-cache: . bin/varnishd bin/varnishreplay
bin/varnishtop include lib/libvcl
Message-ID: <20070925084815.779A21EC21E@projects.linpro.no>
Author: des
Date: 2007-09-25 10:48:14 +0200 (Tue, 25 Sep 2007)
New Revision: 2033
Added:
trunk/varnish-cache/include/vqueue.h
Removed:
trunk/varnish-cache/include/queue.h
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_acceptor.c
trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c
trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c
trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c
trunk/varnish-cache/bin/varnishd/cache_backend.c
trunk/varnish-cache/bin/varnishd/cache_backend_random.c
trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
trunk/varnish-cache/bin/varnishd/cache_ban.c
trunk/varnish-cache/bin/varnishd/cache_expire.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/cache_pool.c
trunk/varnish-cache/bin/varnishd/cache_response.c
trunk/varnish-cache/bin/varnishd/cache_session.c
trunk/varnish-cache/bin/varnishd/cache_synthetic.c
trunk/varnish-cache/bin/varnishd/cache_vcl.c
trunk/varnish-cache/bin/varnishd/hash_classic.c
trunk/varnish-cache/bin/varnishd/hash_simple_list.c
trunk/varnish-cache/bin/varnishd/heritage.h
trunk/varnish-cache/bin/varnishd/mgt_child.c
trunk/varnish-cache/bin/varnishd/mgt_event.c
trunk/varnish-cache/bin/varnishd/mgt_event.h
trunk/varnish-cache/bin/varnishd/mgt_param.c
trunk/varnish-cache/bin/varnishd/mgt_vcc.c
trunk/varnish-cache/bin/varnishd/stevedore.h
trunk/varnish-cache/bin/varnishd/storage_file.c
trunk/varnish-cache/bin/varnishd/varnishd.c
trunk/varnish-cache/bin/varnishreplay/varnishreplay.c
trunk/varnish-cache/bin/varnishtop/varnishtop.c
trunk/varnish-cache/configure.ac
trunk/varnish-cache/include/Makefile.am
trunk/varnish-cache/lib/libvcl/vcc_backend.c
trunk/varnish-cache/lib/libvcl/vcc_compile.c
trunk/varnish-cache/lib/libvcl/vcc_compile.h
trunk/varnish-cache/lib/libvcl/vcc_token.c
trunk/varnish-cache/lib/libvcl/vcc_xref.c
Log:
The previous commit made things worse rather than better, as some systems
have a that differs in small but important details from what
we expect. Replace our "queue.h" (which was taken from NetBSD) with a new
"vqueue.h" which is based on FreeBSD's with the debugging
taken out and a "V" prefix added to everything.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 08:48:14 UTC (rev 2033)
@@ -36,11 +36,7 @@
#include
#include
-#ifdef HAVE_SYS_QUEUE_H
-#include
-#else
-#include "queue.h"
-#endif
+#include "vqueue.h"
#include "vsb.h"
@@ -159,7 +155,7 @@
int pipe[2];
- TAILQ_ENTRY(worker) list;
+ VTAILQ_ENTRY(worker) list;
struct workreq *wrq;
int *wfd;
@@ -178,7 +174,7 @@
};
struct workreq {
- TAILQ_ENTRY(workreq) list;
+ VTAILQ_ENTRY(workreq) list;
struct sess *sess;
};
@@ -189,7 +185,7 @@
struct bereq {
unsigned magic;
#define BEREQ_MAGIC 0x3b6d250c
- TAILQ_ENTRY(bereq) list;
+ VTAILQ_ENTRY(bereq) list;
void *space;
unsigned len;
struct http http[1];
@@ -200,7 +196,7 @@
struct storage {
unsigned magic;
#define STORAGE_MAGIC 0x1a4e51c0
- TAILQ_ENTRY(storage) list;
+ VTAILQ_ENTRY(storage) list;
struct stevedore *stevedore;
void *priv;
@@ -243,13 +239,13 @@
double last_modified;
struct http http;
- TAILQ_ENTRY(object) list;
+ VTAILQ_ENTRY(object) list;
- TAILQ_ENTRY(object) deathrow;
+ VTAILQ_ENTRY(object) deathrow;
- TAILQ_HEAD(, storage) store;
+ VTAILQ_HEAD(, storage) store;
- TAILQ_HEAD(, sess) waitinglist;
+ VTAILQ_HEAD(, sess) waitinglist;
double lru_stamp;
};
@@ -260,7 +256,7 @@
void *hashpriv;
pthread_mutex_t mtx;
- TAILQ_HEAD(,object) objects;
+ VTAILQ_HEAD(,object) objects;
char *hash;
unsigned hashlen;
};
@@ -302,7 +298,7 @@
int err_code;
const char *err_reason;
- TAILQ_ENTRY(sess) list;
+ VTAILQ_ENTRY(sess) list;
struct backend *backend;
struct bereq *bereq;
@@ -328,7 +324,7 @@
struct vbe_conn {
unsigned magic;
#define VBE_CONN_MAGIC 0x0c5e6592
- TAILQ_ENTRY(vbe_conn) list;
+ VTAILQ_ENTRY(vbe_conn) list;
struct backend *backend;
int fd;
void *priv;
@@ -361,7 +357,7 @@
#define BACKEND_MAGIC 0x64c4c7c6
char *vcl_name;
- TAILQ_ENTRY(backend) list;
+ VTAILQ_ENTRY(backend) list;
int refcount;
pthread_mutex_t mtx;
@@ -377,7 +373,7 @@
* NB: This list is not locked, it is only ever manipulated from the
* cachers CLI thread.
*/
-TAILQ_HEAD(backendlist, backend);
+VTAILQ_HEAD(backendlist, backend);
/* Prototypes etc ----------------------------------------------------*/
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -145,7 +145,7 @@
pfd = calloc(sizeof *pfd, heritage.nsocks);
AN(pfd);
i = 0;
- TAILQ_FOREACH(ls, &heritage.socks, list) {
+ VTAILQ_FOREACH(ls, &heritage.socks, list) {
AZ(setsockopt(ls->sock, SOL_SOCKET, SO_LINGER,
&linger, sizeof linger));
pfd[i].events = POLLIN;
@@ -157,7 +157,7 @@
if (params->send_timeout != tv_sndtimeo.tv_sec) {
need_test = 1;
tv_sndtimeo.tv_sec = params->send_timeout;
- TAILQ_FOREACH(ls, &heritage.socks, list)
+ VTAILQ_FOREACH(ls, &heritage.socks, list)
AZ(setsockopt(ls->sock, SOL_SOCKET,
SO_SNDTIMEO,
&tv_sndtimeo, sizeof tv_sndtimeo));
@@ -165,7 +165,7 @@
if (params->sess_timeout != tv_rcvtimeo.tv_sec) {
need_test = 1;
tv_rcvtimeo.tv_sec = params->sess_timeout;
- TAILQ_FOREACH(ls, &heritage.socks, list)
+ VTAILQ_FOREACH(ls, &heritage.socks, list)
AZ(setsockopt(ls->sock, SOL_SOCKET,
SO_RCVTIMEO,
&tv_rcvtimeo, sizeof tv_rcvtimeo));
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -49,7 +49,7 @@
static pthread_t vca_epoll_thread;
static int epfd = -1;
-static TAILQ_HEAD(,sess) sesshead = TAILQ_HEAD_INITIALIZER(sesshead);
+static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead);
static void
vca_add(int fd, void *data)
@@ -86,13 +86,13 @@
i = read(vca_pipes[0], &sp, sizeof sp);
assert(i == sizeof sp);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- TAILQ_INSERT_TAIL(&sesshead, sp, list);
+ VTAILQ_INSERT_TAIL(&sesshead, sp, list);
vca_add(sp->fd, sp);
} else {
CAST_OBJ_NOTNULL(sp, ev.data.ptr, SESS_MAGIC);
i = vca_pollsession(sp);
if (i >= 0) {
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
if (sp->fd != -1)
vca_del(sp->fd);
if (i == 0)
@@ -104,11 +104,11 @@
}
/* check for timeouts */
deadline = TIM_real() - params->sess_timeout;
- TAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) {
+ VTAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) {
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (sp->t_open > deadline)
continue;
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
vca_del(sp->fd);
vca_close_session(sp, "timeout");
SES_Delete(sp);
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -51,7 +51,7 @@
static pthread_t vca_kqueue_thread;
static int kq = -1;
-static TAILQ_HEAD(,sess) sesshead = TAILQ_HEAD_INITIALIZER(sesshead);
+static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead);
#define NKEV 100
@@ -88,7 +88,7 @@
while (i >= sizeof ss[0]) {
CHECK_OBJ_NOTNULL(ss[j], SESS_MAGIC);
assert(ss[j]->fd >= 0);
- TAILQ_INSERT_TAIL(&sesshead, ss[j], list);
+ VTAILQ_INSERT_TAIL(&sesshead, ss[j], list);
vca_kq_sess(ss[j], EV_ADD);
j++;
i -= sizeof ss[0];
@@ -101,7 +101,7 @@
i = vca_pollsession(sp);
if (i == -1)
return;
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
if (i == 0) {
vca_kq_sess(sp, EV_DELETE);
vca_handover(sp, i);
@@ -110,7 +110,7 @@
}
return;
} else if (kp->flags == EV_EOF) {
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
vca_close_session(sp, "EOF");
SES_Delete(sp);
return;
@@ -157,12 +157,12 @@
continue;
deadline = TIM_real() - params->sess_timeout;
for (;;) {
- sp = TAILQ_FIRST(&sesshead);
+ sp = VTAILQ_FIRST(&sesshead);
if (sp == NULL)
break;
if (sp->t_open > deadline)
break;
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
vca_close_session(sp, "timeout");
SES_Delete(sp);
}
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -51,7 +51,7 @@
static struct pollfd *pollfd;
static unsigned npoll;
-static TAILQ_HEAD(,sess) sesshead = TAILQ_HEAD_INITIALIZER(sesshead);
+static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead);
/*--------------------------------------------------------------------*/
@@ -116,11 +116,11 @@
i = read(vca_pipes[0], &sp, sizeof sp);
assert(i == sizeof sp);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- TAILQ_INSERT_TAIL(&sesshead, sp, list);
+ VTAILQ_INSERT_TAIL(&sesshead, sp, list);
vca_poll(sp->fd);
}
deadline = TIM_real() - params->sess_timeout;
- TAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) {
+ VTAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) {
if (v == 0)
break;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -130,7 +130,7 @@
i = vca_pollsession(sp);
if (i < 0)
continue;
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
vca_unpoll(fd);
if (i == 0)
vca_handover(sp, i);
@@ -140,7 +140,7 @@
}
if (sp->t_open > deadline)
continue;
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
vca_unpoll(fd);
vca_close_session(sp, "timeout");
SES_Delete(sp);
Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -44,12 +44,12 @@
#include "shmlog.h"
#include "cache.h"
-static TAILQ_HEAD(,bereq) bereq_head = TAILQ_HEAD_INITIALIZER(bereq_head);
-static TAILQ_HEAD(,vbe_conn) vbe_head = TAILQ_HEAD_INITIALIZER(vbe_head);
+static VTAILQ_HEAD(,bereq) bereq_head = VTAILQ_HEAD_INITIALIZER(bereq_head);
+static VTAILQ_HEAD(,vbe_conn) vbe_head = VTAILQ_HEAD_INITIALIZER(vbe_head);
static MTX VBE_mtx;
-struct backendlist backendlist = TAILQ_HEAD_INITIALIZER(backendlist);
+struct backendlist backendlist = VTAILQ_HEAD_INITIALIZER(backendlist);
/*--------------------------------------------------------------------
@@ -135,9 +135,9 @@
volatile unsigned len;
LOCK(&VBE_mtx);
- bereq = TAILQ_FIRST(&bereq_head);
+ bereq = VTAILQ_FIRST(&bereq_head);
if (bereq != NULL)
- TAILQ_REMOVE(&bereq_head, bereq, list);
+ VTAILQ_REMOVE(&bereq_head, bereq, list);
UNLOCK(&VBE_mtx);
if (bereq != NULL) {
CHECK_OBJ(bereq, BEREQ_MAGIC);
@@ -163,7 +163,7 @@
CHECK_OBJ_NOTNULL(bereq, BEREQ_MAGIC);
LOCK(&VBE_mtx);
- TAILQ_INSERT_HEAD(&bereq_head, bereq, list);
+ VTAILQ_INSERT_HEAD(&bereq_head, bereq, list);
UNLOCK(&VBE_mtx);
}
@@ -174,13 +174,13 @@
{
struct vbe_conn *vc;
- vc = TAILQ_FIRST(&vbe_head);
+ vc = VTAILQ_FIRST(&vbe_head);
if (vc != NULL) {
LOCK(&VBE_mtx);
- vc = TAILQ_FIRST(&vbe_head);
+ vc = VTAILQ_FIRST(&vbe_head);
if (vc != NULL) {
VSL_stats->backend_unused--;
- TAILQ_REMOVE(&vbe_head, vc, list);
+ VTAILQ_REMOVE(&vbe_head, vc, list);
} else {
VSL_stats->n_vbe_conn++;
}
@@ -206,7 +206,7 @@
assert(vc->backend == NULL);
assert(vc->fd < 0);
LOCK(&VBE_mtx);
- TAILQ_INSERT_HEAD(&vbe_head, vc, list);
+ VTAILQ_INSERT_HEAD(&vbe_head, vc, list);
VSL_stats->backend_unused++;
UNLOCK(&VBE_mtx);
}
@@ -229,7 +229,7 @@
b->last_check = TIM_mono();
b->minute_limit = 1;
- TAILQ_INSERT_TAIL(&backendlist, b, list);
+ VTAILQ_INSERT_TAIL(&backendlist, b, list);
return (b);
}
@@ -244,7 +244,7 @@
i = --b->refcount;
if (i == 0)
- TAILQ_REMOVE(&backendlist, b, list);
+ VTAILQ_REMOVE(&backendlist, b, list);
UNLOCK(&b->mtx);
if (i)
return;
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -71,7 +71,7 @@
double dnsttl;
double dnstime;
unsigned dnsseq;
- TAILQ_HEAD(, vbe_conn) connlist;
+ VTAILQ_HEAD(, vbe_conn) connlist;
int health;
};
@@ -255,12 +255,12 @@
while (1) {
LOCK(&bp->mtx);
- vc = TAILQ_FIRST(&bs->connlist);
+ vc = VTAILQ_FIRST(&bs->connlist);
if (vc != NULL) {
bp->refcount++;
assert(vc->backend == bp);
assert(vc->fd >= 0);
- TAILQ_REMOVE(&bs->connlist, vc, list);
+ VTAILQ_REMOVE(&bs->connlist, vc, list);
}
UNLOCK(&bp->mtx);
if (vc == NULL)
@@ -343,7 +343,7 @@
WSL(w, SLT_BackendReuse, vc->fd, "%s", vc->backend->vcl_name);
LOCK(&vc->backend->mtx);
VSL_stats->backend_recycle++;
- TAILQ_INSERT_HEAD(&bs->connlist, vc, list);
+ VTAILQ_INSERT_HEAD(&bs->connlist, vc, list);
VBE_DropRefLocked(vc->backend);
}
@@ -366,10 +366,10 @@
free(bs->hostname);
freeaddrinfo(bs->addr);
while (1) {
- vbe = TAILQ_FIRST(&bs->connlist);
+ vbe = VTAILQ_FIRST(&bs->connlist);
if (vbe == NULL)
break;
- TAILQ_REMOVE(&bs->connlist, vbe, list);
+ VTAILQ_REMOVE(&bs->connlist, vbe, list);
if (vbe->fd >= 0)
close(vbe->fd);
free(vbe);
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -70,7 +70,7 @@
double dnsttl;
double dnstime;
unsigned dnsseq;
- TAILQ_HEAD(, vbe_conn) connlist;
+ VTAILQ_HEAD(, vbe_conn) connlist;
int health;
};
@@ -241,12 +241,12 @@
while (1) {
LOCK(&bp->mtx);
- vc = TAILQ_FIRST(&bs->connlist);
+ vc = VTAILQ_FIRST(&bs->connlist);
if (vc != NULL) {
bp->refcount++;
assert(vc->backend == bp);
assert(vc->fd >= 0);
- TAILQ_REMOVE(&bs->connlist, vc, list);
+ VTAILQ_REMOVE(&bs->connlist, vc, list);
}
UNLOCK(&bp->mtx);
if (vc == NULL)
@@ -328,7 +328,7 @@
WSL(w, SLT_BackendReuse, vc->fd, "%s", vc->backend->vcl_name);
LOCK(&vc->backend->mtx);
VSL_stats->backend_recycle++;
- TAILQ_INSERT_HEAD(&bs->connlist, vc, list);
+ VTAILQ_INSERT_HEAD(&bs->connlist, vc, list);
VBE_DropRefLocked(vc->backend);
}
@@ -351,10 +351,10 @@
free(bs->hostname);
freeaddrinfo(bs->addr);
while (1) {
- vbe = TAILQ_FIRST(&bs->connlist);
+ vbe = VTAILQ_FIRST(&bs->connlist);
if (vbe == NULL)
break;
- TAILQ_REMOVE(&bs->connlist, vbe, list);
+ VTAILQ_REMOVE(&bs->connlist, vbe, list);
if (vbe->fd >= 0)
close(vbe->fd);
free(vbe);
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -55,7 +55,7 @@
double dnsttl;
double dnstime;
unsigned dnsseq;
- TAILQ_HEAD(, vbe_conn) connlist;
+ VTAILQ_HEAD(, vbe_conn) connlist;
};
/*--------------------------------------------------------------------
@@ -213,12 +213,12 @@
CAST_OBJ_NOTNULL(bes, bp->priv, BES_MAGIC);
while (1) {
LOCK(&bp->mtx);
- vc = TAILQ_FIRST(&bes->connlist);
+ vc = VTAILQ_FIRST(&bes->connlist);
if (vc != NULL) {
bp->refcount++;
assert(vc->backend == bp);
assert(vc->fd >= 0);
- TAILQ_REMOVE(&bes->connlist, vc, list);
+ VTAILQ_REMOVE(&bes->connlist, vc, list);
}
UNLOCK(&bp->mtx);
if (vc == NULL)
@@ -302,7 +302,7 @@
WSL(w, SLT_BackendReuse, vc->fd, "%s", vc->backend->vcl_name);
LOCK(&vc->backend->mtx);
VSL_stats->backend_recycle++;
- TAILQ_INSERT_HEAD(&bes->connlist, vc, list);
+ VTAILQ_INSERT_HEAD(&bes->connlist, vc, list);
VBE_DropRefLocked(vc->backend);
}
@@ -320,10 +320,10 @@
free(bes->hostname);
freeaddrinfo(bes->addr);
while (1) {
- vbe = TAILQ_FIRST(&bes->connlist);
+ vbe = VTAILQ_FIRST(&bes->connlist);
if (vbe == NULL)
break;
- TAILQ_REMOVE(&bes->connlist, vbe, list);
+ VTAILQ_REMOVE(&bes->connlist, vbe, list);
if (vbe->fd >= 0)
AZ(close(vbe->fd));
FREE_OBJ(vbe);
@@ -366,7 +366,7 @@
/*
* Scan existing backends to see if we can recycle one of them.
*/
- TAILQ_FOREACH(b, &backendlist, list) {
+ VTAILQ_FOREACH(b, &backendlist, list) {
CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC);
if (b->method != &backend_method_simple)
continue;
Modified: trunk/varnish-cache/bin/varnishd/cache_ban.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_ban.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_ban.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -42,14 +42,14 @@
#include "cache.h"
struct ban {
- TAILQ_ENTRY(ban) list;
+ VTAILQ_ENTRY(ban) list;
unsigned gen;
regex_t regexp;
char *ban;
int hash;
};
-static TAILQ_HEAD(,ban) ban_head = TAILQ_HEAD_INITIALIZER(ban_head);
+static VTAILQ_HEAD(,ban) ban_head = VTAILQ_HEAD_INITIALIZER(ban_head);
static unsigned ban_next;
static struct ban *ban_start;
@@ -72,7 +72,7 @@
b->hash = hash;
b->gen = ++ban_next;
b->ban = strdup(regexp);
- TAILQ_INSERT_HEAD(&ban_head, b, list);
+ VTAILQ_INSERT_HEAD(&ban_head, b, list);
ban_start = b;
}
@@ -92,7 +92,7 @@
b0 = ban_start;
for (b = b0;
b != NULL && b->gen > o->ban_seq;
- b = TAILQ_NEXT(b, list)) {
+ b = VTAILQ_NEXT(b, list)) {
i = regexec(&b->regexp, b->hash ? hash : url, 0, NULL, 0);
if (!i)
return (1);
Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -51,8 +51,8 @@
static struct binheap *exp_heap;
static MTX exp_mtx;
static unsigned expearly = 30;
-static TAILQ_HEAD(,object) exp_deathrow = TAILQ_HEAD_INITIALIZER(exp_deathrow);
-static TAILQ_HEAD(,object) exp_lru = TAILQ_HEAD_INITIALIZER(exp_lru);
+static VTAILQ_HEAD(,object) exp_deathrow = VTAILQ_HEAD_INITIALIZER(exp_deathrow);
+static VTAILQ_HEAD(,object) exp_lru = VTAILQ_HEAD_INITIALIZER(exp_lru);
/*
* This is a magic marker for the objects currently on the SIOP [look it up]
@@ -71,7 +71,7 @@
assert(o->heap_idx == 0);
LOCK(&exp_mtx);
binheap_insert(exp_heap, o);
- TAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
+ VTAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
UNLOCK(&exp_mtx);
}
@@ -83,8 +83,8 @@
if (o->lru_stamp + params->lru_timeout < now) {
LOCK(&exp_mtx); /* XXX: should be ..._TRY */
if (o->heap_idx != lru_target && o->heap_idx != 0) {
- TAILQ_REMOVE(&exp_lru, o, deathrow);
- TAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
+ VTAILQ_REMOVE(&exp_lru, o, deathrow);
+ VTAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
o->lru_stamp = now;
}
UNLOCK(&exp_mtx);
@@ -119,7 +119,7 @@
t = TIM_real();
while (1) {
LOCK(&exp_mtx);
- TAILQ_FOREACH(o, &exp_deathrow, deathrow) {
+ VTAILQ_FOREACH(o, &exp_deathrow, deathrow) {
CHECK_OBJ(o, OBJECT_MAGIC);
if (o->ttl >= t) {
o = NULL;
@@ -139,7 +139,7 @@
t = TIM_real();
continue;
}
- TAILQ_REMOVE(&exp_deathrow, o, deathrow);
+ VTAILQ_REMOVE(&exp_deathrow, o, deathrow);
VSL_stats->n_deathrow--;
VSL_stats->n_expired++;
UNLOCK(&exp_mtx);
@@ -206,8 +206,8 @@
if (sp->handling == VCL_RET_DISCARD) {
LOCK(&exp_mtx);
- TAILQ_REMOVE(&exp_lru, o, deathrow);
- TAILQ_INSERT_TAIL(&exp_deathrow, o, deathrow);
+ VTAILQ_REMOVE(&exp_lru, o, deathrow);
+ VTAILQ_INSERT_TAIL(&exp_deathrow, o, deathrow);
VSL_stats->n_deathrow++;
UNLOCK(&exp_mtx);
continue;
@@ -252,7 +252,7 @@
/* Find the first currently unused object on the LRU */
LOCK(&exp_mtx);
- TAILQ_FOREACH(o, &exp_lru, deathrow)
+ VTAILQ_FOREACH(o, &exp_lru, deathrow)
if (o->refcnt == 1)
break;
if (o != NULL) {
@@ -260,7 +260,7 @@
* Take it off the binheap while we chew. This effectively
* means that we own the EXP refcnt on this object.
*/
- TAILQ_REMOVE(&exp_lru, o, deathrow);
+ VTAILQ_REMOVE(&exp_lru, o, deathrow);
binheap_delete(exp_heap, o->heap_idx);
assert(o->heap_idx == 0);
o->heap_idx = lru_target;
@@ -297,7 +297,7 @@
o->heap_idx = 0;
o->lru_stamp = sp->wrk->used;
binheap_insert(exp_heap, o);
- TAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
+ VTAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
UNLOCK(&exp_mtx);
return (0);
}
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -61,7 +61,7 @@
return (0);
st = STV_alloc(sp, cl);
- TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
+ VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
st->len = cl;
sp->obj->len = cl;
p = st->ptr;
@@ -150,7 +150,7 @@
if (u < params->fetch_chunksize * 1024)
v = params->fetch_chunksize * 1024;
st = STV_alloc(sp, v);
- TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
+ VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
}
v = st->space - st->len;
if (v > u)
@@ -195,7 +195,7 @@
}
if (st != NULL && st->len == 0) {
- TAILQ_REMOVE(&sp->obj->store, st, list);
+ VTAILQ_REMOVE(&sp->obj->store, st, list);
STV_free(st);
} else if (st != NULL)
STV_trim(st, st->len);
@@ -225,7 +225,7 @@
while (1) {
if (v == 0) {
st = STV_alloc(sp, params->fetch_chunksize * 1024);
- TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
+ VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
p = st->ptr + st->len;
v = st->space - st->len;
}
@@ -243,7 +243,7 @@
}
if (st->len == 0) {
- TAILQ_REMOVE(&sp->obj->store, st, list);
+ VTAILQ_REMOVE(&sp->obj->store, st, list);
STV_free(st);
} else
STV_trim(st, st->len);
@@ -371,9 +371,9 @@
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
if (cls < 0) {
- while (!TAILQ_EMPTY(&sp->obj->store)) {
- st = TAILQ_FIRST(&sp->obj->store);
- TAILQ_REMOVE(&sp->obj->store, st, list);
+ while (!VTAILQ_EMPTY(&sp->obj->store)) {
+ st = VTAILQ_FIRST(&sp->obj->store);
+ VTAILQ_REMOVE(&sp->obj->store, st, list);
STV_free(st);
}
VBE_ClosedFd(sp->wrk, vc);
@@ -386,7 +386,7 @@
unsigned uu;
uu = 0;
- TAILQ_FOREACH(st, &sp->obj->store, list)
+ VTAILQ_FOREACH(st, &sp->obj->store, list)
uu += st->len;
assert(uu == sp->obj->len);
}
Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -78,7 +78,7 @@
w->nobjhead = calloc(sizeof *w->nobjhead, 1);
XXXAN(w->nobjhead);
w->nobjhead->magic = OBJHEAD_MAGIC;
- TAILQ_INIT(&w->nobjhead->objects);
+ VTAILQ_INIT(&w->nobjhead->objects);
MTX_INIT(&w->nobjhead->mtx);
VSL_stats->n_objecthead++;
} else
@@ -90,8 +90,8 @@
w->nobj->http.magic = HTTP_MAGIC;
w->nobj->busy = 1;
w->nobj->refcnt = 1;
- TAILQ_INIT(&w->nobj->store);
- TAILQ_INIT(&w->nobj->waitinglist);
+ VTAILQ_INIT(&w->nobj->store);
+ VTAILQ_INIT(&w->nobj->waitinglist);
VSL_stats->n_object++;
} else
CHECK_OBJ_NOTNULL(w->nobj, OBJECT_MAGIC);
@@ -102,9 +102,9 @@
{
struct storage *st, *stn;
- TAILQ_FOREACH_SAFE(st, &o->store, list, stn) {
+ VTAILQ_FOREACH_SAFE(st, &o->store, list, stn) {
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
- TAILQ_REMOVE(&o->store, st, list);
+ VTAILQ_REMOVE(&o->store, st, list);
STV_free(st);
}
}
@@ -186,10 +186,10 @@
if (oh == w->nobjhead)
w->nobjhead = NULL;
LOCK(&oh->mtx);
- TAILQ_FOREACH(o, &oh->objects, list) {
+ VTAILQ_FOREACH(o, &oh->objects, list) {
o->refcnt++;
if (o->busy) {
- TAILQ_INSERT_TAIL(&o->waitinglist, sp, list);
+ VTAILQ_INSERT_TAIL(&o->waitinglist, sp, list);
sp->obj = o;
UNLOCK(&oh->mtx);
return (NULL);
@@ -221,7 +221,7 @@
o = w->nobj;
w->nobj = NULL;
o->objhead = oh;
- TAILQ_INSERT_TAIL(&oh->objects, o, list);
+ VTAILQ_INSERT_TAIL(&oh->objects, o, list);
/* NB: do not deref objhead the new object inherits our reference */
UNLOCK(&oh->mtx);
BAN_NewObj(o);
@@ -253,10 +253,10 @@
if (oh != NULL)
UNLOCK(&oh->mtx);
while (1) {
- sp = TAILQ_FIRST(&o->waitinglist);
+ sp = VTAILQ_FIRST(&o->waitinglist);
if (sp == NULL)
break;
- TAILQ_REMOVE(&o->waitinglist, sp, list);
+ VTAILQ_REMOVE(&o->waitinglist, sp, list);
WRK_QueueSession(sp);
}
}
@@ -296,7 +296,7 @@
r = --o->refcnt;
if (oh != NULL) {
if (!r)
- TAILQ_REMOVE(&oh->objects, o, list);
+ VTAILQ_REMOVE(&oh->objects, o, list);
UNLOCK(&oh->mtx);
}
@@ -319,7 +319,7 @@
/* Drop our ref on the objhead */
if (hash->deref(oh))
return;
- assert(TAILQ_EMPTY(&oh->objects));
+ assert(VTAILQ_EMPTY(&oh->objects));
MTX_DESTROY(&oh->mtx);
VSL_stats->n_objecthead--;
FREE_OBJ(oh);
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -57,7 +57,7 @@
#include "cli_priv.h"
#include "cache.h"
-TAILQ_HEAD(workerhead, worker);
+VTAILQ_HEAD(workerhead, worker);
/* Number of work requests queued in excess of worker threads available */
@@ -68,7 +68,7 @@
};
static MTX tmtx;
-static TAILQ_HEAD(, workreq) overflow = TAILQ_HEAD_INITIALIZER(overflow);
+static VTAILQ_HEAD(, workreq) overflow = VTAILQ_HEAD_INITIALIZER(overflow);
static struct wq **wq;
static unsigned nwq;
@@ -221,21 +221,21 @@
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
assert(!isnan(w->used));
- w->wrq = TAILQ_FIRST(&overflow);
+ w->wrq = VTAILQ_FIRST(&overflow);
if (w->wrq != NULL) {
LOCK(&tmtx);
/* Process overflow requests, if any */
- w->wrq = TAILQ_FIRST(&overflow);
+ w->wrq = VTAILQ_FIRST(&overflow);
if (w->wrq != NULL) {
VSL_stats->n_wrk_queue--;
- TAILQ_REMOVE(&overflow, w->wrq, list);
+ VTAILQ_REMOVE(&overflow, w->wrq, list);
}
UNLOCK(&tmtx);
}
if (w->wrq == NULL) {
LOCK(&qp->mtx);
- TAILQ_INSERT_HEAD(&qp->idle, w, list);
+ VTAILQ_INSERT_HEAD(&qp->idle, w, list);
UNLOCK(&qp->mtx);
assert(1 == read(w->pipe[0], &c, 1));
}
@@ -286,9 +286,9 @@
LOCK(&qp->mtx);
/* If there are idle threads, we tickle the first one into action */
- w = TAILQ_FIRST(&qp->idle);
+ w = VTAILQ_FIRST(&qp->idle);
if (w != NULL) {
- TAILQ_REMOVE(&qp->idle, w, list);
+ VTAILQ_REMOVE(&qp->idle, w, list);
UNLOCK(&qp->mtx);
w->wrq = &sp->workreq;
assert(1 == write(w->pipe[1], w, 1));
@@ -321,7 +321,7 @@
* XXX: Not sure how though. Simply closing may be the better
* XXX: compromise.
*/
- TAILQ_INSERT_TAIL(&overflow, &sp->workreq, list);
+ VTAILQ_INSERT_TAIL(&overflow, &sp->workreq, list);
VSL_stats->n_wrk_overflow++;
VSL_stats->n_wrk_queue++;
/* Can we create more threads ? */
@@ -375,7 +375,7 @@
wq[u] = calloc(sizeof *wq[u], 1);
XXXAN(wq[u]);
MTX_INIT(&wq[u]->mtx);
- TAILQ_INIT(&wq[u]->idle);
+ VTAILQ_INIT(&wq[u]->idle);
}
free(owq);
nwq = t;
@@ -401,11 +401,11 @@
for (u = 0; u < nwq; u++) {
qp = wq[u];
LOCK(&qp->mtx);
- w = TAILQ_LAST(&qp->idle, workerhead);
+ w = VTAILQ_LAST(&qp->idle, workerhead);
if (w != NULL &&
(w->used + params->wthread_timeout < now ||
VSL_stats->n_wrk > params->wthread_max))
- TAILQ_REMOVE(&qp->idle, w, list);
+ VTAILQ_REMOVE(&qp->idle, w, list);
else
w = NULL;
UNLOCK(&qp->mtx);
Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -158,7 +158,7 @@
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (sp->wantbody) {
- TAILQ_FOREACH(st, &sp->obj->store, list) {
+ VTAILQ_FOREACH(st, &sp->obj->store, list) {
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
u += st->len;
Modified: trunk/varnish-cache/bin/varnishd/cache_session.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_session.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_session.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -67,13 +67,13 @@
struct sess sess;
struct http http;
unsigned workspace;
- TAILQ_ENTRY(sessmem) list;
+ VTAILQ_ENTRY(sessmem) list;
struct sockaddr_storage sockaddr[2];
};
-static TAILQ_HEAD(,sessmem) ses_free_mem[2] = {
- TAILQ_HEAD_INITIALIZER(ses_free_mem[0]),
- TAILQ_HEAD_INITIALIZER(ses_free_mem[1]),
+static VTAILQ_HEAD(,sessmem) ses_free_mem[2] = {
+ VTAILQ_HEAD_INITIALIZER(ses_free_mem[0]),
+ VTAILQ_HEAD_INITIALIZER(ses_free_mem[1]),
};
static unsigned ses_qp;
@@ -86,7 +86,7 @@
#define SRCADDR_MAGIC 0x375111db
unsigned hash;
- TAILQ_ENTRY(srcaddr) list;
+ VTAILQ_ENTRY(srcaddr) list;
struct srcaddrhead *sah;
char addr[TCP_ADDRBUFSIZE];
@@ -101,7 +101,7 @@
static struct srcaddrhead {
unsigned magic;
#define SRCADDRHEAD_MAGIC 0x38231a8b
- TAILQ_HEAD(,srcaddr) head;
+ VTAILQ_HEAD(,srcaddr) head;
MTX mtx;
} *srchash;
@@ -141,17 +141,17 @@
LOCK(&ch->mtx);
c3 = NULL;
- TAILQ_FOREACH_SAFE(c, &ch->head, list, c2) {
+ VTAILQ_FOREACH_SAFE(c, &ch->head, list, c2) {
if (c->hash == u && !strcmp(c->addr, sp->addr)) {
if (c->nref == 0)
VSL_stats->n_srcaddr_act++;
c->nref++;
c->ttl = now + params->srcaddr_ttl;
sp->srcaddr = c;
- TAILQ_REMOVE(&ch->head, c, list);
- TAILQ_INSERT_TAIL(&ch->head, c, list);
+ VTAILQ_REMOVE(&ch->head, c, list);
+ VTAILQ_INSERT_TAIL(&ch->head, c, list);
if (c3 != NULL) {
- TAILQ_REMOVE(&ch->head, c3, list);
+ VTAILQ_REMOVE(&ch->head, c3, list);
VSL_stats->n_srcaddr--;
}
UNLOCK(&ch->mtx);
@@ -169,7 +169,7 @@
sp->wrk->srcaddr = NULL;
VSL_stats->n_srcaddr++;
} else
- TAILQ_REMOVE(&ch->head, c3, list);
+ VTAILQ_REMOVE(&ch->head, c3, list);
AN(c3);
memset(c3, 0, sizeof *c3);
c3->magic = SRCADDR_MAGIC;
@@ -180,7 +180,7 @@
c3->nref = 1;
c3->sah = ch;
VSL_stats->n_srcaddr_act++;
- TAILQ_INSERT_TAIL(&ch->head, c3, list);
+ VTAILQ_INSERT_TAIL(&ch->head, c3, list);
sp->srcaddr = c3;
UNLOCK(&ch->mtx);
}
@@ -267,7 +267,7 @@
* thread ever gets here to empty it.
*/
assert(ses_qp <= 1);
- sm = TAILQ_FIRST(&ses_free_mem[ses_qp]);
+ sm = VTAILQ_FIRST(&ses_free_mem[ses_qp]);
if (sm == NULL) {
/*
* If that queue is empty, flip queues holding the lock
@@ -276,10 +276,10 @@
LOCK(&ses_mem_mtx);
ses_qp = 1 - ses_qp;
UNLOCK(&ses_mem_mtx);
- sm = TAILQ_FIRST(&ses_free_mem[ses_qp]);
+ sm = VTAILQ_FIRST(&ses_free_mem[ses_qp]);
}
if (sm != NULL) {
- TAILQ_REMOVE(&ses_free_mem[ses_qp], sm, list);
+ VTAILQ_REMOVE(&ses_free_mem[ses_qp], sm, list);
} else {
/*
* If that fails, alloc new one.
@@ -349,7 +349,7 @@
free(sm);
} else {
LOCK(&ses_mem_mtx);
- TAILQ_INSERT_HEAD(&ses_free_mem[1 - ses_qp], sm, list);
+ VTAILQ_INSERT_HEAD(&ses_free_mem[1 - ses_qp], sm, list);
UNLOCK(&ses_mem_mtx);
}
}
@@ -366,7 +366,7 @@
XXXAN(srchash);
for (i = 0; i < nsrchash; i++) {
srchash[i].magic = SRCADDRHEAD_MAGIC;
- TAILQ_INIT(&srchash[i].head);
+ VTAILQ_INIT(&srchash[i].head);
MTX_INIT(&srchash[i].mtx);
}
MTX_INIT(&stat_mtx);
Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -88,7 +88,7 @@
/* allocate space for body */
/* XXX what if the object already has a body? */
st = STV_alloc(sp, 1024);
- TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
+ VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
/* generate body */
AN(vsb_new(&vsb, (char *)st->ptr, st->space, VSB_FIXEDLEN));
Modified: trunk/varnish-cache/bin/varnishd/cache_vcl.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vcl.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/cache_vcl.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -46,7 +46,7 @@
#include "cache.h"
struct vcls {
- TAILQ_ENTRY(vcls) list;
+ VTAILQ_ENTRY(vcls) list;
const char *name;
void *dlh;
struct VCL_conf *conf;
@@ -57,8 +57,8 @@
* XXX: Presently all modifications to this list happen from the
* CLI event-engine, so no locking is necessary
*/
-static TAILQ_HEAD(, vcls) vcl_head =
- TAILQ_HEAD_INITIALIZER(vcl_head);
+static VTAILQ_HEAD(, vcls) vcl_head =
+ VTAILQ_HEAD_INITIALIZER(vcl_head);
static struct vcls *vcl_active; /* protected by vcl_mtx */
@@ -106,7 +106,7 @@
/* XXX: purge backends */
}
if (vc->busy == 0 && vcl->discard) {
- TAILQ_REMOVE(&vcl_head, vcl, list);
+ VTAILQ_REMOVE(&vcl_head, vcl, list);
} else {
vcl = NULL;
}
@@ -123,7 +123,7 @@
{
struct vcls *vcl;
- TAILQ_FOREACH(vcl, &vcl_head, list)
+ VTAILQ_FOREACH(vcl, &vcl_head, list)
if (!strcmp(vcl->name, name))
return (vcl);
return (NULL);
@@ -179,7 +179,7 @@
vcl->conf->priv = vcl;
vcl->name = strdup(name);
XXXAN(vcl->name);
- TAILQ_INSERT_TAIL(&vcl_head, vcl, list);
+ VTAILQ_INSERT_TAIL(&vcl_head, vcl, list);
LOCK(&vcl_mtx);
if (vcl_active == NULL)
vcl_active = vcl;
@@ -201,7 +201,7 @@
(void)av;
(void)priv;
- TAILQ_FOREACH(vcl, &vcl_head, list) {
+ VTAILQ_FOREACH(vcl, &vcl_head, list) {
cli_out(cli, "%s %6u %s\n",
vcl == vcl_active ? "* " : " ",
vcl->conf->busy,
@@ -247,7 +247,7 @@
}
vcl->discard = 1;
if (vcl->conf->busy == 0)
- TAILQ_REMOVE(&vcl_head, vcl, list);
+ VTAILQ_REMOVE(&vcl_head, vcl, list);
else
vcl = NULL;
UNLOCK(&vcl_mtx);
Modified: trunk/varnish-cache/bin/varnishd/hash_classic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -44,7 +44,7 @@
struct hcl_entry {
unsigned magic;
#define HCL_ENTRY_MAGIC 0x0ba707bf
- TAILQ_ENTRY(hcl_entry) list;
+ VTAILQ_ENTRY(hcl_entry) list;
struct hcl_hd *head;
struct objhead *oh;
unsigned refcnt;
@@ -55,7 +55,7 @@
struct hcl_hd {
unsigned magic;
#define HCL_HEAD_MAGIC 0x0f327016
- TAILQ_HEAD(, hcl_entry) head;
+ VTAILQ_HEAD(, hcl_entry) head;
MTX mtx;
};
@@ -103,7 +103,7 @@
XXXAN(hcl_head);
for (u = 0; u < hcl_nhash; u++) {
- TAILQ_INIT(&hcl_head[u].head);
+ VTAILQ_INIT(&hcl_head[u].head);
MTX_INIT(&hcl_head[u].mtx);
hcl_head[u].magic = HCL_HEAD_MAGIC;
}
@@ -143,7 +143,7 @@
for (r = 0; r < 2; r++ ) {
LOCK(&hp->mtx);
- TAILQ_FOREACH(he, &hp->head, list) {
+ VTAILQ_FOREACH(he, &hp->head, list) {
CHECK_OBJ_NOTNULL(he, HCL_ENTRY_MAGIC);
if (sp->lhashptr < he->oh->hashlen)
continue;
@@ -179,9 +179,9 @@
}
if (he2 != NULL) {
if (he != NULL)
- TAILQ_INSERT_BEFORE(he, he2, list);
+ VTAILQ_INSERT_BEFORE(he, he2, list);
else
- TAILQ_INSERT_TAIL(&hp->head, he2, list);
+ VTAILQ_INSERT_TAIL(&hp->head, he2, list);
he2->refcnt++;
noh = he2->oh;
UNLOCK(&hp->mtx);
@@ -227,7 +227,7 @@
assert(hp == &hcl_head[he->hash]);
LOCK(&hp->mtx);
if (--he->refcnt == 0)
- TAILQ_REMOVE(&hp->head, he, list);
+ VTAILQ_REMOVE(&hp->head, he, list);
else
he = NULL;
UNLOCK(&hp->mtx);
Modified: trunk/varnish-cache/bin/varnishd/hash_simple_list.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_simple_list.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/hash_simple_list.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -43,12 +43,12 @@
/*--------------------------------------------------------------------*/
struct hsl_entry {
- TAILQ_ENTRY(hsl_entry) list;
+ VTAILQ_ENTRY(hsl_entry) list;
struct objhead *obj;
unsigned refcnt;
};
-static TAILQ_HEAD(, hsl_entry) hsl_head = TAILQ_HEAD_INITIALIZER(hsl_head);
+static VTAILQ_HEAD(, hsl_entry) hsl_head = VTAILQ_HEAD_INITIALIZER(hsl_head);
static MTX hsl_mutex;
/*--------------------------------------------------------------------
@@ -77,7 +77,7 @@
int i;
LOCK(&hsl_mutex);
- TAILQ_FOREACH(he, &hsl_head, list) {
+ VTAILQ_FOREACH(he, &hsl_head, list) {
i = HSH_Compare(sp, he->obj);
if (i < 0)
continue;
@@ -104,9 +104,9 @@
HSH_Copy(sp, nobj);
if (he != NULL)
- TAILQ_INSERT_BEFORE(he, he2, list);
+ VTAILQ_INSERT_BEFORE(he, he2, list);
else
- TAILQ_INSERT_TAIL(&hsl_head, he2, list);
+ VTAILQ_INSERT_TAIL(&hsl_head, he2, list);
UNLOCK(&hsl_mutex);
return (nobj);
}
@@ -125,7 +125,7 @@
he = obj->hashpriv;
LOCK(&hsl_mutex);
if (--he->refcnt == 0) {
- TAILQ_REMOVE(&hsl_head, he, list);
+ VTAILQ_REMOVE(&hsl_head, he, list);
free(he);
ret = 0;
} else
Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/heritage.h 2007-09-25 08:48:14 UTC (rev 2033)
@@ -33,19 +33,15 @@
#include
-#ifdef HAVE_SYS_QUEUE_H
-#include
-#else
-#include "queue.h"
-#endif
+#include "vqueue.h"
struct listen_sock {
- TAILQ_ENTRY(listen_sock) list;
+ VTAILQ_ENTRY(listen_sock) list;
int sock;
struct vss_addr *addr;
};
-TAILQ_HEAD(listen_sock_head, listen_sock);
+VTAILQ_HEAD(listen_sock_head, listen_sock);
struct heritage {
Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_child.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -127,14 +127,14 @@
struct listen_sock *ls, *ls2;
int good = 0;
- TAILQ_FOREACH_SAFE(ls, &heritage.socks, list, ls2) {
+ VTAILQ_FOREACH_SAFE(ls, &heritage.socks, list, ls2) {
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);
+ VTAILQ_REMOVE(&heritage.socks, ls, list);
free(ls);
continue;
}
@@ -153,7 +153,7 @@
{
struct listen_sock *ls;
- TAILQ_FOREACH(ls, &heritage.socks, list) {
+ VTAILQ_FOREACH(ls, &heritage.socks, list) {
if (ls->sock < 0)
continue;
close(ls->sock);
Modified: trunk/varnish-cache/bin/varnishd/mgt_event.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_event.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/mgt_event.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -60,7 +60,7 @@
struct evbase {
unsigned magic;
#define EVBASE_MAGIC 0x0cfd976f
- TAILQ_HEAD(,ev) events;
+ VTAILQ_HEAD(,ev) events;
struct pollfd *pfd;
unsigned npfd;
unsigned lpfd;
@@ -173,7 +173,7 @@
return (NULL);
}
evb->magic = EVBASE_MAGIC;
- TAILQ_INIT(&evb->events);
+ VTAILQ_INIT(&evb->events);
evb->binheap = binheap_new(evb, ev_bh_cmp, ev_bh_update);
return (evb);
}
@@ -259,9 +259,9 @@
e->__evb = evb;
e->__privflags = 0;
if (e->fd < 0)
- TAILQ_INSERT_TAIL(&evb->events, e, __list);
+ VTAILQ_INSERT_TAIL(&evb->events, e, __list);
else
- TAILQ_INSERT_HEAD(&evb->events, e, __list);
+ VTAILQ_INSERT_HEAD(&evb->events, e, __list);
if (e->sig > 0) {
assert(es != NULL);
@@ -307,7 +307,7 @@
es->happened = 0;
}
- TAILQ_REMOVE(&evb->events, e, __list);
+ VTAILQ_REMOVE(&evb->events, e, __list);
e->magic = 0;
e->__evb = NULL;
@@ -339,11 +339,11 @@
struct ev *ep;
p = evb->pfd;
- ep = TAILQ_FIRST(&evb->events);
+ ep = VTAILQ_FIRST(&evb->events);
for (u = 0; u < evb->lpfd; u++, p++) {
if (p->fd >= 0)
continue;
- for(; ep != NULL; ep = TAILQ_NEXT(ep, __list)) {
+ for(; ep != NULL; ep = VTAILQ_NEXT(ep, __list)) {
if (ep->fd >= 0 && ep->__poll_idx > u)
break;
}
@@ -441,7 +441,7 @@
return (ev_sched_timeout(evb, e, t));
}
evb->disturbed = 0;
- TAILQ_FOREACH_SAFE(e, &evb->events, __list, e2) {
+ VTAILQ_FOREACH_SAFE(e, &evb->events, __list, e2) {
if (i == 0)
break;
if (e->fd < 0)
@@ -454,9 +454,9 @@
j = e->callback(e, pfd->revents);
i--;
if (evb->disturbed) {
- TAILQ_FOREACH(e3, &evb->events, __list) {
+ VTAILQ_FOREACH(e3, &evb->events, __list) {
if (e3 == e) {
- e3 = TAILQ_NEXT(e, __list);
+ e3 = VTAILQ_NEXT(e, __list);
break;
} else if (e3 == e2)
break;
Modified: trunk/varnish-cache/bin/varnishd/mgt_event.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_event.h 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/mgt_event.h 2007-09-25 08:48:14 UTC (rev 2033)
@@ -31,11 +31,7 @@
#include
-#ifdef HAVE_SYS_QUEUE_H
-#include
-#else
-#include "queue.h"
-#endif
+#include "vqueue.h"
struct ev;
struct evbase;
@@ -63,7 +59,7 @@
/* priv */
double __when;
- TAILQ_ENTRY(ev) __list;
+ VTAILQ_ENTRY(ev) __list;
unsigned __binheap_idx;
unsigned __privflags;
struct evbase *__evb;
Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -383,8 +383,8 @@
{
struct listen_sock *ls, *ls2;
- TAILQ_FOREACH_SAFE(ls, lsh, list, ls2) {
- TAILQ_REMOVE(lsh, ls, list);
+ VTAILQ_FOREACH_SAFE(ls, lsh, list, ls2) {
+ VTAILQ_REMOVE(lsh, ls, list);
free(ls->addr);
free(ls);
}
@@ -421,7 +421,7 @@
FreeArgv(av);
return;
}
- TAILQ_INIT(&lsh);
+ VTAILQ_INIT(&lsh);
for (i = 1; av[i] != NULL; i++) {
struct vss_addr **ta;
char *host, *port;
@@ -445,7 +445,7 @@
AN(ls);
ls->sock = -1;
ls->addr = ta[j];
- TAILQ_INSERT_TAIL(&lsh, ls, list);
+ VTAILQ_INSERT_TAIL(&lsh, ls, list);
}
free(ta);
}
@@ -460,10 +460,10 @@
clean_listen_sock_head(&heritage.socks);
heritage.nsocks = 0;
- while (!TAILQ_EMPTY(&lsh)) {
- ls = TAILQ_FIRST(&lsh);
- TAILQ_REMOVE(&lsh, ls, list);
- TAILQ_INSERT_TAIL(&heritage.socks, ls, list);
+ while (!VTAILQ_EMPTY(&lsh)) {
+ ls = VTAILQ_FIRST(&lsh);
+ VTAILQ_REMOVE(&lsh, ls, list);
+ VTAILQ_INSERT_TAIL(&heritage.socks, ls, list);
heritage.nsocks++;
}
}
Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -45,11 +45,7 @@
#endif
#include "vsb.h"
-#ifdef HAVE_SYS_QUEUE_H
-#include
-#else
-#include "queue.h"
-#endif
+#include "vqueue.h"
#include "libvcl.h"
#include "cli.h"
@@ -63,13 +59,13 @@
#include "vss.h"
struct vclprog {
- TAILQ_ENTRY(vclprog) list;
+ VTAILQ_ENTRY(vclprog) list;
char *name;
char *fname;
int active;
};
-static TAILQ_HEAD(, vclprog) vclhead = TAILQ_HEAD_INITIALIZER(vclhead);
+static VTAILQ_HEAD(, vclprog) vclhead = VTAILQ_HEAD_INITIALIZER(vclhead);
char *mgt_cc_cmd;
@@ -340,14 +336,14 @@
vp->name = strdup(name);
XXXAN(vp->name);
vp->fname = file;
- TAILQ_INSERT_TAIL(&vclhead, vp, list);
+ VTAILQ_INSERT_TAIL(&vclhead, vp, list);
return (vp);
}
static void
mgt_vcc_del(struct vclprog *vp)
{
- TAILQ_REMOVE(&vclhead, vp, list);
+ VTAILQ_REMOVE(&vclhead, vp, list);
printf("unlink %s\n", vp->fname);
XXXAZ(unlink(vp->fname));
free(vp->fname);
@@ -360,7 +356,7 @@
{
struct vclprog *vp;
- TAILQ_FOREACH(vp, &vclhead, list) {
+ VTAILQ_FOREACH(vp, &vclhead, list) {
if (!strcmp(name, vp->name)) {
mgt_vcc_del(vp);
return (0);
@@ -430,7 +426,7 @@
{
struct vclprog *vp;
- TAILQ_FOREACH(vp, &vclhead, list) {
+ VTAILQ_FOREACH(vp, &vclhead, list) {
if (mgt_cli_askchild(status, p,
"vcl.load %s %s\n", vp->name, vp->fname))
return (1);
@@ -460,7 +456,7 @@
if (getpid() != mgt_pid)
return;
while (1) {
- vp = TAILQ_FIRST(&vclhead);
+ vp = VTAILQ_FIRST(&vclhead);
if (vp == NULL)
break;
mgt_vcc_del(vp);
@@ -543,7 +539,7 @@
{
struct vclprog *vp;
- TAILQ_FOREACH(vp, &vclhead, list)
+ VTAILQ_FOREACH(vp, &vclhead, list)
if (!strcmp(vp->name, name))
break;
if (vp == NULL) {
@@ -570,7 +566,7 @@
free(p);
} else {
vp->active = 2;
- TAILQ_FOREACH(vp, &vclhead, list) {
+ VTAILQ_FOREACH(vp, &vclhead, list) {
if (vp->active == 1)
vp->active = 0;
else if (vp->active == 2)
@@ -620,7 +616,7 @@
cli_out(cli, "%s", p);
free(p);
} else {
- TAILQ_FOREACH(vp, &vclhead, list) {
+ VTAILQ_FOREACH(vp, &vclhead, list) {
cli_out(cli, "%s %6s %s\n",
vp->active ? "*" : " ",
"N/A", vp->name);
Modified: trunk/varnish-cache/bin/varnishd/stevedore.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.h 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/stevedore.h 2007-09-25 08:48:14 UTC (rev 2033)
@@ -29,11 +29,7 @@
* $Id$
*/
-#ifdef HAVE_SYS_QUEUE_H
-#include
-#else
-#include "queue.h"
-#endif
+#include "vqueue.h"
struct stevedore;
struct sess;
Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -83,7 +83,7 @@
/*--------------------------------------------------------------------*/
-TAILQ_HEAD(smfhead, smf);
+VTAILQ_HEAD(smfhead, smf);
struct smf {
unsigned magic;
@@ -97,8 +97,8 @@
off_t offset;
unsigned char *ptr;
- TAILQ_ENTRY(smf) order;
- TAILQ_ENTRY(smf) status;
+ VTAILQ_ENTRY(smf) order;
+ VTAILQ_ENTRY(smf) status;
struct smfhead *flist;
};
@@ -254,10 +254,10 @@
sc = calloc(sizeof *sc, 1);
XXXAN(sc);
- TAILQ_INIT(&sc->order);
+ VTAILQ_INIT(&sc->order);
for (u = 0; u < NBUCKET; u++)
- TAILQ_INIT(&sc->free[u]);
- TAILQ_INIT(&sc->used);
+ VTAILQ_INIT(&sc->free[u]);
+ VTAILQ_INIT(&sc->used);
sc->pagesize = getpagesize();
parent->priv = sc;
@@ -359,7 +359,7 @@
}
sp->flist = &sc->free[b];
ns = b * sc->pagesize;
- TAILQ_FOREACH(sp2, sp->flist, status) {
+ VTAILQ_FOREACH(sp2, sp->flist, status) {
assert(sp2->size >= ns);
assert(sp2->alloc == 0);
assert(sp2->flist == sp->flist);
@@ -367,9 +367,9 @@
break;
}
if (sp2 == NULL)
- TAILQ_INSERT_TAIL(sp->flist, sp, status);
+ VTAILQ_INSERT_TAIL(sp->flist, sp, status);
else
- TAILQ_INSERT_BEFORE(sp2, sp, status);
+ VTAILQ_INSERT_BEFORE(sp2, sp, status);
}
static void
@@ -387,7 +387,7 @@
VSL_stats->n_smf_frag--;
}
assert(sp->flist == &sc->free[b]);
- TAILQ_REMOVE(sp->flist, sp, status);
+ VTAILQ_REMOVE(sp->flist, sp, status);
sp->flist = NULL;
}
@@ -406,12 +406,12 @@
if (b >= NBUCKET)
b = NBUCKET - 1;
for (sp = NULL; b < NBUCKET - 1; b++) {
- sp = TAILQ_FIRST(&sc->free[b]);
+ sp = VTAILQ_FIRST(&sc->free[b]);
if (sp != NULL)
break;
}
if (sp == NULL) {
- TAILQ_FOREACH(sp, &sc->free[NBUCKET -1], status)
+ VTAILQ_FOREACH(sp, &sc->free[NBUCKET -1], status)
if (sp->size >= bytes)
break;
}
@@ -423,7 +423,7 @@
if (sp->size == bytes) {
sp->alloc = 1;
- TAILQ_INSERT_TAIL(&sc->used, sp, status);
+ VTAILQ_INSERT_TAIL(&sc->used, sp, status);
return (sp);
}
@@ -439,8 +439,8 @@
sp2->size = bytes;
sp2->alloc = 1;
- TAILQ_INSERT_BEFORE(sp, sp2, order);
- TAILQ_INSERT_TAIL(&sc->used, sp2, status);
+ VTAILQ_INSERT_BEFORE(sp, sp2, order);
+ VTAILQ_INSERT_TAIL(&sc->used, sp2, status);
insfree(sc, sp);
return (sp2);
}
@@ -460,29 +460,29 @@
assert(sp->alloc != 0);
assert(sp->size > 0);
assert(!(sp->size % sc->pagesize));
- TAILQ_REMOVE(&sc->used, sp, status);
+ VTAILQ_REMOVE(&sc->used, sp, status);
sp->alloc = 0;
- sp2 = TAILQ_NEXT(sp, order);
+ sp2 = VTAILQ_NEXT(sp, order);
if (sp2 != NULL &&
sp2->alloc == 0 &&
(sp2->ptr == sp->ptr + sp->size) &&
(sp2->offset == sp->offset + sp->size)) {
sp->size += sp2->size;
- TAILQ_REMOVE(&sc->order, sp2, order);
+ VTAILQ_REMOVE(&sc->order, sp2, order);
remfree(sc, sp2);
free(sp2);
VSL_stats->n_smf--;
}
- sp2 = TAILQ_PREV(sp, smfhead, order);
+ sp2 = VTAILQ_PREV(sp, smfhead, order);
if (sp2 != NULL &&
sp2->alloc == 0 &&
(sp->ptr == sp2->ptr + sp2->size) &&
(sp->offset == sp2->offset + sp2->size)) {
remfree(sc, sp2);
sp2->size += sp->size;
- TAILQ_REMOVE(&sc->order, sp, order);
+ VTAILQ_REMOVE(&sc->order, sp, order);
free(sp);
VSL_stats->n_smf--;
sp = sp2;
@@ -516,8 +516,8 @@
sp->size = bytes;
sp2->ptr += bytes;
sp2->offset += bytes;
- TAILQ_INSERT_AFTER(&sc->order, sp, sp2, order);
- TAILQ_INSERT_TAIL(&sc->used, sp2, status);
+ VTAILQ_INSERT_AFTER(&sc->order, sp, sp2, order);
+ VTAILQ_INSERT_TAIL(&sc->used, sp2, status);
free_smf(sp2);
}
@@ -543,16 +543,16 @@
sp->offset = off;
sp->alloc = 1;
- TAILQ_FOREACH(sp2, &sc->order, order) {
+ VTAILQ_FOREACH(sp2, &sc->order, order) {
if (sp->ptr < sp2->ptr) {
- TAILQ_INSERT_BEFORE(sp2, sp, order);
+ VTAILQ_INSERT_BEFORE(sp2, sp, order);
break;
}
}
if (sp2 == NULL)
- TAILQ_INSERT_TAIL(&sc->order, sp, order);
+ VTAILQ_INSERT_TAIL(&sc->order, sp, order);
- TAILQ_INSERT_HEAD(&sc->used, sp, status);
+ VTAILQ_INSERT_HEAD(&sc->used, sp, status);
free_smf(sp);
}
@@ -734,17 +734,17 @@
return (0);
printf("----------------\n");
printf("Order:\n");
- TAILQ_FOREACH(s, &sc->order, order) {
+ VTAILQ_FOREACH(s, &sc->order, order) {
printf("%10p %12ju %12ju %12ju\n",
s, s->offset, s->size, s->offset + s->size);
}
printf("Used:\n");
- TAILQ_FOREACH(s, &sc->used, status) {
+ VTAILQ_FOREACH(s, &sc->used, status) {
printf("%10p %12ju %12ju %12ju\n",
s, s->offset, s->size, s->offset + s->size);
}
printf("Free:\n");
- TAILQ_FOREACH(s, &sc->free, status) {
+ VTAILQ_FOREACH(s, &sc->free, status) {
printf("%10p %12ju %12ju %12ju\n",
s, s->offset, s->size, s->offset + s->size);
}
Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -395,7 +395,7 @@
XXXAN(cli[0].sb);
cli[0].result = CLIS_OK;
- TAILQ_INIT(&heritage.socks);
+ VTAILQ_INIT(&heritage.socks);
mgt_vcc_init();
Modified: trunk/varnish-cache/bin/varnishreplay/varnishreplay.c
===================================================================
--- trunk/varnish-cache/bin/varnishreplay/varnishreplay.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishreplay/varnishreplay.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -38,11 +38,7 @@
#include
#include
-#ifdef HAVE_SYS_QUEUE_H
-#include
-#else
-#include "queue.h"
-#endif
+#include "vqueue.h"
#include "libvarnish.h"
#include "varnishapi.h"
@@ -65,21 +61,21 @@
enum shmlogtag tag;
size_t len;
char *ptr;
- STAILQ_ENTRY(message) list;
+ VSTAILQ_ENTRY(message) list;
};
struct mailbox {
pthread_mutex_t lock;
pthread_cond_t has_mail;
int open;
- STAILQ_HEAD(msgq_head, message) messages;
+ VSTAILQ_HEAD(msgq_head, message) messages;
};
static void
mailbox_create(struct mailbox *mbox)
{
- STAILQ_INIT(&mbox->messages);
+ VSTAILQ_INIT(&mbox->messages);
pthread_mutex_init(&mbox->lock, NULL);
pthread_cond_init(&mbox->has_mail, NULL);
mbox->open = 1;
@@ -90,8 +86,8 @@
{
struct message *msg;
- while ((msg = STAILQ_FIRST(&mbox->messages))) {
- STAILQ_REMOVE_HEAD(&mbox->messages, list);
+ while ((msg = VSTAILQ_FIRST(&mbox->messages))) {
+ VSTAILQ_REMOVE_HEAD(&mbox->messages, list);
free(msg);
}
pthread_cond_destroy(&mbox->has_mail);
@@ -103,7 +99,7 @@
{
pthread_mutex_lock(&mbox->lock);
- STAILQ_INSERT_TAIL(&mbox->messages, msg, list);
+ VSTAILQ_INSERT_TAIL(&mbox->messages, msg, list);
pthread_cond_signal(&mbox->has_mail);
pthread_mutex_unlock(&mbox->lock);
}
@@ -114,10 +110,10 @@
struct message *msg;
pthread_mutex_lock(&mbox->lock);
- while ((msg = STAILQ_FIRST(&mbox->messages)) == NULL && mbox->open)
+ while ((msg = VSTAILQ_FIRST(&mbox->messages)) == NULL && mbox->open)
pthread_cond_wait(&mbox->has_mail, &mbox->lock);
if (msg != NULL)
- STAILQ_REMOVE_HEAD(&mbox->messages, list);
+ VSTAILQ_REMOVE_HEAD(&mbox->messages, list);
pthread_mutex_unlock(&mbox->lock);
return msg;
}
Modified: trunk/varnish-cache/bin/varnishtop/varnishtop.c
===================================================================
--- trunk/varnish-cache/bin/varnishtop/varnishtop.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/bin/varnishtop/varnishtop.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -43,11 +43,7 @@
#include
#include
-#ifdef HAVE_SYS_QUEUE_H
-#include
-#else
-#include "queue.h"
-#endif
+#include "vqueue.h"
#include "vsb.h"
@@ -59,11 +55,11 @@
unsigned char rec[4 + 255];
unsigned clen;
unsigned hash;
- TAILQ_ENTRY(top) list;
+ VTAILQ_ENTRY(top) list;
double count;
};
-static TAILQ_HEAD(tophead, top) top_head = TAILQ_HEAD_INITIALIZER(top_head);
+static VTAILQ_HEAD(tophead, top) top_head = VTAILQ_HEAD_INITIALIZER(top_head);
static unsigned ntop;
@@ -91,7 +87,7 @@
u += *q;
}
- TAILQ_FOREACH(tp, &top_head, list) {
+ VTAILQ_FOREACH(tp, &top_head, list) {
if (tp->hash != u)
continue;
if (tp->rec[0] != p[0])
@@ -110,22 +106,22 @@
tp->hash = u;
tp->count = 1.0;
tp->clen = q - p;
- TAILQ_INSERT_TAIL(&top_head, tp, list);
+ VTAILQ_INSERT_TAIL(&top_head, tp, list);
}
memcpy(tp->rec, p, 4 + p[1]);
while (1) {
- tp2 = TAILQ_PREV(tp, tophead, list);
+ tp2 = VTAILQ_PREV(tp, tophead, list);
if (tp2 == NULL || tp2->count >= tp->count)
break;
- TAILQ_REMOVE(&top_head, tp2, list);
- TAILQ_INSERT_AFTER(&top_head, tp, tp2, list);
+ VTAILQ_REMOVE(&top_head, tp2, list);
+ VTAILQ_INSERT_AFTER(&top_head, tp, tp2, list);
}
while (1) {
- tp2 = TAILQ_NEXT(tp, list);
+ tp2 = VTAILQ_NEXT(tp, list);
if (tp2 == NULL || tp2->count <= tp->count)
break;
- TAILQ_REMOVE(&top_head, tp2, list);
- TAILQ_INSERT_BEFORE(tp, tp2, list);
+ VTAILQ_REMOVE(&top_head, tp2, list);
+ VTAILQ_INSERT_BEFORE(tp, tp2, list);
}
}
@@ -147,7 +143,7 @@
l = 1;
mvprintw(0, 0, "%*s", COLS - 1, VSL_Name());
mvprintw(0, 0, "list length %u", ntop);
- TAILQ_FOREACH_SAFE(tp, &top_head, list, tp2) {
+ VTAILQ_FOREACH_SAFE(tp, &top_head, list, tp2) {
if (++l < LINES) {
int len = tp->rec[1];
if (len > COLS - 20)
@@ -159,7 +155,7 @@
}
tp->count *= .999;
if (tp->count * 10 < t || l > LINES * 10) {
- TAILQ_REMOVE(&top_head, tp, list);
+ VTAILQ_REMOVE(&top_head, tp, list);
free(tp);
ntop--;
}
@@ -251,7 +247,7 @@
struct top *tp, *tp2;
int len;
- TAILQ_FOREACH_SAFE(tp, &top_head, list, tp2) {
+ VTAILQ_FOREACH_SAFE(tp, &top_head, list, tp2) {
if (tp->count <= 1.0)
break;
len = tp->rec[1];
Modified: trunk/varnish-cache/configure.ac
===================================================================
--- trunk/varnish-cache/configure.ac 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/configure.ac 2007-09-25 08:48:14 UTC (rev 2033)
@@ -65,7 +65,6 @@
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
-AC_CHECK_HEADERS([sys/queue.h])
AC_CHECK_HEADERS([sys/socket.h])
AC_CHECK_HEADERS([sys/mount.h])
AC_CHECK_HEADERS([sys/vfs.h])
Modified: trunk/varnish-cache/include/Makefile.am
===================================================================
--- trunk/varnish-cache/include/Makefile.am 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/include/Makefile.am 2007-09-25 08:48:14 UTC (rev 2033)
@@ -25,7 +25,7 @@
libvarnish.h \
libvcl.h \
miniobj.h \
- queue.h \
+ vqueue.h \
vpf.h \
vsb.h \
vcl.h \
Deleted: trunk/varnish-cache/include/queue.h
===================================================================
--- trunk/varnish-cache/include/queue.h 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/include/queue.h 2007-09-25 08:48:14 UTC (rev 2033)
@@ -1,676 +0,0 @@
-/* $Id$ */
-/* $NetBSD: queue.h,v 1.45 2006/03/07 17:56:00 pooka Exp $ */
-
-/*
- * Copyright (c) 1991, 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.
- * 3. 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.
- *
- * @(#)queue.h 8.5 (Berkeley) 8/20/94
- */
-
-#ifndef _SYS_QUEUE_H_
-#define _SYS_QUEUE_H_
-
-/*
- * This file defines five types of data structures: singly-linked lists,
- * lists, simple queues, tail queues, and circular queues.
- *
- * A singly-linked list is headed by a single forward pointer. The
- * elements are singly linked for minimum space and pointer manipulation
- * overhead at the expense of O(n) removal for arbitrary elements. New
- * elements can be added to the list after an existing element or at the
- * head of the list. Elements being removed from the head of the list
- * should use the explicit macro for this purpose for optimum
- * efficiency. A singly-linked list may only be traversed in the forward
- * direction. Singly-linked lists are ideal for applications with large
- * datasets and few or no removals or for implementing a LIFO queue.
- *
- * A list is headed by a single forward pointer (or an array of forward
- * pointers for a hash table header). The elements are doubly linked
- * so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before
- * or after an existing element or at the head of the list. A list
- * may only be traversed in the forward direction.
- *
- * A simple queue is headed by a pair of pointers, one the head of the
- * list and the other to the tail of the list. The elements are singly
- * linked to save space, so elements can only be removed from the
- * head of the list. New elements can be added to the list after
- * an existing element, at the head of the list, or at the end of the
- * list. A simple queue may only be traversed in the forward direction.
- *
- * A tail queue is headed by a pair of pointers, one to the head of the
- * list and the other to the tail of the list. The elements are doubly
- * linked so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before or
- * after an existing element, at the head of the list, or at the end of
- * the list. A tail queue may be traversed in either direction.
- *
- * A circle queue is headed by a pair of pointers, one to the head of the
- * list and the other to the tail of the list. The elements are doubly
- * linked so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before or after
- * an existing element, at the head of the list, or at the end of the list.
- * A circle queue may be traversed in either direction, but has a more
- * complex end of list detection.
- *
- * For details on the use of these macros, see the queue(3) manual page.
- */
-
-/*
- * List definitions.
- */
-#define LIST_HEAD(name, type) \
-struct name { \
- struct type *lh_first; /* first element */ \
-}
-
-#define LIST_HEAD_INITIALIZER(head) \
- { NULL }
-
-#define LIST_ENTRY(type) \
-struct { \
- struct type *le_next; /* next element */ \
- struct type **le_prev; /* address of previous next element */ \
-}
-
-/*
- * List functions.
- */
-#if defined(_KERNEL) && defined(QUEUEDEBUG)
-#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) \
- if ((head)->lh_first && \
- (head)->lh_first->field.le_prev != &(head)->lh_first) \
- panic("LIST_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__);
-#define QUEUEDEBUG_LIST_OP(elm, field) \
- if ((elm)->field.le_next && \
- (elm)->field.le_next->field.le_prev != \
- &(elm)->field.le_next) \
- panic("LIST_* forw %p %s:%d", (elm), __FILE__, __LINE__);\
- if (*(elm)->field.le_prev != (elm)) \
- panic("LIST_* back %p %s:%d", (elm), __FILE__, __LINE__);
-#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) \
- (elm)->field.le_next = (void *)1L; \
- (elm)->field.le_prev = (void *)1L;
-#else
-#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field)
-#define QUEUEDEBUG_LIST_OP(elm, field)
-#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field)
-#endif
-
-#define LIST_INIT(head) do { \
- (head)->lh_first = NULL; \
-} while (/*CONSTCOND*/0)
-
-#define LIST_INSERT_AFTER(listelm, elm, field) do { \
- QUEUEDEBUG_LIST_OP((listelm), field) \
- if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
- (listelm)->field.le_next->field.le_prev = \
- &(elm)->field.le_next; \
- (listelm)->field.le_next = (elm); \
- (elm)->field.le_prev = &(listelm)->field.le_next; \
-} while (/*CONSTCOND*/0)
-
-#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
- QUEUEDEBUG_LIST_OP((listelm), field) \
- (elm)->field.le_prev = (listelm)->field.le_prev; \
- (elm)->field.le_next = (listelm); \
- *(listelm)->field.le_prev = (elm); \
- (listelm)->field.le_prev = &(elm)->field.le_next; \
-} while (/*CONSTCOND*/0)
-
-#define LIST_INSERT_HEAD(head, elm, field) do { \
- QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \
- if (((elm)->field.le_next = (head)->lh_first) != NULL) \
- (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
- (head)->lh_first = (elm); \
- (elm)->field.le_prev = &(head)->lh_first; \
-} while (/*CONSTCOND*/0)
-
-#define LIST_REMOVE(elm, field) do { \
- QUEUEDEBUG_LIST_OP((elm), field) \
- if ((elm)->field.le_next != NULL) \
- (elm)->field.le_next->field.le_prev = \
- (elm)->field.le_prev; \
- *(elm)->field.le_prev = (elm)->field.le_next; \
- QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \
-} while (/*CONSTCOND*/0)
-
-#define LIST_FOREACH(var, head, field) \
- for ((var) = ((head)->lh_first); \
- (var); \
- (var) = ((var)->field.le_next))
-
-/*
- * List access methods.
- */
-#define LIST_EMPTY(head) ((head)->lh_first == NULL)
-#define LIST_FIRST(head) ((head)->lh_first)
-#define LIST_NEXT(elm, field) ((elm)->field.le_next)
-
-
-/*
- * Singly-linked List definitions.
- */
-#define SLIST_HEAD(name, type) \
-struct name { \
- struct type *slh_first; /* first element */ \
-}
-
-#define SLIST_HEAD_INITIALIZER(head) \
- { NULL }
-
-#define SLIST_ENTRY(type) \
-struct { \
- struct type *sle_next; /* next element */ \
-}
-
-/*
- * Singly-linked List functions.
- */
-#define SLIST_INIT(head) do { \
- (head)->slh_first = NULL; \
-} while (/*CONSTCOND*/0)
-
-#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
- (elm)->field.sle_next = (slistelm)->field.sle_next; \
- (slistelm)->field.sle_next = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define SLIST_INSERT_HEAD(head, elm, field) do { \
- (elm)->field.sle_next = (head)->slh_first; \
- (head)->slh_first = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define SLIST_REMOVE_HEAD(head, field) do { \
- (head)->slh_first = (head)->slh_first->field.sle_next; \
-} while (/*CONSTCOND*/0)
-
-#define SLIST_REMOVE(head, elm, type, field) do { \
- if ((head)->slh_first == (elm)) { \
- SLIST_REMOVE_HEAD((head), field); \
- } \
- else { \
- struct type *curelm = (head)->slh_first; \
- while(curelm->field.sle_next != (elm)) \
- curelm = curelm->field.sle_next; \
- curelm->field.sle_next = \
- curelm->field.sle_next->field.sle_next; \
- } \
-} while (/*CONSTCOND*/0)
-
-#define SLIST_FOREACH(var, head, field) \
- for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
-
-/*
- * Singly-linked List access methods.
- */
-#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
-#define SLIST_FIRST(head) ((head)->slh_first)
-#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
-
-
-/*
- * Singly-linked Tail queue declarations.
- */
-#define STAILQ_HEAD(name, type) \
-struct name { \
- struct type *stqh_first; /* first element */ \
- struct type **stqh_last; /* addr of last next element */ \
-}
-
-#define STAILQ_HEAD_INITIALIZER(head) \
- { NULL, &(head).stqh_first }
-
-#define STAILQ_ENTRY(type) \
-struct { \
- struct type *stqe_next; /* next element */ \
-}
-
-/*
- * Singly-linked Tail queue functions.
- */
-#define STAILQ_INIT(head) do { \
- (head)->stqh_first = NULL; \
- (head)->stqh_last = &(head)->stqh_first; \
-} while (/*CONSTCOND*/0)
-
-#define STAILQ_INSERT_HEAD(head, elm, field) do { \
- if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \
- (head)->stqh_last = &(elm)->field.stqe_next; \
- (head)->stqh_first = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define STAILQ_INSERT_TAIL(head, elm, field) do { \
- (elm)->field.stqe_next = NULL; \
- *(head)->stqh_last = (elm); \
- (head)->stqh_last = &(elm)->field.stqe_next; \
-} while (/*CONSTCOND*/0)
-
-#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
- if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
- (head)->stqh_last = &(elm)->field.stqe_next; \
- (listelm)->field.stqe_next = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define STAILQ_REMOVE_HEAD(head, field) do { \
- if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
- (head)->stqh_last = &(head)->stqh_first; \
-} while (/*CONSTCOND*/0)
-
-#define STAILQ_REMOVE(head, elm, type, field) do { \
- if ((head)->stqh_first == (elm)) { \
- STAILQ_REMOVE_HEAD((head), field); \
- } else { \
- struct type *curelm = (head)->stqh_first; \
- while (curelm->field.stqe_next != (elm)) \
- curelm = curelm->field.stqe_next; \
- if ((curelm->field.stqe_next = \
- curelm->field.stqe_next->field.stqe_next) == NULL) \
- (head)->stqh_last = &(curelm)->field.stqe_next; \
- } \
-} while (/*CONSTCOND*/0)
-
-#define STAILQ_FOREACH(var, head, field) \
- for ((var) = ((head)->stqh_first); \
- (var); \
- (var) = ((var)->field.stqe_next))
-
-/*
- * Singly-linked Tail queue access methods.
- */
-#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
-#define STAILQ_FIRST(head) ((head)->stqh_first)
-#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
-
-
-/*
- * Simple queue definitions.
- */
-#define SIMPLEQ_HEAD(name, type) \
-struct name { \
- struct type *sqh_first; /* first element */ \
- struct type **sqh_last; /* addr of last next element */ \
-}
-
-#define SIMPLEQ_HEAD_INITIALIZER(head) \
- { NULL, &(head).sqh_first }
-
-#define SIMPLEQ_ENTRY(type) \
-struct { \
- struct type *sqe_next; /* next element */ \
-}
-
-/*
- * Simple queue functions.
- */
-#define SIMPLEQ_INIT(head) do { \
- (head)->sqh_first = NULL; \
- (head)->sqh_last = &(head)->sqh_first; \
-} while (/*CONSTCOND*/0)
-
-#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
- if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
- (head)->sqh_last = &(elm)->field.sqe_next; \
- (head)->sqh_first = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
- (elm)->field.sqe_next = NULL; \
- *(head)->sqh_last = (elm); \
- (head)->sqh_last = &(elm)->field.sqe_next; \
-} while (/*CONSTCOND*/0)
-
-#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
- if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
- (head)->sqh_last = &(elm)->field.sqe_next; \
- (listelm)->field.sqe_next = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
- if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
- (head)->sqh_last = &(head)->sqh_first; \
-} while (/*CONSTCOND*/0)
-
-#define SIMPLEQ_REMOVE(head, elm, type, field) do { \
- if ((head)->sqh_first == (elm)) { \
- SIMPLEQ_REMOVE_HEAD((head), field); \
- } else { \
- struct type *curelm = (head)->sqh_first; \
- while (curelm->field.sqe_next != (elm)) \
- curelm = curelm->field.sqe_next; \
- if ((curelm->field.sqe_next = \
- curelm->field.sqe_next->field.sqe_next) == NULL) \
- (head)->sqh_last = &(curelm)->field.sqe_next; \
- } \
-} while (/*CONSTCOND*/0)
-
-#define SIMPLEQ_FOREACH(var, head, field) \
- for ((var) = ((head)->sqh_first); \
- (var); \
- (var) = ((var)->field.sqe_next))
-
-/*
- * Simple queue access methods.
- */
-#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL)
-#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
-#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
-
-
-/*
- * Tail queue definitions.
- */
-#define _TAILQ_HEAD(name, type, qual) \
-struct name { \
- qual type *tqh_first; /* first element */ \
- qual type *qual *tqh_last; /* addr of last next element */ \
-}
-#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,)
-
-#define TAILQ_HEAD_INITIALIZER(head) \
- { NULL, &(head).tqh_first }
-
-#define _TAILQ_ENTRY(type, qual) \
-struct { \
- qual type *tqe_next; /* next element */ \
- qual type *qual *tqe_prev; /* address of previous next element */\
-}
-#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,)
-
-/*
- * Tail queue functions.
- */
-#if defined(_KERNEL) && defined(QUEUEDEBUG)
-#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) \
- if ((head)->tqh_first && \
- (head)->tqh_first->field.tqe_prev != &(head)->tqh_first) \
- panic("TAILQ_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__);
-#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) \
- if (*(head)->tqh_last != NULL) \
- panic("TAILQ_INSERT_TAIL %p %s:%d", (head), __FILE__, __LINE__);
-#define QUEUEDEBUG_TAILQ_OP(elm, field) \
- if ((elm)->field.tqe_next && \
- (elm)->field.tqe_next->field.tqe_prev != \
- &(elm)->field.tqe_next) \
- panic("TAILQ_* forw %p %s:%d", (elm), __FILE__, __LINE__);\
- if (*(elm)->field.tqe_prev != (elm)) \
- panic("TAILQ_* back %p %s:%d", (elm), __FILE__, __LINE__);
-#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) \
- if ((elm)->field.tqe_next == NULL && \
- (head)->tqh_last != &(elm)->field.tqe_next) \
- panic("TAILQ_PREREMOVE head %p elm %p %s:%d", \
- (head), (elm), __FILE__, __LINE__);
-#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \
- (elm)->field.tqe_next = (void *)1L; \
- (elm)->field.tqe_prev = (void *)1L;
-#else
-#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field)
-#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field)
-#define QUEUEDEBUG_TAILQ_OP(elm, field)
-#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field)
-#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field)
-#endif
-
-#define TAILQ_INIT(head) do { \
- (head)->tqh_first = NULL; \
- (head)->tqh_last = &(head)->tqh_first; \
-} while (/*CONSTCOND*/0)
-
-#define TAILQ_INSERT_HEAD(head, elm, field) do { \
- QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \
- if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
- (head)->tqh_first->field.tqe_prev = \
- &(elm)->field.tqe_next; \
- else \
- (head)->tqh_last = &(elm)->field.tqe_next; \
- (head)->tqh_first = (elm); \
- (elm)->field.tqe_prev = &(head)->tqh_first; \
-} while (/*CONSTCOND*/0)
-
-#define TAILQ_INSERT_TAIL(head, elm, field) do { \
- QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \
- (elm)->field.tqe_next = NULL; \
- (elm)->field.tqe_prev = (head)->tqh_last; \
- *(head)->tqh_last = (elm); \
- (head)->tqh_last = &(elm)->field.tqe_next; \
-} while (/*CONSTCOND*/0)
-
-#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
- QUEUEDEBUG_TAILQ_OP((listelm), field) \
- if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
- (elm)->field.tqe_next->field.tqe_prev = \
- &(elm)->field.tqe_next; \
- else \
- (head)->tqh_last = &(elm)->field.tqe_next; \
- (listelm)->field.tqe_next = (elm); \
- (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
-} while (/*CONSTCOND*/0)
-
-#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
- QUEUEDEBUG_TAILQ_OP((listelm), field) \
- (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
- (elm)->field.tqe_next = (listelm); \
- *(listelm)->field.tqe_prev = (elm); \
- (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
-} while (/*CONSTCOND*/0)
-
-#define TAILQ_REMOVE(head, elm, field) do { \
- QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \
- QUEUEDEBUG_TAILQ_OP((elm), field) \
- if (((elm)->field.tqe_next) != NULL) \
- (elm)->field.tqe_next->field.tqe_prev = \
- (elm)->field.tqe_prev; \
- else \
- (head)->tqh_last = (elm)->field.tqe_prev; \
- *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
- QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \
-} while (/*CONSTCOND*/0)
-
-#define TAILQ_FOREACH(var, head, field) \
- for ((var) = ((head)->tqh_first); \
- (var); \
- (var) = ((var)->field.tqe_next))
-
-#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = TAILQ_FIRST((head)); \
- (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
- (var) = (tvar))
-
-#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
- for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
- (var); \
- (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
-
-/*
- * Tail queue access methods.
- */
-#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
-#define TAILQ_FIRST(head) ((head)->tqh_first)
-#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
-
-#define TAILQ_LAST(head, headname) \
- (*(((struct headname *)((head)->tqh_last))->tqh_last))
-#define TAILQ_PREV(elm, headname, field) \
- (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
-
-
-/*
- * Circular queue definitions.
- */
-#if defined(_KERNEL) && defined(QUEUEDEBUG)
-#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) \
- if ((head)->cqh_first != (void *)(head) && \
- (head)->cqh_first->field.cqe_prev != (void *)(head)) \
- panic("CIRCLEQ head forw %p %s:%d", (head), \
- __FILE__, __LINE__); \
- if ((head)->cqh_last != (void *)(head) && \
- (head)->cqh_last->field.cqe_next != (void *)(head)) \
- panic("CIRCLEQ head back %p %s:%d", (head), \
- __FILE__, __LINE__);
-#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) \
- if ((elm)->field.cqe_next == (void *)(head)) { \
- if ((head)->cqh_last != (elm)) \
- panic("CIRCLEQ elm last %p %s:%d", (elm), \
- __FILE__, __LINE__); \
- } else { \
- if ((elm)->field.cqe_next->field.cqe_prev != (elm)) \
- panic("CIRCLEQ elm forw %p %s:%d", (elm), \
- __FILE__, __LINE__); \
- } \
- if ((elm)->field.cqe_prev == (void *)(head)) { \
- if ((head)->cqh_first != (elm)) \
- panic("CIRCLEQ elm first %p %s:%d", (elm), \
- __FILE__, __LINE__); \
- } else { \
- if ((elm)->field.cqe_prev->field.cqe_next != (elm)) \
- panic("CIRCLEQ elm prev %p %s:%d", (elm), \
- __FILE__, __LINE__); \
- }
-#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) \
- (elm)->field.cqe_next = (void *)1L; \
- (elm)->field.cqe_prev = (void *)1L;
-#else
-#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field)
-#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field)
-#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field)
-#endif
-
-#define CIRCLEQ_HEAD(name, type) \
-struct name { \
- struct type *cqh_first; /* first element */ \
- struct type *cqh_last; /* last element */ \
-}
-
-#define CIRCLEQ_HEAD_INITIALIZER(head) \
- { (void *)&head, (void *)&head }
-
-#define CIRCLEQ_ENTRY(type) \
-struct { \
- struct type *cqe_next; /* next element */ \
- struct type *cqe_prev; /* previous element */ \
-}
-
-/*
- * Circular queue functions.
- */
-#define CIRCLEQ_INIT(head) do { \
- (head)->cqh_first = (void *)(head); \
- (head)->cqh_last = (void *)(head); \
-} while (/*CONSTCOND*/0)
-
-#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
- QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
- QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \
- (elm)->field.cqe_next = (listelm)->field.cqe_next; \
- (elm)->field.cqe_prev = (listelm); \
- if ((listelm)->field.cqe_next == (void *)(head)) \
- (head)->cqh_last = (elm); \
- else \
- (listelm)->field.cqe_next->field.cqe_prev = (elm); \
- (listelm)->field.cqe_next = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
- QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
- QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \
- (elm)->field.cqe_next = (listelm); \
- (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
- if ((listelm)->field.cqe_prev == (void *)(head)) \
- (head)->cqh_first = (elm); \
- else \
- (listelm)->field.cqe_prev->field.cqe_next = (elm); \
- (listelm)->field.cqe_prev = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
- QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
- (elm)->field.cqe_next = (head)->cqh_first; \
- (elm)->field.cqe_prev = (void *)(head); \
- if ((head)->cqh_last == (void *)(head)) \
- (head)->cqh_last = (elm); \
- else \
- (head)->cqh_first->field.cqe_prev = (elm); \
- (head)->cqh_first = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
- QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
- (elm)->field.cqe_next = (void *)(head); \
- (elm)->field.cqe_prev = (head)->cqh_last; \
- if ((head)->cqh_first == (void *)(head)) \
- (head)->cqh_first = (elm); \
- else \
- (head)->cqh_last->field.cqe_next = (elm); \
- (head)->cqh_last = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define CIRCLEQ_REMOVE(head, elm, field) do { \
- QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
- QUEUEDEBUG_CIRCLEQ_ELM((head), (elm), field) \
- if ((elm)->field.cqe_next == (void *)(head)) \
- (head)->cqh_last = (elm)->field.cqe_prev; \
- else \
- (elm)->field.cqe_next->field.cqe_prev = \
- (elm)->field.cqe_prev; \
- if ((elm)->field.cqe_prev == (void *)(head)) \
- (head)->cqh_first = (elm)->field.cqe_next; \
- else \
- (elm)->field.cqe_prev->field.cqe_next = \
- (elm)->field.cqe_next; \
- QUEUEDEBUG_CIRCLEQ_POSTREMOVE((elm), field) \
-} while (/*CONSTCOND*/0)
-
-#define CIRCLEQ_FOREACH(var, head, field) \
- for ((var) = ((head)->cqh_first); \
- (var) != (const void *)(head); \
- (var) = ((var)->field.cqe_next))
-
-#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
- for ((var) = ((head)->cqh_last); \
- (var) != (const void *)(head); \
- (var) = ((var)->field.cqe_prev))
-
-/*
- * Circular queue access methods.
- */
-#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head))
-#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
-#define CIRCLEQ_LAST(head) ((head)->cqh_last)
-#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
-#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
-
-#define CIRCLEQ_LOOP_NEXT(head, elm, field) \
- (((elm)->field.cqe_next == (void *)(head)) \
- ? ((head)->cqh_first) \
- : (elm->field.cqe_next))
-#define CIRCLEQ_LOOP_PREV(head, elm, field) \
- (((elm)->field.cqe_prev == (void *)(head)) \
- ? ((head)->cqh_last) \
- : (elm->field.cqe_prev))
-
-#endif /* !_SYS_QUEUE_H_ */
Added: trunk/varnish-cache/include/vqueue.h
===================================================================
--- trunk/varnish-cache/include/vqueue.h (rev 0)
+++ trunk/varnish-cache/include/vqueue.h 2007-09-25 08:48:14 UTC (rev 2033)
@@ -0,0 +1,495 @@
+/*-
+ * Copyright (c) 1991, 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.
+ * 3. 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.
+ *
+ * @(#)queue.h 8.5 (Berkeley) 8/20/94
+ * $FreeBSD: src/sys/sys/queue.h,v 1.68 2006/10/24 11:20:29 ru Exp $
+ * $Id$
+ */
+
+#ifndef VARNISH_QUEUE_H
+#define VARNISH_QUEUE_H
+
+/*
+ * This file defines four types of data structures: singly-linked lists,
+ * singly-linked tail queues, lists and tail queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The elements
+ * are singly linked for minimum space and pointer manipulation overhead at
+ * the expense of O(n) removal for arbitrary elements. New elements can be
+ * added to the list after an existing element or at the head of the list.
+ * Elements being removed from the head of the list should use the explicit
+ * macro for this purpose for optimum efficiency. A singly-linked list may
+ * only be traversed in the forward direction. Singly-linked lists are ideal
+ * for applications with large datasets and few or no removals or for
+ * implementing a LIFO queue.
+ *
+ * A singly-linked tail queue is headed by a pair of pointers, one to the
+ * head of the list and the other to the tail of the list. The elements are
+ * singly linked for minimum space and pointer manipulation overhead at the
+ * expense of O(n) removal for arbitrary elements. New elements can be added
+ * to the list after an existing element, at the head of the list, or at the
+ * end of the list. Elements being removed from the head of the tail queue
+ * should use the explicit macro for this purpose for optimum efficiency.
+ * A singly-linked tail queue may only be traversed in the forward direction.
+ * Singly-linked tail queues are ideal for applications with large datasets
+ * and few or no removals or for implementing a FIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ *
+ *
+ * VSLIST VLIST VSTAILQ VTAILQ
+ * _HEAD + + + +
+ * _HEAD_INITIALIZER + + + +
+ * _ENTRY + + + +
+ * _INIT + + + +
+ * _EMPTY + + + +
+ * _FIRST + + + +
+ * _NEXT + + + +
+ * _PREV - - - +
+ * _LAST - - + +
+ * _FOREACH + + + +
+ * _FOREACH_SAFE + + + +
+ * _FOREACH_REVERSE - - - +
+ * _FOREACH_REVERSE_SAFE - - - +
+ * _INSERT_HEAD + + + +
+ * _INSERT_BEFORE - + - +
+ * _INSERT_AFTER + + + +
+ * _INSERT_TAIL - - + +
+ * _CONCAT - - + +
+ * _REMOVE_HEAD + - + -
+ * _REMOVE + + + +
+ *
+ */
+
+/*
+ * Singly-linked List declarations.
+ */
+#define VSLIST_HEAD(name, type) \
+struct name { \
+ struct type *vslh_first; /* first element */ \
+}
+
+#define VSLIST_HEAD_INITIALIZER(head) \
+ { NULL }
+
+#define VSLIST_ENTRY(type) \
+struct { \
+ struct type *vsle_next; /* next element */ \
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define VSLIST_EMPTY(head) ((head)->vslh_first == NULL)
+
+#define VSLIST_FIRST(head) ((head)->vslh_first)
+
+#define VSLIST_FOREACH(var, head, field) \
+ for ((var) = VSLIST_FIRST((head)); \
+ (var); \
+ (var) = VSLIST_NEXT((var), field))
+
+#define VSLIST_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = VSLIST_FIRST((head)); \
+ (var) && ((tvar) = VSLIST_NEXT((var), field), 1); \
+ (var) = (tvar))
+
+#define VSLIST_FOREACH_PREVPTR(var, varp, head, field) \
+ for ((varp) = &VSLIST_FIRST((head)); \
+ ((var) = *(varp)) != NULL; \
+ (varp) = &VSLIST_NEXT((var), field))
+
+#define VSLIST_INIT(head) do { \
+ VSLIST_FIRST((head)) = NULL; \
+} while (0)
+
+#define VSLIST_INSERT_AFTER(slistelm, elm, field) do { \
+ VSLIST_NEXT((elm), field) = VSLIST_NEXT((slistelm), field); \
+ VSLIST_NEXT((slistelm), field) = (elm); \
+} while (0)
+
+#define VSLIST_INSERT_HEAD(head, elm, field) do { \
+ VSLIST_NEXT((elm), field) = VSLIST_FIRST((head)); \
+ VSLIST_FIRST((head)) = (elm); \
+} while (0)
+
+#define VSLIST_NEXT(elm, field) ((elm)->field.vsle_next)
+
+#define VSLIST_REMOVE(head, elm, type, field) do { \
+ if (VSLIST_FIRST((head)) == (elm)) { \
+ VSLIST_REMOVE_HEAD((head), field); \
+ } \
+ else { \
+ struct type *curelm = VSLIST_FIRST((head)); \
+ while (VSLIST_NEXT(curelm, field) != (elm)) \
+ curelm = VSLIST_NEXT(curelm, field); \
+ VSLIST_NEXT(curelm, field) = \
+ VSLIST_NEXT(VSLIST_NEXT(curelm, field), field); \
+ } \
+} while (0)
+
+#define VSLIST_REMOVE_HEAD(head, field) do { \
+ VSLIST_FIRST((head)) = VSLIST_NEXT(VSLIST_FIRST((head)), field);\
+} while (0)
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define VSTAILQ_HEAD(name, type) \
+struct name { \
+ struct type *vstqh_first;/* first element */ \
+ struct type **vstqh_last;/* addr of last next element */ \
+}
+
+#define VSTAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).vstqh_first }
+
+#define VSTAILQ_ENTRY(type) \
+struct { \
+ struct type *vstqe_next; /* next element */ \
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define VSTAILQ_CONCAT(head1, head2) do { \
+ if (!VSTAILQ_EMPTY((head2))) { \
+ *(head1)->vstqh_last = (head2)->vstqh_first; \
+ (head1)->vstqh_last = (head2)->vstqh_last; \
+ VSTAILQ_INIT((head2)); \
+ } \
+} while (0)
+
+#define VSTAILQ_EMPTY(head) ((head)->vstqh_first == NULL)
+
+#define VSTAILQ_FIRST(head) ((head)->vstqh_first)
+
+#define VSTAILQ_FOREACH(var, head, field) \
+ for((var) = VSTAILQ_FIRST((head)); \
+ (var); \
+ (var) = VSTAILQ_NEXT((var), field))
+
+
+#define VSTAILQ_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = VSTAILQ_FIRST((head)); \
+ (var) && ((tvar) = VSTAILQ_NEXT((var), field), 1); \
+ (var) = (tvar))
+
+#define VSTAILQ_INIT(head) do { \
+ VSTAILQ_FIRST((head)) = NULL; \
+ (head)->vstqh_last = &VSTAILQ_FIRST((head)); \
+} while (0)
+
+#define VSTAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
+ if ((VSTAILQ_NEXT((elm), field) = VSTAILQ_NEXT((tqelm), field)) == NULL)\
+ (head)->vstqh_last = &VSTAILQ_NEXT((elm), field); \
+ VSTAILQ_NEXT((tqelm), field) = (elm); \
+} while (0)
+
+#define VSTAILQ_INSERT_HEAD(head, elm, field) do { \
+ if ((VSTAILQ_NEXT((elm), field) = VSTAILQ_FIRST((head))) == NULL)\
+ (head)->vstqh_last = &VSTAILQ_NEXT((elm), field); \
+ VSTAILQ_FIRST((head)) = (elm); \
+} while (0)
+
+#define VSTAILQ_INSERT_TAIL(head, elm, field) do { \
+ VSTAILQ_NEXT((elm), field) = NULL; \
+ *(head)->vstqh_last = (elm); \
+ (head)->vstqh_last = &VSTAILQ_NEXT((elm), field); \
+} while (0)
+
+#define VSTAILQ_LAST(head, type, field) \
+ (VSTAILQ_EMPTY((head)) ? \
+ NULL : \
+ ((struct type *)(void *) \
+ ((char *)((head)->vstqh_last) - __offsetof(struct type, field))))
+
+#define VSTAILQ_NEXT(elm, field) ((elm)->field.vstqe_next)
+
+#define VSTAILQ_REMOVE(head, elm, type, field) do { \
+ if (VSTAILQ_FIRST((head)) == (elm)) { \
+ VSTAILQ_REMOVE_HEAD((head), field); \
+ } \
+ else { \
+ struct type *curelm = VSTAILQ_FIRST((head)); \
+ while (VSTAILQ_NEXT(curelm, field) != (elm)) \
+ curelm = VSTAILQ_NEXT(curelm, field); \
+ if ((VSTAILQ_NEXT(curelm, field) = \
+ VSTAILQ_NEXT(VSTAILQ_NEXT(curelm, field), field)) == NULL)\
+ (head)->vstqh_last = &VSTAILQ_NEXT((curelm), field);\
+ } \
+} while (0)
+
+#define VSTAILQ_REMOVE_HEAD(head, field) do { \
+ if ((VSTAILQ_FIRST((head)) = \
+ VSTAILQ_NEXT(VSTAILQ_FIRST((head)), field)) == NULL) \
+ (head)->vstqh_last = &VSTAILQ_FIRST((head)); \
+} while (0)
+
+/*
+ * List declarations.
+ */
+#define VLIST_HEAD(name, type) \
+struct name { \
+ struct type *vlh_first; /* first element */ \
+}
+
+#define VLIST_HEAD_INITIALIZER(head) \
+ { NULL }
+
+#define VLIST_ENTRY(type) \
+struct { \
+ struct type *vle_next; /* next element */ \
+ struct type **vle_prev; /* address of previous next element */ \
+}
+
+/*
+ * List functions.
+ */
+#define VLIST_EMPTY(head) ((head)->vlh_first == NULL)
+
+#define VLIST_FIRST(head) ((head)->vlh_first)
+
+#define VLIST_FOREACH(var, head, field) \
+ for ((var) = VLIST_FIRST((head)); \
+ (var); \
+ (var) = VLIST_NEXT((var), field))
+
+#define VLIST_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = VLIST_FIRST((head)); \
+ (var) && ((tvar) = VLIST_NEXT((var), field), 1); \
+ (var) = (tvar))
+
+#define VLIST_INIT(head) do { \
+ VLIST_FIRST((head)) = NULL; \
+} while (0)
+
+#define VLIST_INSERT_AFTER(listelm, elm, field) do { \
+ if ((VLIST_NEXT((elm), field) = VLIST_NEXT((listelm), field)) != NULL)\
+ VLIST_NEXT((listelm), field)->field.vle_prev = \
+ &VLIST_NEXT((elm), field); \
+ VLIST_NEXT((listelm), field) = (elm); \
+ (elm)->field.vle_prev = &VLIST_NEXT((listelm), field); \
+} while (0)
+
+#define VLIST_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.vle_prev = (listelm)->field.vle_prev; \
+ VLIST_NEXT((elm), field) = (listelm); \
+ *(listelm)->field.vle_prev = (elm); \
+ (listelm)->field.vle_prev = &VLIST_NEXT((elm), field); \
+} while (0)
+
+#define VLIST_INSERT_HEAD(head, elm, field) do { \
+ if ((VLIST_NEXT((elm), field) = VLIST_FIRST((head))) != NULL) \
+ VLIST_FIRST((head))->field.vle_prev = &VLIST_NEXT((elm), field);\
+ VLIST_FIRST((head)) = (elm); \
+ (elm)->field.vle_prev = &VLIST_FIRST((head)); \
+} while (0)
+
+#define VLIST_NEXT(elm, field) ((elm)->field.vle_next)
+
+#define VLIST_REMOVE(elm, field) do { \
+ if (VLIST_NEXT((elm), field) != NULL) \
+ VLIST_NEXT((elm), field)->field.vle_prev = \
+ (elm)->field.vle_prev; \
+ *(elm)->field.vle_prev = VLIST_NEXT((elm), field); \
+} while (0)
+
+/*
+ * Tail queue declarations.
+ */
+#define VTAILQ_HEAD(name, type) \
+struct name { \
+ struct type *vtqh_first; /* first element */ \
+ struct type **vtqh_last; /* addr of last next element */ \
+}
+
+#define VTAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).vtqh_first }
+
+#define VTAILQ_ENTRY(type) \
+struct { \
+ struct type *vtqe_next; /* next element */ \
+ struct type **vtqe_prev; /* address of previous next element */\
+}
+
+/*
+ * Tail queue functions.
+ */
+#define VTAILQ_CONCAT(head1, head2, field) do { \
+ if (!VTAILQ_EMPTY(head2)) { \
+ *(head1)->vtqh_last = (head2)->vtqh_first; \
+ (head2)->vtqh_first->field.vtqe_prev = (head1)->vtqh_last;\
+ (head1)->vtqh_last = (head2)->vtqh_last; \
+ VTAILQ_INIT((head2)); \
+ } \
+} while (0)
+
+#define VTAILQ_EMPTY(head) ((head)->vtqh_first == NULL)
+
+#define VTAILQ_FIRST(head) ((head)->vtqh_first)
+
+#define VTAILQ_FOREACH(var, head, field) \
+ for ((var) = VTAILQ_FIRST((head)); \
+ (var); \
+ (var) = VTAILQ_NEXT((var), field))
+
+#define VTAILQ_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = VTAILQ_FIRST((head)); \
+ (var) && ((tvar) = VTAILQ_NEXT((var), field), 1); \
+ (var) = (tvar))
+
+#define VTAILQ_FOREACH_REVERSE(var, head, headname, field) \
+ for ((var) = VTAILQ_LAST((head), headname); \
+ (var); \
+ (var) = VTAILQ_PREV((var), headname, field))
+
+#define VTAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
+ for ((var) = VTAILQ_LAST((head), headname); \
+ (var) && ((tvar) = VTAILQ_PREV((var), headname, field), 1); \
+ (var) = (tvar))
+
+#define VTAILQ_INIT(head) do { \
+ VTAILQ_FIRST((head)) = NULL; \
+ (head)->vtqh_last = &VTAILQ_FIRST((head)); \
+} while (0)
+
+#define VTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if ((VTAILQ_NEXT((elm), field) = VTAILQ_NEXT((listelm), field)) != NULL)\
+ VTAILQ_NEXT((elm), field)->field.vtqe_prev = \
+ &VTAILQ_NEXT((elm), field); \
+ else { \
+ (head)->vtqh_last = &VTAILQ_NEXT((elm), field); \
+ } \
+ VTAILQ_NEXT((listelm), field) = (elm); \
+ (elm)->field.vtqe_prev = &VTAILQ_NEXT((listelm), field); \
+} while (0)
+
+#define VTAILQ_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.vtqe_prev = (listelm)->field.vtqe_prev; \
+ VTAILQ_NEXT((elm), field) = (listelm); \
+ *(listelm)->field.vtqe_prev = (elm); \
+ (listelm)->field.vtqe_prev = &VTAILQ_NEXT((elm), field); \
+} while (0)
+
+#define VTAILQ_INSERT_HEAD(head, elm, field) do { \
+ if ((VTAILQ_NEXT((elm), field) = VTAILQ_FIRST((head))) != NULL) \
+ VTAILQ_FIRST((head))->field.vtqe_prev = \
+ &VTAILQ_NEXT((elm), field); \
+ else \
+ (head)->vtqh_last = &VTAILQ_NEXT((elm), field); \
+ VTAILQ_FIRST((head)) = (elm); \
+ (elm)->field.vtqe_prev = &VTAILQ_FIRST((head)); \
+} while (0)
+
+#define VTAILQ_INSERT_TAIL(head, elm, field) do { \
+ VTAILQ_NEXT((elm), field) = NULL; \
+ (elm)->field.vtqe_prev = (head)->vtqh_last; \
+ *(head)->vtqh_last = (elm); \
+ (head)->vtqh_last = &VTAILQ_NEXT((elm), field); \
+} while (0)
+
+#define VTAILQ_LAST(head, headname) \
+ (*(((struct headname *)((head)->vtqh_last))->vtqh_last))
+
+#define VTAILQ_NEXT(elm, field) ((elm)->field.vtqe_next)
+
+#define VTAILQ_PREV(elm, headname, field) \
+ (*(((struct headname *)((elm)->field.vtqe_prev))->vtqh_last))
+
+#define VTAILQ_REMOVE(head, elm, field) do { \
+ if ((VTAILQ_NEXT((elm), field)) != NULL) \
+ VTAILQ_NEXT((elm), field)->field.vtqe_prev = \
+ (elm)->field.vtqe_prev; \
+ else { \
+ (head)->vtqh_last = (elm)->field.vtqe_prev; \
+ } \
+ *(elm)->field.vtqe_prev = VTAILQ_NEXT((elm), field); \
+} while (0)
+
+
+#ifdef _KERNEL
+
+/*
+ * XXX insque() and remque() are an old way of handling certain queues.
+ * They bogusly assumes that all queue heads look alike.
+ */
+
+struct quehead {
+ struct quehead *qh_link;
+ struct quehead *qh_rlink;
+};
+
+#ifdef __CC_SUPPORTS___INLINE
+
+static __inline void
+insque(void *a, void *b)
+{
+ struct quehead *element = (struct quehead *)a,
+ *head = (struct quehead *)b;
+
+ element->qh_link = head->qh_link;
+ element->qh_rlink = head;
+ head->qh_link = element;
+ element->qh_link->qh_rlink = element;
+}
+
+static __inline void
+remque(void *a)
+{
+ struct quehead *element = (struct quehead *)a;
+
+ element->qh_link->qh_rlink = element->qh_rlink;
+ element->qh_rlink->qh_link = element->qh_link;
+ element->qh_rlink = 0;
+}
+
+#else /* !__CC_SUPPORTS___INLINE */
+
+void insque(void *a, void *b);
+void remque(void *a);
+
+#endif /* __CC_SUPPORTS___INLINE */
+
+#endif /* _KERNEL */
+
+#endif /* !VARNISH_QUEUE_H */
Property changes on: trunk/varnish-cache/include/vqueue.h
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -79,7 +79,7 @@
PF(first));
else
Fc(tl, 0, "\n\t \"%.*s \"", PF(first));
- first = TAILQ_NEXT(first, list);
+ first = VTAILQ_NEXT(first, list);
}
Fc(tl, 0, ",\n");
}
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -71,11 +71,7 @@
#include
#include
-#ifdef HAVE_SYS_QUEUE_H
-#include
-#else
-#include "queue.h"
-#endif
+#include "vqueue.h"
#include "vsb.h"
@@ -108,7 +104,7 @@
mb = calloc(sizeof *mb, 1);
assert(mb != NULL);
mb->ptr = p;
- TAILQ_INSERT_TAIL(&tl->membits, mb, list);
+ VTAILQ_INSERT_TAIL(&tl->membits, mb, list);
}
@@ -264,7 +260,7 @@
pos = 0;
sp = 0;
p = NULL;
- TAILQ_FOREACH(t, &tl->tokens, list) {
+ VTAILQ_FOREACH(t, &tl->tokens, list) {
if (t->cnt == 0)
continue;
assert(t->src != NULL);
@@ -325,7 +321,7 @@
struct source *sp;
Fc(tl, 0, "\nconst char *srcname[%u] = {\n", tl->nsources);
- TAILQ_FOREACH(sp, &tl->sources, list) {
+ VTAILQ_FOREACH(sp, &tl->sources, list) {
Fc(tl, 0, "\t");
EncString(tl->fc, sp->name, NULL, 0);
Fc(tl, 0, ",\n");
@@ -333,7 +329,7 @@
Fc(tl, 0, "};\n");
Fc(tl, 0, "\nconst char *srcbody[%u] = {\n", tl->nsources);
- TAILQ_FOREACH(sp, &tl->sources, list) {
+ VTAILQ_FOREACH(sp, &tl->sources, list) {
Fc(tl, 0, " /* ");
EncString(tl->fc, sp->name, NULL, 0);
Fc(tl, 0, "*/\n");
@@ -431,11 +427,11 @@
struct token *t, *t1, *t2;
struct source *sp;
- TAILQ_FOREACH(t, &tl->tokens, list) {
+ VTAILQ_FOREACH(t, &tl->tokens, list) {
if (t->tok != T_INCLUDE)
continue;
- t1 = TAILQ_NEXT(t, list);
+ t1 = VTAILQ_NEXT(t, list);
assert(t1 != NULL); /* There's always an EOI */
if (t1->tok != CSTR) {
vsb_printf(tl->sb,
@@ -443,7 +439,7 @@
vcc_ErrWhere(tl, t1);
return;
}
- t2 = TAILQ_NEXT(t1, list);
+ t2 = VTAILQ_NEXT(t1, list);
assert(t2 != NULL); /* There's always an EOI */
if (t2->tok != ';') {
vsb_printf(tl->sb,
@@ -458,14 +454,14 @@
vcc_ErrWhere(tl, t1);
return;
}
- TAILQ_INSERT_TAIL(&tl->sources, sp, list);
+ VTAILQ_INSERT_TAIL(&tl->sources, sp, list);
sp->idx = tl->nsources++;
tl->t = t2;
vcc_Lexer(tl, sp);
- TAILQ_REMOVE(&tl->tokens, t, list);
- TAILQ_REMOVE(&tl->tokens, t1, list);
- TAILQ_REMOVE(&tl->tokens, t2, list);
+ VTAILQ_REMOVE(&tl->tokens, t, list);
+ VTAILQ_REMOVE(&tl->tokens, t1, list);
+ VTAILQ_REMOVE(&tl->tokens, t2, list);
if (!tl->err)
vcc_resolve_includes(tl);
return;
@@ -482,11 +478,11 @@
tl = calloc(sizeof *tl, 1);
assert(tl != NULL);
- TAILQ_INIT(&tl->membits);
- TAILQ_INIT(&tl->tokens);
- TAILQ_INIT(&tl->refs);
- TAILQ_INIT(&tl->procs);
- TAILQ_INIT(&tl->sources);
+ VTAILQ_INIT(&tl->membits);
+ VTAILQ_INIT(&tl->tokens);
+ VTAILQ_INIT(&tl->refs);
+ VTAILQ_INIT(&tl->procs);
+ VTAILQ_INIT(&tl->sources);
tl->nsources = 0;
@@ -523,15 +519,15 @@
struct source *sp;
int i;
- while (!TAILQ_EMPTY(&tl->membits)) {
- mb = TAILQ_FIRST(&tl->membits);
- TAILQ_REMOVE(&tl->membits, mb, list);
+ while (!VTAILQ_EMPTY(&tl->membits)) {
+ mb = VTAILQ_FIRST(&tl->membits);
+ VTAILQ_REMOVE(&tl->membits, mb, list);
free(mb->ptr);
free(mb);
}
- while (!TAILQ_EMPTY(&tl->sources)) {
- sp = TAILQ_FIRST(&tl->sources);
- TAILQ_REMOVE(&tl->sources, sp, list);
+ while (!VTAILQ_EMPTY(&tl->sources)) {
+ sp = VTAILQ_FIRST(&tl->sources);
+ VTAILQ_REMOVE(&tl->sources, sp, list);
vcc_destroy_source(sp);
}
@@ -565,7 +561,7 @@
Fh(tl, 0, "\nextern struct VCL_conf VCL_conf;\n");
/* Register and lex the main source */
- TAILQ_INSERT_TAIL(&tl->sources, sp, list);
+ VTAILQ_INSERT_TAIL(&tl->sources, sp, list);
sp->idx = tl->nsources++;
vcc_Lexer(tl, sp);
if (tl->err)
@@ -574,7 +570,7 @@
/* Register and lex the default VCL */
sp = vcc_new_source(vcc_default_vcl_b, vcc_default_vcl_e, "Default");
assert(sp != NULL);
- TAILQ_INSERT_TAIL(&tl->sources, sp, list);
+ VTAILQ_INSERT_TAIL(&tl->sources, sp, list);
sp->idx = tl->nsources++;
vcc_Lexer(tl, sp);
if (tl->err)
@@ -591,7 +587,7 @@
return (vcc_DestroyTokenList(tl, NULL));
/* Parse the token string */
- tl->t = TAILQ_FIRST(&tl->tokens);
+ tl->t = VTAILQ_FIRST(&tl->tokens);
vcc_Parse(tl);
if (tl->err)
return (vcc_DestroyTokenList(tl, NULL));
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h 2007-09-25 08:48:14 UTC (rev 2033)
@@ -29,23 +29,19 @@
* $Id$
*/
-#ifdef HAVE_SYS_QUEUE_H
-#include
-#else
-#include "queue.h"
-#endif
+#include "vqueue.h"
#include "vcl_returns.h"
#define INDENT 2
struct membit {
- TAILQ_ENTRY(membit) list;
+ VTAILQ_ENTRY(membit) list;
void *ptr;
};
struct source {
- TAILQ_ENTRY(source) list;
+ VTAILQ_ENTRY(source) list;
char *name;
const char *b;
const char *e;
@@ -58,17 +54,17 @@
const char *b;
const char *e;
struct source *src;
- TAILQ_ENTRY(token) list;
+ VTAILQ_ENTRY(token) list;
unsigned cnt;
char *dec;
};
-TAILQ_HEAD(tokenhead, token);
+VTAILQ_HEAD(tokenhead, token);
struct tokenlist {
struct tokenhead tokens;
- TAILQ_HEAD(, source) sources;
- TAILQ_HEAD(, membit) membits;
+ VTAILQ_HEAD(, source) sources;
+ VTAILQ_HEAD(, membit) membits;
unsigned nsources;
struct source *src;
struct token *t;
@@ -79,11 +75,11 @@
unsigned cnt;
struct vsb *fc, *fh, *fi, *ff, *fb;
struct vsb *fm[N_METHODS];
- TAILQ_HEAD(, ref) refs;
+ VTAILQ_HEAD(, ref) refs;
struct vsb *sb;
int err;
int nbackend;
- TAILQ_HEAD(, proc) procs;
+ VTAILQ_HEAD(, proc) procs;
struct proc *curproc;
struct proc *mprocs[N_METHODS];
@@ -125,7 +121,7 @@
struct token *name;
unsigned defcnt;
unsigned refcnt;
- TAILQ_ENTRY(ref) list;
+ VTAILQ_ENTRY(ref) list;
};
struct var {
Modified: trunk/varnish-cache/lib/libvcl/vcc_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_token.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/lib/libvcl/vcc_token.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -34,11 +34,7 @@
#include
#include
-#ifdef HAVE_SYS_QUEUE_H
-#include
-#else
-#include "queue.h"
-#endif
+#include "vqueue.h"
#include "vsb.h"
@@ -138,7 +134,7 @@
vcc_NextToken(struct tokenlist *tl)
{
- tl->t = TAILQ_NEXT(tl->t, list);
+ tl->t = VTAILQ_NEXT(tl->t, list);
if (tl->t == NULL) {
vsb_printf(tl->sb,
"Ran out of input, something is missing or"
@@ -267,9 +263,9 @@
t->e = e;
t->src = tl->src;
if (tl->t != NULL)
- TAILQ_INSERT_AFTER(&tl->tokens, tl->t, t, list);
+ VTAILQ_INSERT_AFTER(&tl->tokens, tl->t, t, list);
else
- TAILQ_INSERT_TAIL(&tl->tokens, t, list);
+ VTAILQ_INSERT_TAIL(&tl->tokens, t, list);
tl->t = t;
if (0) {
fprintf(stderr, "[%s %.*s] ",
Modified: trunk/varnish-cache/lib/libvcl/vcc_xref.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_xref.c 2007-09-25 08:21:28 UTC (rev 2032)
+++ trunk/varnish-cache/lib/libvcl/vcc_xref.c 2007-09-25 08:48:14 UTC (rev 2033)
@@ -50,21 +50,21 @@
/*--------------------------------------------------------------------*/
struct proccall {
- TAILQ_ENTRY(proccall) list;
+ VTAILQ_ENTRY(proccall) list;
struct proc *p;
struct token *t;
};
struct procuse {
- TAILQ_ENTRY(procuse) list;
+ VTAILQ_ENTRY(procuse) list;
struct token *t;
struct var *v;
};
struct proc {
- TAILQ_ENTRY(proc) list;
- TAILQ_HEAD(,proccall) calls;
- TAILQ_HEAD(,procuse) uses;
+ VTAILQ_ENTRY(proc) list;
+ VTAILQ_HEAD(,proccall) calls;
+ VTAILQ_HEAD(,procuse) uses;
struct token *name;
unsigned returns;
unsigned exists;
@@ -101,7 +101,7 @@
{
struct ref *r;
- TAILQ_FOREACH(r, &tl->refs, list) {
+ VTAILQ_FOREACH(r, &tl->refs, list) {
if (r->type != type)
continue;
if (vcc_Teq(r->name, t))
@@ -111,7 +111,7 @@
assert(r != NULL);
r->name = t;
r->type = type;
- TAILQ_INSERT_TAIL(&tl->refs, r, list);
+ VTAILQ_INSERT_TAIL(&tl->refs, r, list);
return (r);
}
@@ -154,7 +154,7 @@
const char *type;
int nerr = 0;
- TAILQ_FOREACH(r, &tl->refs, list) {
+ VTAILQ_FOREACH(r, &tl->refs, list) {
if (r->defcnt != 0 && r->refcnt != 0)
continue;
nerr++;
@@ -185,14 +185,14 @@
{
struct proc *p;
- TAILQ_FOREACH(p, &tl->procs, list)
+ VTAILQ_FOREACH(p, &tl->procs, list)
if (vcc_Teq(p->name, t))
return (p);
p = TlAlloc(tl, sizeof *p);
assert(p != NULL);
- TAILQ_INIT(&p->calls);
- TAILQ_INIT(&p->uses);
- TAILQ_INSERT_TAIL(&tl->procs, p, list);
+ VTAILQ_INIT(&p->calls);
+ VTAILQ_INIT(&p->uses);
+ VTAILQ_INSERT_TAIL(&tl->procs, p, list);
p->name = t;
return (p);
}
@@ -219,7 +219,7 @@
assert(pu != NULL);
pu->v = v;
pu->t = tl->t;
- TAILQ_INSERT_TAIL(&tl->curproc->uses, pu, list);
+ VTAILQ_INSERT_TAIL(&tl->curproc->uses, pu, list);
}
void
@@ -233,7 +233,7 @@
assert(pc != NULL);
pc->p = p;
pc->t = t;
- TAILQ_INSERT_TAIL(&tl->curproc->calls, pc, list);
+ VTAILQ_INSERT_TAIL(&tl->curproc->calls, pc, list);
}
void
@@ -279,7 +279,7 @@
return (1);
}
p->active = 1;
- TAILQ_FOREACH(pc, &p->calls, list) {
+ VTAILQ_FOREACH(pc, &p->calls, list) {
if (vcc_CheckActionRecurse(tl, pc->p, returns)) {
vsb_printf(tl->sb, "\n...called from \"%.*s\"\n",
PF(p->name));
@@ -299,7 +299,7 @@
struct method *m;
int i;
- TAILQ_FOREACH(p, &tl->procs, list) {
+ VTAILQ_FOREACH(p, &tl->procs, list) {
i = IsMethod(p->name);
if (i < 0)
continue;
@@ -321,7 +321,7 @@
return (1);
}
}
- TAILQ_FOREACH(p, &tl->procs, list) {
+ VTAILQ_FOREACH(p, &tl->procs, list) {
if (p->called)
continue;
vsb_printf(tl->sb, "Function unused\n");
@@ -336,7 +336,7 @@
{
struct procuse *pu;
- TAILQ_FOREACH(pu, &p->uses, list)
+ VTAILQ_FOREACH(pu, &p->uses, list)
if (!(pu->v->methods & m->bitval))
return (pu);
return (NULL);
@@ -359,7 +359,7 @@
vcc_ErrWhere(tl, p->name);
return (1);
}
- TAILQ_FOREACH(pc, &p->calls, list) {
+ VTAILQ_FOREACH(pc, &p->calls, list) {
if (vcc_CheckUseRecurse(tl, pc->p, m)) {
vsb_printf(tl->sb, "\n...called from \"%.*s\"\n",
PF(p->name));
@@ -378,7 +378,7 @@
struct procuse *pu;
int i;
- TAILQ_FOREACH(p, &tl->procs, list) {
+ VTAILQ_FOREACH(p, &tl->procs, list) {
i = IsMethod(p->name);
if (i < 0)
continue;
From des at projects.linpro.no Tue Sep 25 08:54:11 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Tue, 25 Sep 2007 10:54:11 +0200 (CEST)
Subject: r2034 - in branches/1.1: . bin/varnishd bin/varnishreplay
bin/varnishtop include lib/libvcl
Message-ID: <20070925085411.548581EC1D1@projects.linpro.no>
Author: des
Date: 2007-09-25 10:54:11 +0200 (Tue, 25 Sep 2007)
New Revision: 2034
Added:
branches/1.1/include/vqueue.h
Removed:
branches/1.1/include/queue.h
Modified:
branches/1.1/
branches/1.1/bin/varnishd/cache.h
branches/1.1/bin/varnishd/cache_acceptor.c
branches/1.1/bin/varnishd/cache_acceptor_epoll.c
branches/1.1/bin/varnishd/cache_acceptor_kqueue.c
branches/1.1/bin/varnishd/cache_acceptor_poll.c
branches/1.1/bin/varnishd/cache_backend.c
branches/1.1/bin/varnishd/cache_ban.c
branches/1.1/bin/varnishd/cache_expire.c
branches/1.1/bin/varnishd/cache_fetch.c
branches/1.1/bin/varnishd/cache_hash.c
branches/1.1/bin/varnishd/cache_lru.c
branches/1.1/bin/varnishd/cache_pool.c
branches/1.1/bin/varnishd/cache_response.c
branches/1.1/bin/varnishd/cache_session.c
branches/1.1/bin/varnishd/cache_synthetic.c
branches/1.1/bin/varnishd/cache_vcl.c
branches/1.1/bin/varnishd/cache_vrt.c
branches/1.1/bin/varnishd/hash_classic.c
branches/1.1/bin/varnishd/hash_simple_list.c
branches/1.1/bin/varnishd/heritage.h
branches/1.1/bin/varnishd/mgt_child.c
branches/1.1/bin/varnishd/mgt_event.c
branches/1.1/bin/varnishd/mgt_event.h
branches/1.1/bin/varnishd/mgt_param.c
branches/1.1/bin/varnishd/mgt_vcc.c
branches/1.1/bin/varnishd/storage_file.c
branches/1.1/bin/varnishd/varnishd.c
branches/1.1/bin/varnishreplay/varnishreplay.c
branches/1.1/bin/varnishtop/varnishtop.c
branches/1.1/configure.ac
branches/1.1/include/Makefile.am
branches/1.1/lib/libvcl/vcc_compile.c
branches/1.1/lib/libvcl/vcc_compile.h
branches/1.1/lib/libvcl/vcc_token.c
branches/1.1/lib/libvcl/vcc_xref.c
Log:
Merged revisions 2032-2033 via svnmerge from
file:///var/lib/svn/varnish/trunk/varnish-cache
........
r2032 | des | 2007-09-25 10:21:28 +0200 (Tue, 25 Sep 2007) | 3 lines
Portability: use -lsocket / -lns on systems that need it (read Solaris),
use instead of our own if present.
........
r2033 | des | 2007-09-25 10:48:14 +0200 (Tue, 25 Sep 2007) | 6 lines
The previous commit made things worse rather than better, as some systems
have a that differs in small but important details from what
we expect. Replace our "queue.h" (which was taken from NetBSD) with a new
"vqueue.h" which is based on FreeBSD's with the debugging
taken out and a "V" prefix added to everything.
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2032-2033
Modified: branches/1.1/bin/varnishd/cache.h
===================================================================
--- branches/1.1/bin/varnishd/cache.h 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache.h 2007-09-25 08:54:11 UTC (rev 2034)
@@ -36,7 +36,7 @@
#include
#include
-#include "queue.h"
+#include "vqueue.h"
#include "vsb.h"
#include "libvarnish.h"
@@ -155,7 +155,7 @@
int pipe[2];
- TAILQ_ENTRY(worker) list;
+ VTAILQ_ENTRY(worker) list;
struct workreq *wrq;
int *wfd;
@@ -174,7 +174,7 @@
};
struct workreq {
- TAILQ_ENTRY(workreq) list;
+ VTAILQ_ENTRY(workreq) list;
struct sess *sess;
};
@@ -185,7 +185,7 @@
struct bereq {
unsigned magic;
#define BEREQ_MAGIC 0x3b6d250c
- TAILQ_ENTRY(bereq) list;
+ VTAILQ_ENTRY(bereq) list;
void *space;
unsigned len;
struct http http[1];
@@ -194,7 +194,7 @@
struct vbe_conn {
unsigned magic;
#define VBE_CONN_MAGIC 0x0c5e6592
- TAILQ_ENTRY(vbe_conn) list;
+ VTAILQ_ENTRY(vbe_conn) list;
struct backend *backend;
int fd;
};
@@ -204,7 +204,7 @@
struct storage {
unsigned magic;
#define STORAGE_MAGIC 0x1a4e51c0
- TAILQ_ENTRY(storage) list;
+ VTAILQ_ENTRY(storage) list;
struct stevedore *stevedore;
void *priv;
@@ -256,16 +256,16 @@
double last_modified;
struct http http;
- TAILQ_ENTRY(object) list;
+ VTAILQ_ENTRY(object) list;
- TAILQ_ENTRY(object) deathrow;
+ VTAILQ_ENTRY(object) deathrow;
- TAILQ_HEAD(, storage) store;
+ VTAILQ_HEAD(, storage) store;
- TAILQ_HEAD(, sess) waitinglist;
+ VTAILQ_HEAD(, sess) waitinglist;
double lru_stamp;
- TAILQ_ENTRY(object) lru;
+ VTAILQ_ENTRY(object) lru;
};
struct objhead {
@@ -274,7 +274,7 @@
void *hashpriv;
pthread_mutex_t mtx;
- TAILQ_HEAD(,object) objects;
+ VTAILQ_HEAD(,object) objects;
};
/* -------------------------------------------------------------------*/
@@ -314,7 +314,7 @@
int err_code;
const char *err_reason;
- TAILQ_ENTRY(sess) list;
+ VTAILQ_ENTRY(sess) list;
struct backend *backend;
struct bereq *bereq;
@@ -344,7 +344,7 @@
struct addrinfo *addr;
struct addrinfo *last_addr;
- TAILQ_HEAD(,vbe_conn) connlist;
+ VTAILQ_HEAD(,vbe_conn) connlist;
double dnsttl;
double dnstime;
Modified: branches/1.1/bin/varnishd/cache_acceptor.c
===================================================================
--- branches/1.1/bin/varnishd/cache_acceptor.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_acceptor.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -145,7 +145,7 @@
pfd = calloc(sizeof *pfd, heritage.nsocks);
AN(pfd);
i = 0;
- TAILQ_FOREACH(ls, &heritage.socks, list) {
+ VTAILQ_FOREACH(ls, &heritage.socks, list) {
AZ(setsockopt(ls->sock, SOL_SOCKET, SO_LINGER,
&linger, sizeof linger));
pfd[i].events = POLLIN;
@@ -157,7 +157,7 @@
if (params->send_timeout != tv_sndtimeo.tv_sec) {
need_test = 1;
tv_sndtimeo.tv_sec = params->send_timeout;
- TAILQ_FOREACH(ls, &heritage.socks, list)
+ VTAILQ_FOREACH(ls, &heritage.socks, list)
AZ(setsockopt(ls->sock, SOL_SOCKET,
SO_SNDTIMEO,
&tv_sndtimeo, sizeof tv_sndtimeo));
@@ -165,7 +165,7 @@
if (params->sess_timeout != tv_rcvtimeo.tv_sec) {
need_test = 1;
tv_rcvtimeo.tv_sec = params->sess_timeout;
- TAILQ_FOREACH(ls, &heritage.socks, list)
+ VTAILQ_FOREACH(ls, &heritage.socks, list)
AZ(setsockopt(ls->sock, SOL_SOCKET,
SO_RCVTIMEO,
&tv_rcvtimeo, sizeof tv_rcvtimeo));
Modified: branches/1.1/bin/varnishd/cache_acceptor_epoll.c
===================================================================
--- branches/1.1/bin/varnishd/cache_acceptor_epoll.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_acceptor_epoll.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -49,7 +49,7 @@
static pthread_t vca_epoll_thread;
static int epfd = -1;
-static TAILQ_HEAD(,sess) sesshead = TAILQ_HEAD_INITIALIZER(sesshead);
+static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead);
static void
vca_add(int fd, void *data)
@@ -86,13 +86,13 @@
i = read(vca_pipes[0], &sp, sizeof sp);
assert(i == sizeof sp);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- TAILQ_INSERT_TAIL(&sesshead, sp, list);
+ VTAILQ_INSERT_TAIL(&sesshead, sp, list);
vca_add(sp->fd, sp);
} else {
CAST_OBJ_NOTNULL(sp, ev.data.ptr, SESS_MAGIC);
i = vca_pollsession(sp);
if (i >= 0) {
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
if (sp->fd != -1)
vca_del(sp->fd);
if (i == 0)
@@ -104,11 +104,11 @@
}
/* check for timeouts */
deadline = TIM_real() - params->sess_timeout;
- TAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) {
+ VTAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) {
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (sp->t_open > deadline)
continue;
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
vca_del(sp->fd);
vca_close_session(sp, "timeout");
SES_Delete(sp);
Modified: branches/1.1/bin/varnishd/cache_acceptor_kqueue.c
===================================================================
--- branches/1.1/bin/varnishd/cache_acceptor_kqueue.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_acceptor_kqueue.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -51,7 +51,7 @@
static pthread_t vca_kqueue_thread;
static int kq = -1;
-static TAILQ_HEAD(,sess) sesshead = TAILQ_HEAD_INITIALIZER(sesshead);
+static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead);
#define NKEV 100
@@ -88,7 +88,7 @@
while (i >= sizeof ss[0]) {
CHECK_OBJ_NOTNULL(ss[j], SESS_MAGIC);
assert(ss[j]->fd >= 0);
- TAILQ_INSERT_TAIL(&sesshead, ss[j], list);
+ VTAILQ_INSERT_TAIL(&sesshead, ss[j], list);
vca_kq_sess(ss[j], EV_ADD);
j++;
i -= sizeof ss[0];
@@ -101,7 +101,7 @@
i = vca_pollsession(sp);
if (i == -1)
return;
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
if (i == 0) {
vca_kq_sess(sp, EV_DELETE);
vca_handover(sp, i);
@@ -110,7 +110,7 @@
}
return;
} else if (kp->flags == EV_EOF) {
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
vca_close_session(sp, "EOF");
SES_Delete(sp);
return;
@@ -157,12 +157,12 @@
continue;
deadline = TIM_real() - params->sess_timeout;
for (;;) {
- sp = TAILQ_FIRST(&sesshead);
+ sp = VTAILQ_FIRST(&sesshead);
if (sp == NULL)
break;
if (sp->t_open > deadline)
break;
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
vca_close_session(sp, "timeout");
SES_Delete(sp);
}
Modified: branches/1.1/bin/varnishd/cache_acceptor_poll.c
===================================================================
--- branches/1.1/bin/varnishd/cache_acceptor_poll.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_acceptor_poll.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -51,7 +51,7 @@
static struct pollfd *pollfd;
static unsigned npoll;
-static TAILQ_HEAD(,sess) sesshead = TAILQ_HEAD_INITIALIZER(sesshead);
+static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead);
/*--------------------------------------------------------------------*/
@@ -116,11 +116,11 @@
i = read(vca_pipes[0], &sp, sizeof sp);
assert(i == sizeof sp);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- TAILQ_INSERT_TAIL(&sesshead, sp, list);
+ VTAILQ_INSERT_TAIL(&sesshead, sp, list);
vca_poll(sp->fd);
}
deadline = TIM_real() - params->sess_timeout;
- TAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) {
+ VTAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) {
if (v == 0)
break;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -130,7 +130,7 @@
i = vca_pollsession(sp);
if (i < 0)
continue;
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
vca_unpoll(fd);
if (i == 0)
vca_handover(sp, i);
@@ -140,7 +140,7 @@
}
if (sp->t_open > deadline)
continue;
- TAILQ_REMOVE(&sesshead, sp, list);
+ VTAILQ_REMOVE(&sesshead, sp, list);
vca_unpoll(fd);
vca_close_session(sp, "timeout");
SES_Delete(sp);
Modified: branches/1.1/bin/varnishd/cache_backend.c
===================================================================
--- branches/1.1/bin/varnishd/cache_backend.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_backend.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -54,8 +54,8 @@
/* A backend IP */
-static TAILQ_HEAD(,vbe_conn) vbe_head = TAILQ_HEAD_INITIALIZER(vbe_head);
-static TAILQ_HEAD(,bereq) bereq_head = TAILQ_HEAD_INITIALIZER(bereq_head);
+static VTAILQ_HEAD(,vbe_conn) vbe_head = VTAILQ_HEAD_INITIALIZER(vbe_head);
+static VTAILQ_HEAD(,bereq) bereq_head = VTAILQ_HEAD_INITIALIZER(bereq_head);
static MTX vbemtx;
@@ -68,9 +68,9 @@
volatile unsigned len;
LOCK(&vbemtx);
- bereq = TAILQ_FIRST(&bereq_head);
+ bereq = VTAILQ_FIRST(&bereq_head);
if (bereq != NULL)
- TAILQ_REMOVE(&bereq_head, bereq, list);
+ VTAILQ_REMOVE(&bereq_head, bereq, list);
UNLOCK(&vbemtx);
if (bereq != NULL) {
CHECK_OBJ(bereq, BEREQ_MAGIC);
@@ -96,7 +96,7 @@
CHECK_OBJ_NOTNULL(bereq, BEREQ_MAGIC);
LOCK(&vbemtx);
- TAILQ_INSERT_HEAD(&bereq_head, bereq, list);
+ VTAILQ_INSERT_HEAD(&bereq_head, bereq, list);
UNLOCK(&vbemtx);
}
@@ -257,16 +257,16 @@
vc2 = NULL;
while (1) {
LOCK(&vbemtx);
- vc = TAILQ_FIRST(&bp->connlist);
+ vc = VTAILQ_FIRST(&bp->connlist);
if (vc != NULL) {
assert(vc->backend == bp);
assert(vc->fd >= 0);
- TAILQ_REMOVE(&bp->connlist, vc, list);
+ VTAILQ_REMOVE(&bp->connlist, vc, list);
} else {
- vc2 = TAILQ_FIRST(&vbe_head);
+ vc2 = VTAILQ_FIRST(&vbe_head);
if (vc2 != NULL) {
VSL_stats->backend_unused--;
- TAILQ_REMOVE(&vbe_head, vc2, list);
+ VTAILQ_REMOVE(&vbe_head, vc2, list);
}
}
UNLOCK(&vbemtx);
@@ -295,7 +295,7 @@
vc->fd = vbe_connect(sp, bp);
if (vc->fd < 0) {
LOCK(&vbemtx);
- TAILQ_INSERT_HEAD(&vbe_head, vc, list);
+ VTAILQ_INSERT_HEAD(&vbe_head, vc, list);
VSL_stats->backend_unused++;
UNLOCK(&vbemtx);
vc = NULL;
@@ -355,7 +355,7 @@
vc->fd = -1;
vc->backend = NULL;
LOCK(&vbemtx);
- TAILQ_INSERT_HEAD(&vbe_head, vc, list);
+ VTAILQ_INSERT_HEAD(&vbe_head, vc, list);
VSL_stats->backend_unused++;
UNLOCK(&vbemtx);
}
@@ -372,7 +372,7 @@
WSL(w, SLT_BackendReuse, vc->fd, "%s", vc->backend->vcl_name);
LOCK(&vbemtx);
VSL_stats->backend_recycle++;
- TAILQ_INSERT_HEAD(&vc->backend->connlist, vc, list);
+ VTAILQ_INSERT_HEAD(&vc->backend->connlist, vc, list);
UNLOCK(&vbemtx);
}
Modified: branches/1.1/bin/varnishd/cache_ban.c
===================================================================
--- branches/1.1/bin/varnishd/cache_ban.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_ban.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -42,13 +42,13 @@
#include "cache.h"
struct ban {
- TAILQ_ENTRY(ban) list;
+ VTAILQ_ENTRY(ban) list;
unsigned gen;
regex_t regexp;
char *ban;
};
-static TAILQ_HEAD(,ban) ban_head = TAILQ_HEAD_INITIALIZER(ban_head);
+static VTAILQ_HEAD(,ban) ban_head = VTAILQ_HEAD_INITIALIZER(ban_head);
static unsigned ban_next;
static struct ban *ban_start;
@@ -70,7 +70,7 @@
}
b->gen = ++ban_next;
b->ban = strdup(regexp);
- TAILQ_INSERT_HEAD(&ban_head, b, list);
+ VTAILQ_INSERT_HEAD(&ban_head, b, list);
ban_start = b;
}
@@ -90,7 +90,7 @@
b0 = ban_start;
for (b = b0;
b != NULL && b->gen > o->ban_seq;
- b = TAILQ_NEXT(b, list)) {
+ b = VTAILQ_NEXT(b, list)) {
i = regexec(&b->regexp, url, 0, NULL, 0);
if (!i)
return (1);
Modified: branches/1.1/bin/varnishd/cache_expire.c
===================================================================
--- branches/1.1/bin/varnishd/cache_expire.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_expire.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -50,7 +50,7 @@
static struct binheap *exp_heap;
static MTX exp_mtx;
static unsigned expearly = 30;
-static TAILQ_HEAD(,object) exp_deathrow = TAILQ_HEAD_INITIALIZER(exp_deathrow);
+static VTAILQ_HEAD(,object) exp_deathrow = VTAILQ_HEAD_INITIALIZER(exp_deathrow);
/*--------------------------------------------------------------------*/
@@ -85,8 +85,8 @@
LRU_Remove(o);
if (o->heap_idx)
binheap_delete(exp_heap, o->heap_idx);
- if (o->deathrow.tqe_next) {
- TAILQ_REMOVE(&exp_deathrow, o, deathrow);
+ if (o->deathrow.vtqe_next) {
+ VTAILQ_REMOVE(&exp_deathrow, o, deathrow);
VSL_stats->n_deathrow--;
}
UNLOCK(&exp_mtx);
@@ -109,7 +109,7 @@
t = TIM_real();
while (1) {
LOCK(&exp_mtx);
- TAILQ_FOREACH(o, &exp_deathrow, deathrow) {
+ VTAILQ_FOREACH(o, &exp_deathrow, deathrow) {
CHECK_OBJ(o, OBJECT_MAGIC);
if (o->ttl >= t) {
o = NULL;
@@ -129,7 +129,7 @@
t = TIM_real();
continue;
}
- TAILQ_REMOVE(&exp_deathrow, o, deathrow);
+ VTAILQ_REMOVE(&exp_deathrow, o, deathrow);
VSL_stats->n_deathrow--;
VSL_stats->n_expired++;
UNLOCK(&exp_mtx);
@@ -195,7 +195,7 @@
if (sp->handling == VCL_RET_DISCARD) {
LOCK(&exp_mtx);
- TAILQ_INSERT_TAIL(&exp_deathrow, o, deathrow);
+ VTAILQ_INSERT_TAIL(&exp_deathrow, o, deathrow);
VSL_stats->n_deathrow++;
UNLOCK(&exp_mtx);
continue;
Modified: branches/1.1/bin/varnishd/cache_fetch.c
===================================================================
--- branches/1.1/bin/varnishd/cache_fetch.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_fetch.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -60,7 +60,7 @@
return (0);
st = STV_alloc(cl);
- TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
+ VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
st->len = cl;
sp->obj->len = cl;
p = st->ptr;
@@ -149,7 +149,7 @@
if (u < params->fetch_chunksize * 1024)
v = params->fetch_chunksize * 1024;
st = STV_alloc(v);
- TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
+ VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
}
v = st->space - st->len;
if (v > u)
@@ -194,7 +194,7 @@
}
if (st != NULL && st->len == 0) {
- TAILQ_REMOVE(&sp->obj->store, st, list);
+ VTAILQ_REMOVE(&sp->obj->store, st, list);
STV_free(st);
} else if (st != NULL)
STV_trim(st, st->len);
@@ -224,7 +224,7 @@
while (1) {
if (v == 0) {
st = STV_alloc(params->fetch_chunksize * 1024);
- TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
+ VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
p = st->ptr + st->len;
v = st->space - st->len;
}
@@ -242,7 +242,7 @@
}
if (st->len == 0) {
- TAILQ_REMOVE(&sp->obj->store, st, list);
+ VTAILQ_REMOVE(&sp->obj->store, st, list);
STV_free(st);
} else
STV_trim(st, st->len);
@@ -359,9 +359,9 @@
"Content-Length: %u", sp->obj->len);
if (cls < 0) {
- while (!TAILQ_EMPTY(&sp->obj->store)) {
- st = TAILQ_FIRST(&sp->obj->store);
- TAILQ_REMOVE(&sp->obj->store, st, list);
+ while (!VTAILQ_EMPTY(&sp->obj->store)) {
+ st = VTAILQ_FIRST(&sp->obj->store);
+ VTAILQ_REMOVE(&sp->obj->store, st, list);
STV_free(st);
}
VBE_ClosedFd(sp->wrk, vc, 0);
@@ -373,7 +373,7 @@
unsigned uu;
uu = 0;
- TAILQ_FOREACH(st, &sp->obj->store, list)
+ VTAILQ_FOREACH(st, &sp->obj->store, list)
uu += st->len;
assert(uu == sp->obj->len);
}
Modified: branches/1.1/bin/varnishd/cache_hash.c
===================================================================
--- branches/1.1/bin/varnishd/cache_hash.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_hash.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -77,7 +77,7 @@
w->nobjhead = calloc(sizeof *w->nobjhead, 1);
XXXAN(w->nobjhead);
w->nobjhead->magic = OBJHEAD_MAGIC;
- TAILQ_INIT(&w->nobjhead->objects);
+ VTAILQ_INIT(&w->nobjhead->objects);
MTX_INIT(&w->nobjhead->mtx);
VSL_stats->n_objecthead++;
} else
@@ -89,8 +89,8 @@
w->nobj->http.magic = HTTP_MAGIC;
w->nobj->busy = 1;
w->nobj->refcnt = 1;
- TAILQ_INIT(&w->nobj->store);
- TAILQ_INIT(&w->nobj->waitinglist);
+ VTAILQ_INIT(&w->nobj->store);
+ VTAILQ_INIT(&w->nobj->waitinglist);
VSL_stats->n_object++;
} else
CHECK_OBJ_NOTNULL(w->nobj, OBJECT_MAGIC);
@@ -101,9 +101,9 @@
{
struct storage *st, *stn;
- TAILQ_FOREACH_SAFE(st, &o->store, list, stn) {
+ VTAILQ_FOREACH_SAFE(st, &o->store, list, stn) {
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
- TAILQ_REMOVE(&o->store, st, list);
+ VTAILQ_REMOVE(&o->store, st, list);
STV_free(st);
}
}
@@ -179,10 +179,10 @@
if (oh == w->nobjhead)
w->nobjhead = NULL;
LOCK(&oh->mtx);
- TAILQ_FOREACH(o, &oh->objects, list) {
+ VTAILQ_FOREACH(o, &oh->objects, list) {
o->refcnt++;
if (o->busy) {
- TAILQ_INSERT_TAIL(&o->waitinglist, sp, list);
+ VTAILQ_INSERT_TAIL(&o->waitinglist, sp, list);
sp->obj = o;
UNLOCK(&oh->mtx);
return (NULL);
@@ -214,7 +214,7 @@
o = w->nobj;
w->nobj = NULL;
o->objhead = oh;
- TAILQ_INSERT_TAIL(&oh->objects, o, list);
+ VTAILQ_INSERT_TAIL(&oh->objects, o, list);
/* NB: do not deref objhead the new object inherits our reference */
UNLOCK(&oh->mtx);
BAN_NewObj(o);
@@ -242,10 +242,10 @@
if (oh != NULL)
UNLOCK(&oh->mtx);
while (1) {
- sp = TAILQ_FIRST(&o->waitinglist);
+ sp = VTAILQ_FIRST(&o->waitinglist);
if (sp == NULL)
break;
- TAILQ_REMOVE(&o->waitinglist, sp, list);
+ VTAILQ_REMOVE(&o->waitinglist, sp, list);
WRK_QueueSession(sp);
}
}
@@ -285,7 +285,7 @@
r = --o->refcnt;
if (oh != NULL) {
if (!r)
- TAILQ_REMOVE(&oh->objects, o, list);
+ VTAILQ_REMOVE(&oh->objects, o, list);
UNLOCK(&oh->mtx);
}
@@ -309,7 +309,7 @@
/* Drop our ref on the objhead */
if (hash->deref(oh))
return;
- assert(TAILQ_EMPTY(&oh->objects));
+ assert(VTAILQ_EMPTY(&oh->objects));
MTX_DESTROY(&oh->mtx);
VSL_stats->n_objecthead--;
FREE_OBJ(oh);
Modified: branches/1.1/bin/varnishd/cache_lru.c
===================================================================
--- branches/1.1/bin/varnishd/cache_lru.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_lru.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -30,7 +30,7 @@
#include "shmlog.h"
#include "cache.h"
-#include "queue.h"
+#include "vqueue.h"
/*
* For performance reasons, objects are only moved to the head of the LRU
@@ -40,9 +40,9 @@
*/
#define LRU_DELAY 2
-TAILQ_HEAD(lru_head, object);
+VTAILQ_HEAD(lru_head, object);
-static struct lru_head lru_list = TAILQ_HEAD_INITIALIZER(lru_list);
+static struct lru_head lru_list = VTAILQ_HEAD_INITIALIZER(lru_list);
static pthread_mutex_t lru_mtx = PTHREAD_MUTEX_INITIALIZER;
static struct sess *lru_session;
static struct worker lru_worker;
@@ -76,12 +76,12 @@
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
assert(stamp > 0);
- if (o->lru_stamp < stamp - LRU_DELAY && o != lru_list.tqh_first) {
+ if (o->lru_stamp < stamp - LRU_DELAY && o != lru_list.vtqh_first) {
// VSL(SLT_LRU_enter, 0, "%u %u %u", o->xid, o->lru_stamp, stamp);
LOCK(&lru_mtx);
if (o->lru_stamp != 0)
- TAILQ_REMOVE(&lru_list, o, lru);
- TAILQ_INSERT_HEAD(&lru_list, o, lru);
+ VTAILQ_REMOVE(&lru_list, o, lru);
+ VTAILQ_INSERT_HEAD(&lru_list, o, lru);
o->lru_stamp = stamp;
UNLOCK(&lru_mtx);
}
@@ -98,7 +98,7 @@
if (o->lru_stamp != 0) {
// VSL(SLT_LRU_remove, 0, "%u", o->xid);
LOCK(&lru_mtx);
- TAILQ_REMOVE(&lru_list, o, lru);
+ VTAILQ_REMOVE(&lru_list, o, lru);
UNLOCK(&lru_mtx);
}
}
@@ -119,7 +119,7 @@
LRU_Init();
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- TAILQ_REMOVE(&lru_list, o, lru);
+ VTAILQ_REMOVE(&lru_list, o, lru);
lru_session->obj = o;
VCL_discard_method(lru_session);
@@ -132,9 +132,9 @@
return (1);
} else {
/* keep: move to front of list */
- if ((so = TAILQ_FIRST(&lru_list)))
+ if ((so = VTAILQ_FIRST(&lru_list)))
o->lru_stamp = so->lru_stamp;
- TAILQ_INSERT_HEAD(&lru_list, o, lru);
+ VTAILQ_INSERT_HEAD(&lru_list, o, lru);
return (0);
}
}
@@ -147,12 +147,12 @@
int
LRU_DiscardOne(void)
{
- struct object *first = TAILQ_FIRST(&lru_list);
+ struct object *first = VTAILQ_FIRST(&lru_list);
struct object *o;
int count = 0;
LOCK(&lru_mtx);
- while (!count && (o = TAILQ_LAST(&lru_list, lru_head))) {
+ while (!count && (o = VTAILQ_LAST(&lru_list, lru_head))) {
if (LRU_DiscardLocked(o))
++count;
if (o == first) {
@@ -172,13 +172,13 @@
int
LRU_DiscardSpace(int64_t quota)
{
- struct object *first = TAILQ_FIRST(&lru_list);
+ struct object *first = VTAILQ_FIRST(&lru_list);
struct object *o;
unsigned int len;
int count = 0;
LOCK(&lru_mtx);
- while (quota > 0 && (o = TAILQ_LAST(&lru_list, lru_head))) {
+ while (quota > 0 && (o = VTAILQ_LAST(&lru_list, lru_head))) {
len = o->len;
if (LRU_DiscardLocked(o)) {
quota -= len;
@@ -201,12 +201,12 @@
int
LRU_DiscardTime(double cutoff)
{
- struct object *first = TAILQ_FIRST(&lru_list);
+ struct object *first = VTAILQ_FIRST(&lru_list);
struct object *o;
int count = 0;
LOCK(&lru_mtx);
- while ((o = TAILQ_LAST(&lru_list, lru_head)) && o->lru_stamp <= cutoff) {
+ while ((o = VTAILQ_LAST(&lru_list, lru_head)) && o->lru_stamp <= cutoff) {
if (LRU_DiscardLocked(o))
++count;
if (o == first) {
Modified: branches/1.1/bin/varnishd/cache_pool.c
===================================================================
--- branches/1.1/bin/varnishd/cache_pool.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_pool.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -57,7 +57,7 @@
#include "cli_priv.h"
#include "cache.h"
-TAILQ_HEAD(workerhead, worker);
+VTAILQ_HEAD(workerhead, worker);
/* Number of work requests queued in excess of worker threads available */
@@ -68,7 +68,7 @@
};
static MTX tmtx;
-static TAILQ_HEAD(, workreq) overflow = TAILQ_HEAD_INITIALIZER(overflow);
+static VTAILQ_HEAD(, workreq) overflow = VTAILQ_HEAD_INITIALIZER(overflow);
static struct wq **wq;
static unsigned nwq;
@@ -224,13 +224,13 @@
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
/* Process overflow requests, if any */
- w->wrq = TAILQ_FIRST(&overflow);
+ w->wrq = VTAILQ_FIRST(&overflow);
if (w->wrq != NULL) {
LOCK(&tmtx);
- w->wrq = TAILQ_FIRST(&overflow);
+ w->wrq = VTAILQ_FIRST(&overflow);
if (w->wrq != NULL) {
VSL_stats->n_wrk_queue--;
- TAILQ_REMOVE(&overflow, w->wrq, list);
+ VTAILQ_REMOVE(&overflow, w->wrq, list);
UNLOCK(&tmtx);
wrk_do_one(w);
continue;
@@ -239,7 +239,7 @@
}
LOCK(&qp->mtx);
- TAILQ_INSERT_HEAD(&qp->idle, w, list);
+ VTAILQ_INSERT_HEAD(&qp->idle, w, list);
assert(!isnan(w->used));
UNLOCK(&qp->mtx);
assert(1 == read(w->pipe[0], &c, 1));
@@ -288,9 +288,9 @@
LOCK(&qp->mtx);
/* If there are idle threads, we tickle the first one into action */
- w = TAILQ_FIRST(&qp->idle);
+ w = VTAILQ_FIRST(&qp->idle);
if (w != NULL) {
- TAILQ_REMOVE(&qp->idle, w, list);
+ VTAILQ_REMOVE(&qp->idle, w, list);
UNLOCK(&qp->mtx);
w->wrq = &sp->workreq;
assert(1 == write(w->pipe[1], w, 1));
@@ -323,7 +323,7 @@
* XXX: Not sure how though. Simply closing may be the better
* XXX: compromise.
*/
- TAILQ_INSERT_TAIL(&overflow, &sp->workreq, list);
+ VTAILQ_INSERT_TAIL(&overflow, &sp->workreq, list);
VSL_stats->n_wrk_overflow++;
VSL_stats->n_wrk_queue++;
/* Can we create more threads ? */
@@ -377,7 +377,7 @@
wq[u] = calloc(sizeof *wq[u], 1);
XXXAN(wq[u]);
MTX_INIT(&wq[u]->mtx);
- TAILQ_INIT(&wq[u]->idle);
+ VTAILQ_INIT(&wq[u]->idle);
}
free(owq);
nwq = t;
@@ -403,11 +403,11 @@
for (u = 0; u < nwq; u++) {
qp = wq[u];
LOCK(&qp->mtx);
- w = TAILQ_LAST(&qp->idle, workerhead);
+ w = VTAILQ_LAST(&qp->idle, workerhead);
if (w != NULL &&
(w->used + params->wthread_timeout < now ||
VSL_stats->n_wrk > params->wthread_max))
- TAILQ_REMOVE(&qp->idle, w, list);
+ VTAILQ_REMOVE(&qp->idle, w, list);
else
w = NULL;
UNLOCK(&qp->mtx);
Modified: branches/1.1/bin/varnishd/cache_response.c
===================================================================
--- branches/1.1/bin/varnishd/cache_response.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_response.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -158,7 +158,7 @@
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (sp->wantbody) {
- TAILQ_FOREACH(st, &sp->obj->store, list) {
+ VTAILQ_FOREACH(st, &sp->obj->store, list) {
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
AN(st->stevedore);
Modified: branches/1.1/bin/varnishd/cache_session.c
===================================================================
--- branches/1.1/bin/varnishd/cache_session.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_session.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -67,13 +67,13 @@
struct sess sess;
struct http http;
unsigned workspace;
- TAILQ_ENTRY(sessmem) list;
+ VTAILQ_ENTRY(sessmem) list;
struct sockaddr_storage sockaddr[2];
};
-static TAILQ_HEAD(,sessmem) ses_free_mem[2] = {
- TAILQ_HEAD_INITIALIZER(ses_free_mem[0]),
- TAILQ_HEAD_INITIALIZER(ses_free_mem[1]),
+static VTAILQ_HEAD(,sessmem) ses_free_mem[2] = {
+ VTAILQ_HEAD_INITIALIZER(ses_free_mem[0]),
+ VTAILQ_HEAD_INITIALIZER(ses_free_mem[1]),
};
static unsigned ses_qp;
@@ -86,7 +86,7 @@
#define SRCADDR_MAGIC 0x375111db
unsigned hash;
- TAILQ_ENTRY(srcaddr) list;
+ VTAILQ_ENTRY(srcaddr) list;
struct srcaddrhead *sah;
char addr[TCP_ADDRBUFSIZE];
@@ -101,7 +101,7 @@
static struct srcaddrhead {
unsigned magic;
#define SRCADDRHEAD_MAGIC 0x38231a8b
- TAILQ_HEAD(,srcaddr) head;
+ VTAILQ_HEAD(,srcaddr) head;
MTX mtx;
} *srchash;
@@ -141,17 +141,17 @@
LOCK(&ch->mtx);
c3 = NULL;
- TAILQ_FOREACH_SAFE(c, &ch->head, list, c2) {
+ VTAILQ_FOREACH_SAFE(c, &ch->head, list, c2) {
if (c->hash == u && !strcmp(c->addr, sp->addr)) {
if (c->nref == 0)
VSL_stats->n_srcaddr_act++;
c->nref++;
c->ttl = now + params->srcaddr_ttl;
sp->srcaddr = c;
- TAILQ_REMOVE(&ch->head, c, list);
- TAILQ_INSERT_TAIL(&ch->head, c, list);
+ VTAILQ_REMOVE(&ch->head, c, list);
+ VTAILQ_INSERT_TAIL(&ch->head, c, list);
if (c3 != NULL) {
- TAILQ_REMOVE(&ch->head, c3, list);
+ VTAILQ_REMOVE(&ch->head, c3, list);
VSL_stats->n_srcaddr--;
}
UNLOCK(&ch->mtx);
@@ -169,7 +169,7 @@
sp->wrk->srcaddr = NULL;
VSL_stats->n_srcaddr++;
} else
- TAILQ_REMOVE(&ch->head, c3, list);
+ VTAILQ_REMOVE(&ch->head, c3, list);
AN(c3);
memset(c3, 0, sizeof *c3);
c3->magic = SRCADDR_MAGIC;
@@ -180,7 +180,7 @@
c3->nref = 1;
c3->sah = ch;
VSL_stats->n_srcaddr_act++;
- TAILQ_INSERT_TAIL(&ch->head, c3, list);
+ VTAILQ_INSERT_TAIL(&ch->head, c3, list);
sp->srcaddr = c3;
UNLOCK(&ch->mtx);
}
@@ -267,7 +267,7 @@
* thread ever gets here to empty it.
*/
assert(ses_qp <= 1);
- sm = TAILQ_FIRST(&ses_free_mem[ses_qp]);
+ sm = VTAILQ_FIRST(&ses_free_mem[ses_qp]);
if (sm == NULL) {
/*
* If that queue is empty, flip queues holding the lock
@@ -276,10 +276,10 @@
LOCK(&ses_mem_mtx);
ses_qp = 1 - ses_qp;
UNLOCK(&ses_mem_mtx);
- sm = TAILQ_FIRST(&ses_free_mem[ses_qp]);
+ sm = VTAILQ_FIRST(&ses_free_mem[ses_qp]);
}
if (sm != NULL) {
- TAILQ_REMOVE(&ses_free_mem[ses_qp], sm, list);
+ VTAILQ_REMOVE(&ses_free_mem[ses_qp], sm, list);
} else {
/*
* If that fails, alloc new one.
@@ -351,7 +351,7 @@
free(sm);
} else {
LOCK(&ses_mem_mtx);
- TAILQ_INSERT_HEAD(&ses_free_mem[1 - ses_qp], sm, list);
+ VTAILQ_INSERT_HEAD(&ses_free_mem[1 - ses_qp], sm, list);
UNLOCK(&ses_mem_mtx);
}
}
@@ -368,7 +368,7 @@
XXXAN(srchash);
for (i = 0; i < nsrchash; i++) {
srchash[i].magic = SRCADDRHEAD_MAGIC;
- TAILQ_INIT(&srchash[i].head);
+ VTAILQ_INIT(&srchash[i].head);
MTX_INIT(&srchash[i].mtx);
}
MTX_INIT(&stat_mtx);
Modified: branches/1.1/bin/varnishd/cache_synthetic.c
===================================================================
--- branches/1.1/bin/varnishd/cache_synthetic.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_synthetic.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -88,7 +88,7 @@
/* XXX what if the object already has a body? */
st = STV_alloc(1024);
XXXAN(st->stevedore);
- TAILQ_INSERT_TAIL(&sp->obj->store, st, list);
+ VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
/* generate body */
vsb_new(&vsb, (char *)st->ptr, st->space, VSB_FIXEDLEN);
Modified: branches/1.1/bin/varnishd/cache_vcl.c
===================================================================
--- branches/1.1/bin/varnishd/cache_vcl.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_vcl.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -46,7 +46,7 @@
#include "cache.h"
struct vcls {
- TAILQ_ENTRY(vcls) list;
+ VTAILQ_ENTRY(vcls) list;
const char *name;
void *dlh;
struct VCL_conf *conf;
@@ -57,8 +57,8 @@
* XXX: Presently all modifications to this list happen from the
* CLI event-engine, so no locking is necessary
*/
-static TAILQ_HEAD(, vcls) vcl_head =
- TAILQ_HEAD_INITIALIZER(vcl_head);
+static VTAILQ_HEAD(, vcls) vcl_head =
+ VTAILQ_HEAD_INITIALIZER(vcl_head);
static struct vcls *vcl_active; /* protected by vcl_mtx */
@@ -106,7 +106,7 @@
/* XXX: purge backends */
}
if (vc->busy == 0 && vcl->discard) {
- TAILQ_REMOVE(&vcl_head, vcl, list);
+ VTAILQ_REMOVE(&vcl_head, vcl, list);
} else {
vcl = NULL;
}
@@ -123,7 +123,7 @@
{
struct vcls *vcl;
- TAILQ_FOREACH(vcl, &vcl_head, list)
+ VTAILQ_FOREACH(vcl, &vcl_head, list)
if (!strcmp(vcl->name, name))
return (vcl);
return (NULL);
@@ -179,7 +179,7 @@
vcl->conf->priv = vcl;
vcl->name = strdup(name);
XXXAN(vcl->name);
- TAILQ_INSERT_TAIL(&vcl_head, vcl, list);
+ VTAILQ_INSERT_TAIL(&vcl_head, vcl, list);
LOCK(&vcl_mtx);
if (vcl_active == NULL)
vcl_active = vcl;
@@ -201,7 +201,7 @@
(void)av;
(void)priv;
- TAILQ_FOREACH(vcl, &vcl_head, list) {
+ VTAILQ_FOREACH(vcl, &vcl_head, list) {
cli_out(cli, "%s %6u %s\n",
vcl == vcl_active ? "* " : " ",
vcl->conf->busy,
@@ -247,7 +247,7 @@
}
vcl->discard = 1;
if (vcl->conf->busy == 0)
- TAILQ_REMOVE(&vcl_head, vcl, list);
+ VTAILQ_REMOVE(&vcl_head, vcl, list);
else
vcl = NULL;
UNLOCK(&vcl_mtx);
Modified: branches/1.1/bin/varnishd/cache_vrt.c
===================================================================
--- branches/1.1/bin/varnishd/cache_vrt.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/cache_vrt.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -288,7 +288,7 @@
XXXAN(cp->backend[i]);
cp->backend[i]->magic = BACKEND_MAGIC;
cp->backend[i]->dnsttl = 30;
- TAILQ_INIT(&cp->backend[i]->connlist);
+ VTAILQ_INIT(&cp->backend[i]->connlist);
}
}
Modified: branches/1.1/bin/varnishd/hash_classic.c
===================================================================
--- branches/1.1/bin/varnishd/hash_classic.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/hash_classic.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -44,7 +44,7 @@
struct hcl_entry {
unsigned magic;
#define HCL_ENTRY_MAGIC 0x0ba707bf
- TAILQ_ENTRY(hcl_entry) list;
+ VTAILQ_ENTRY(hcl_entry) list;
struct hcl_hd *head;
char *key;
unsigned klen;
@@ -57,7 +57,7 @@
struct hcl_hd {
unsigned magic;
#define HCL_HEAD_MAGIC 0x0f327016
- TAILQ_HEAD(, hcl_entry) head;
+ VTAILQ_HEAD(, hcl_entry) head;
MTX mtx;
};
@@ -105,7 +105,7 @@
XXXAN(hcl_head);
for (u = 0; u < hcl_nhash; u++) {
- TAILQ_INIT(&hcl_head[u].head);
+ VTAILQ_INIT(&hcl_head[u].head);
MTX_INIT(&hcl_head[u].mtx);
hcl_head[u].magic = HCL_HEAD_MAGIC;
}
@@ -144,7 +144,7 @@
for (r = 0; r < 2; r++ ) {
LOCK(&hp->mtx);
- TAILQ_FOREACH(he, &hp->head, list) {
+ VTAILQ_FOREACH(he, &hp->head, list) {
CHECK_OBJ_NOTNULL(he, HCL_ENTRY_MAGIC);
if (sp->lhashptr < he->klen)
continue;
@@ -172,9 +172,9 @@
}
if (he2 != NULL) {
if (he != NULL)
- TAILQ_INSERT_BEFORE(he, he2, list);
+ VTAILQ_INSERT_BEFORE(he, he2, list);
else
- TAILQ_INSERT_TAIL(&hp->head, he2, list);
+ VTAILQ_INSERT_TAIL(&hp->head, he2, list);
he2->refcnt++;
noh = he2->oh;
UNLOCK(&hp->mtx);
@@ -219,7 +219,7 @@
assert(hp == &hcl_head[he->hash]);
LOCK(&hp->mtx);
if (--he->refcnt == 0)
- TAILQ_REMOVE(&hp->head, he, list);
+ VTAILQ_REMOVE(&hp->head, he, list);
else
he = NULL;
UNLOCK(&hp->mtx);
Modified: branches/1.1/bin/varnishd/hash_simple_list.c
===================================================================
--- branches/1.1/bin/varnishd/hash_simple_list.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/hash_simple_list.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -43,14 +43,14 @@
/*--------------------------------------------------------------------*/
struct hsl_entry {
- TAILQ_ENTRY(hsl_entry) list;
+ VTAILQ_ENTRY(hsl_entry) list;
char *key;
int keylen;
struct objhead *obj;
unsigned refcnt;
};
-static TAILQ_HEAD(, hsl_entry) hsl_head = TAILQ_HEAD_INITIALIZER(hsl_head);
+static VTAILQ_HEAD(, hsl_entry) hsl_head = VTAILQ_HEAD_INITIALIZER(hsl_head);
static MTX hsl_mutex;
/*--------------------------------------------------------------------
@@ -79,7 +79,7 @@
int i;
LOCK(&hsl_mutex);
- TAILQ_FOREACH(he, &hsl_head, list) {
+ VTAILQ_FOREACH(he, &hsl_head, list) {
i = HSH_Compare(sp, he->key, he->key + he->keylen);
if (i < 0)
continue;
@@ -103,9 +103,9 @@
HSH_Copy(sp, he2->key, he2->key + he2->keylen);
nobj->hashpriv = he2;
if (he != NULL)
- TAILQ_INSERT_BEFORE(he, he2, list);
+ VTAILQ_INSERT_BEFORE(he, he2, list);
else
- TAILQ_INSERT_TAIL(&hsl_head, he2, list);
+ VTAILQ_INSERT_TAIL(&hsl_head, he2, list);
UNLOCK(&hsl_mutex);
return (nobj);
}
@@ -124,7 +124,7 @@
he = obj->hashpriv;
LOCK(&hsl_mutex);
if (--he->refcnt == 0) {
- TAILQ_REMOVE(&hsl_head, he, list);
+ VTAILQ_REMOVE(&hsl_head, he, list);
free(he);
ret = 0;
} else
Modified: branches/1.1/bin/varnishd/heritage.h
===================================================================
--- branches/1.1/bin/varnishd/heritage.h 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/heritage.h 2007-09-25 08:54:11 UTC (rev 2034)
@@ -31,15 +31,15 @@
* This file contains the heritage passed when mgt forks cache
*/
-#include "queue.h"
+#include "vqueue.h"
struct listen_sock {
- TAILQ_ENTRY(listen_sock) list;
+ VTAILQ_ENTRY(listen_sock) list;
int sock;
struct vss_addr *addr;
};
-TAILQ_HEAD(listen_sock_head, listen_sock);
+VTAILQ_HEAD(listen_sock_head, listen_sock);
struct heritage {
Modified: branches/1.1/bin/varnishd/mgt_child.c
===================================================================
--- branches/1.1/bin/varnishd/mgt_child.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/mgt_child.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -127,14 +127,14 @@
struct listen_sock *ls, *ls2;
int good = 0;
- TAILQ_FOREACH_SAFE(ls, &heritage.socks, list, ls2) {
+ VTAILQ_FOREACH_SAFE(ls, &heritage.socks, list, ls2) {
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);
+ VTAILQ_REMOVE(&heritage.socks, ls, list);
free(ls);
continue;
}
@@ -153,7 +153,7 @@
{
struct listen_sock *ls;
- TAILQ_FOREACH(ls, &heritage.socks, list) {
+ VTAILQ_FOREACH(ls, &heritage.socks, list) {
if (ls->sock < 0)
continue;
close(ls->sock);
Modified: branches/1.1/bin/varnishd/mgt_event.c
===================================================================
--- branches/1.1/bin/varnishd/mgt_event.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/mgt_event.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -60,7 +60,7 @@
struct evbase {
unsigned magic;
#define EVBASE_MAGIC 0x0cfd976f
- TAILQ_HEAD(,ev) events;
+ VTAILQ_HEAD(,ev) events;
struct pollfd *pfd;
unsigned npfd;
unsigned lpfd;
@@ -173,7 +173,7 @@
return (NULL);
}
evb->magic = EVBASE_MAGIC;
- TAILQ_INIT(&evb->events);
+ VTAILQ_INIT(&evb->events);
evb->binheap = binheap_new(evb, ev_bh_cmp, ev_bh_update);
return (evb);
}
@@ -259,9 +259,9 @@
e->__evb = evb;
e->__privflags = 0;
if (e->fd < 0)
- TAILQ_INSERT_TAIL(&evb->events, e, __list);
+ VTAILQ_INSERT_TAIL(&evb->events, e, __list);
else
- TAILQ_INSERT_HEAD(&evb->events, e, __list);
+ VTAILQ_INSERT_HEAD(&evb->events, e, __list);
if (e->sig > 0) {
assert(es != NULL);
@@ -307,7 +307,7 @@
es->happened = 0;
}
- TAILQ_REMOVE(&evb->events, e, __list);
+ VTAILQ_REMOVE(&evb->events, e, __list);
e->magic = 0;
e->__evb = NULL;
@@ -339,11 +339,11 @@
struct ev *ep;
p = evb->pfd;
- ep = TAILQ_FIRST(&evb->events);
+ ep = VTAILQ_FIRST(&evb->events);
for (u = 0; u < evb->lpfd; u++, p++) {
if (p->fd >= 0)
continue;
- for(; ep != NULL; ep = TAILQ_NEXT(ep, __list)) {
+ for(; ep != NULL; ep = VTAILQ_NEXT(ep, __list)) {
if (ep->fd >= 0 && ep->__poll_idx > u)
break;
}
@@ -441,7 +441,7 @@
return (ev_sched_timeout(evb, e, t));
}
evb->disturbed = 0;
- TAILQ_FOREACH_SAFE(e, &evb->events, __list, e2) {
+ VTAILQ_FOREACH_SAFE(e, &evb->events, __list, e2) {
if (i == 0)
break;
if (e->fd < 0)
@@ -454,9 +454,9 @@
j = e->callback(e, pfd->revents);
i--;
if (evb->disturbed) {
- TAILQ_FOREACH(e3, &evb->events, __list) {
+ VTAILQ_FOREACH(e3, &evb->events, __list) {
if (e3 == e) {
- e3 = TAILQ_NEXT(e, __list);
+ e3 = VTAILQ_NEXT(e, __list);
break;
} else if (e3 == e2)
break;
Modified: branches/1.1/bin/varnishd/mgt_event.h
===================================================================
--- branches/1.1/bin/varnishd/mgt_event.h 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/mgt_event.h 2007-09-25 08:54:11 UTC (rev 2034)
@@ -30,7 +30,7 @@
*/
#include
-#include "queue.h"
+#include "vqueue.h"
struct ev;
struct evbase;
@@ -58,7 +58,7 @@
/* priv */
double __when;
- TAILQ_ENTRY(ev) __list;
+ VTAILQ_ENTRY(ev) __list;
unsigned __binheap_idx;
unsigned __privflags;
struct evbase *__evb;
Modified: branches/1.1/bin/varnishd/mgt_param.c
===================================================================
--- branches/1.1/bin/varnishd/mgt_param.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/mgt_param.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -374,8 +374,8 @@
{
struct listen_sock *ls, *ls2;
- TAILQ_FOREACH_SAFE(ls, lsh, list, ls2) {
- TAILQ_REMOVE(lsh, ls, list);
+ VTAILQ_FOREACH_SAFE(ls, lsh, list, ls2) {
+ VTAILQ_REMOVE(lsh, ls, list);
free(ls->addr);
free(ls);
}
@@ -412,7 +412,7 @@
FreeArgv(av);
return;
}
- TAILQ_INIT(&lsh);
+ VTAILQ_INIT(&lsh);
for (i = 1; av[i] != NULL; i++) {
struct vss_addr **ta;
char *host, *port;
@@ -436,7 +436,7 @@
AN(ls);
ls->sock = -1;
ls->addr = ta[j];
- TAILQ_INSERT_TAIL(&lsh, ls, list);
+ VTAILQ_INSERT_TAIL(&lsh, ls, list);
}
free(ta);
}
@@ -451,10 +451,10 @@
clean_listen_sock_head(&heritage.socks);
heritage.nsocks = 0;
- while (!TAILQ_EMPTY(&lsh)) {
- ls = TAILQ_FIRST(&lsh);
- TAILQ_REMOVE(&lsh, ls, list);
- TAILQ_INSERT_TAIL(&heritage.socks, ls, list);
+ while (!VTAILQ_EMPTY(&lsh)) {
+ ls = VTAILQ_FIRST(&lsh);
+ VTAILQ_REMOVE(&lsh, ls, list);
+ VTAILQ_INSERT_TAIL(&heritage.socks, ls, list);
heritage.nsocks++;
}
}
Modified: branches/1.1/bin/varnishd/mgt_vcc.c
===================================================================
--- branches/1.1/bin/varnishd/mgt_vcc.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/mgt_vcc.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -43,7 +43,7 @@
#include "compat/asprintf.h"
#endif
#include "vsb.h"
-#include "queue.h"
+#include "vqueue.h"
#include "libvcl.h"
#include "cli.h"
@@ -57,13 +57,13 @@
#include "vss.h"
struct vclprog {
- TAILQ_ENTRY(vclprog) list;
+ VTAILQ_ENTRY(vclprog) list;
char *name;
char *fname;
int active;
};
-static TAILQ_HEAD(, vclprog) vclhead = TAILQ_HEAD_INITIALIZER(vclhead);
+static VTAILQ_HEAD(, vclprog) vclhead = VTAILQ_HEAD_INITIALIZER(vclhead);
/*--------------------------------------------------------------------*/
@@ -291,14 +291,14 @@
XXXAN(vp);
vp->name = strdup(name);
vp->fname = file;
- TAILQ_INSERT_TAIL(&vclhead, vp, list);
+ VTAILQ_INSERT_TAIL(&vclhead, vp, list);
return (vp);
}
static void
mgt_vcc_del(struct vclprog *vp)
{
- TAILQ_REMOVE(&vclhead, vp, list);
+ VTAILQ_REMOVE(&vclhead, vp, list);
printf("unlink %s\n", vp->fname);
XXXAZ(unlink(vp->fname));
free(vp->fname);
@@ -311,7 +311,7 @@
{
struct vclprog *vp;
- TAILQ_FOREACH(vp, &vclhead, list) {
+ VTAILQ_FOREACH(vp, &vclhead, list) {
if (!strcmp(name, vp->name)) {
mgt_vcc_del(vp);
return (0);
@@ -381,7 +381,7 @@
{
struct vclprog *vp;
- TAILQ_FOREACH(vp, &vclhead, list) {
+ VTAILQ_FOREACH(vp, &vclhead, list) {
if (mgt_cli_askchild(status, p,
"vcl.load %s %s\n", vp->name, vp->fname))
return (1);
@@ -411,7 +411,7 @@
if (getpid() != mgt_pid)
return;
while (1) {
- vp = TAILQ_FIRST(&vclhead);
+ vp = VTAILQ_FIRST(&vclhead);
if (vp == NULL)
break;
mgt_vcc_del(vp);
@@ -494,7 +494,7 @@
{
struct vclprog *vp;
- TAILQ_FOREACH(vp, &vclhead, list)
+ VTAILQ_FOREACH(vp, &vclhead, list)
if (!strcmp(vp->name, name))
break;
if (vp == NULL) {
@@ -521,7 +521,7 @@
free(p);
} else {
vp->active = 2;
- TAILQ_FOREACH(vp, &vclhead, list) {
+ VTAILQ_FOREACH(vp, &vclhead, list) {
if (vp->active == 1)
vp->active = 0;
else if (vp->active == 2)
@@ -571,7 +571,7 @@
cli_out(cli, "%s", p);
free(p);
} else {
- TAILQ_FOREACH(vp, &vclhead, list) {
+ VTAILQ_FOREACH(vp, &vclhead, list) {
cli_out(cli, "%s %6s %s\n",
vp->active ? "*" : " ",
"N/A", vp->name);
Modified: branches/1.1/bin/varnishd/storage_file.c
===================================================================
--- branches/1.1/bin/varnishd/storage_file.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/storage_file.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -81,7 +81,7 @@
/*--------------------------------------------------------------------*/
-TAILQ_HEAD(smfhead, smf);
+VTAILQ_HEAD(smfhead, smf);
struct smf {
unsigned magic;
@@ -95,8 +95,8 @@
off_t offset;
unsigned char *ptr;
- TAILQ_ENTRY(smf) order;
- TAILQ_ENTRY(smf) status;
+ VTAILQ_ENTRY(smf) order;
+ VTAILQ_ENTRY(smf) status;
struct smfhead *flist;
};
@@ -252,10 +252,10 @@
sc = calloc(sizeof *sc, 1);
XXXAN(sc);
- TAILQ_INIT(&sc->order);
+ VTAILQ_INIT(&sc->order);
for (u = 0; u < NBUCKET; u++)
- TAILQ_INIT(&sc->free[u]);
- TAILQ_INIT(&sc->used);
+ VTAILQ_INIT(&sc->free[u]);
+ VTAILQ_INIT(&sc->used);
sc->pagesize = getpagesize();
parent->priv = sc;
@@ -357,7 +357,7 @@
}
sp->flist = &sc->free[b];
ns = b * sc->pagesize;
- TAILQ_FOREACH(sp2, sp->flist, status) {
+ VTAILQ_FOREACH(sp2, sp->flist, status) {
assert(sp2->size >= ns);
assert(sp2->alloc == 0);
assert(sp2->flist == sp->flist);
@@ -365,9 +365,9 @@
break;
}
if (sp2 == NULL)
- TAILQ_INSERT_TAIL(sp->flist, sp, status);
+ VTAILQ_INSERT_TAIL(sp->flist, sp, status);
else
- TAILQ_INSERT_BEFORE(sp2, sp, status);
+ VTAILQ_INSERT_BEFORE(sp2, sp, status);
}
static void
@@ -385,7 +385,7 @@
VSL_stats->n_smf_frag--;
}
assert(sp->flist == &sc->free[b]);
- TAILQ_REMOVE(sp->flist, sp, status);
+ VTAILQ_REMOVE(sp->flist, sp, status);
sp->flist = NULL;
}
@@ -404,12 +404,12 @@
if (b >= NBUCKET)
b = NBUCKET - 1;
for (sp = NULL; b < NBUCKET - 1; b++) {
- sp = TAILQ_FIRST(&sc->free[b]);
+ sp = VTAILQ_FIRST(&sc->free[b]);
if (sp != NULL)
break;
}
if (sp == NULL) {
- TAILQ_FOREACH(sp, &sc->free[NBUCKET -1], status)
+ VTAILQ_FOREACH(sp, &sc->free[NBUCKET -1], status)
if (sp->size >= bytes)
break;
}
@@ -421,7 +421,7 @@
if (sp->size == bytes) {
sp->alloc = 1;
- TAILQ_INSERT_TAIL(&sc->used, sp, status);
+ VTAILQ_INSERT_TAIL(&sc->used, sp, status);
return (sp);
}
@@ -437,8 +437,8 @@
sp2->size = bytes;
sp2->alloc = 1;
- TAILQ_INSERT_BEFORE(sp, sp2, order);
- TAILQ_INSERT_TAIL(&sc->used, sp2, status);
+ VTAILQ_INSERT_BEFORE(sp, sp2, order);
+ VTAILQ_INSERT_TAIL(&sc->used, sp2, status);
insfree(sc, sp);
return (sp2);
}
@@ -458,29 +458,29 @@
assert(sp->alloc != 0);
assert(sp->size > 0);
assert(!(sp->size % sc->pagesize));
- TAILQ_REMOVE(&sc->used, sp, status);
+ VTAILQ_REMOVE(&sc->used, sp, status);
sp->alloc = 0;
- sp2 = TAILQ_NEXT(sp, order);
+ sp2 = VTAILQ_NEXT(sp, order);
if (sp2 != NULL &&
sp2->alloc == 0 &&
(sp2->ptr == sp->ptr + sp->size) &&
(sp2->offset == sp->offset + sp->size)) {
sp->size += sp2->size;
- TAILQ_REMOVE(&sc->order, sp2, order);
+ VTAILQ_REMOVE(&sc->order, sp2, order);
remfree(sc, sp2);
free(sp2);
VSL_stats->n_smf--;
}
- sp2 = TAILQ_PREV(sp, smfhead, order);
+ sp2 = VTAILQ_PREV(sp, smfhead, order);
if (sp2 != NULL &&
sp2->alloc == 0 &&
(sp->ptr == sp2->ptr + sp2->size) &&
(sp->offset == sp2->offset + sp2->size)) {
remfree(sc, sp2);
sp2->size += sp->size;
- TAILQ_REMOVE(&sc->order, sp, order);
+ VTAILQ_REMOVE(&sc->order, sp, order);
free(sp);
VSL_stats->n_smf--;
sp = sp2;
@@ -514,8 +514,8 @@
sp->size = bytes;
sp2->ptr += bytes;
sp2->offset += bytes;
- TAILQ_INSERT_AFTER(&sc->order, sp, sp2, order);
- TAILQ_INSERT_TAIL(&sc->used, sp2, status);
+ VTAILQ_INSERT_AFTER(&sc->order, sp, sp2, order);
+ VTAILQ_INSERT_TAIL(&sc->used, sp2, status);
free_smf(sp2);
}
@@ -541,16 +541,16 @@
sp->offset = off;
sp->alloc = 1;
- TAILQ_FOREACH(sp2, &sc->order, order) {
+ VTAILQ_FOREACH(sp2, &sc->order, order) {
if (sp->ptr < sp2->ptr) {
- TAILQ_INSERT_BEFORE(sp2, sp, order);
+ VTAILQ_INSERT_BEFORE(sp2, sp, order);
break;
}
}
if (sp2 == NULL)
- TAILQ_INSERT_TAIL(&sc->order, sp, order);
+ VTAILQ_INSERT_TAIL(&sc->order, sp, order);
- TAILQ_INSERT_HEAD(&sc->used, sp, status);
+ VTAILQ_INSERT_HEAD(&sc->used, sp, status);
free_smf(sp);
}
@@ -732,17 +732,17 @@
return (0);
printf("----------------\n");
printf("Order:\n");
- TAILQ_FOREACH(s, &sc->order, order) {
+ VTAILQ_FOREACH(s, &sc->order, order) {
printf("%10p %12ju %12ju %12ju\n",
s, s->offset, s->size, s->offset + s->size);
}
printf("Used:\n");
- TAILQ_FOREACH(s, &sc->used, status) {
+ VTAILQ_FOREACH(s, &sc->used, status) {
printf("%10p %12ju %12ju %12ju\n",
s, s->offset, s->size, s->offset + s->size);
}
printf("Free:\n");
- TAILQ_FOREACH(s, &sc->free, status) {
+ VTAILQ_FOREACH(s, &sc->free, status) {
printf("%10p %12ju %12ju %12ju\n",
s, s->offset, s->size, s->offset + s->size);
}
Modified: branches/1.1/bin/varnishd/varnishd.c
===================================================================
--- branches/1.1/bin/varnishd/varnishd.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishd/varnishd.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -433,7 +433,7 @@
XXXAN(cli[0].sb);
cli[0].result = CLIS_OK;
- TAILQ_INIT(&heritage.socks);
+ VTAILQ_INIT(&heritage.socks);
mgt_vcc_init();
MCF_ParamInit(cli);
Modified: branches/1.1/bin/varnishreplay/varnishreplay.c
===================================================================
--- branches/1.1/bin/varnishreplay/varnishreplay.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishreplay/varnishreplay.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -39,7 +39,7 @@
#include
#include "libvarnish.h"
-#include "queue.h"
+#include "vqueue.h"
#include "varnishapi.h"
#include "vss.h"
@@ -60,21 +60,21 @@
enum shmlogtag tag;
size_t len;
char *ptr;
- STAILQ_ENTRY(message) list;
+ VSTAILQ_ENTRY(message) list;
};
struct mailbox {
pthread_mutex_t lock;
pthread_cond_t has_mail;
int open;
- STAILQ_HEAD(msgq_head, message) messages;
+ VSTAILQ_HEAD(msgq_head, message) messages;
};
static void
mailbox_create(struct mailbox *mbox)
{
- STAILQ_INIT(&mbox->messages);
+ VSTAILQ_INIT(&mbox->messages);
pthread_mutex_init(&mbox->lock, NULL);
pthread_cond_init(&mbox->has_mail, NULL);
mbox->open = 1;
@@ -85,8 +85,8 @@
{
struct message *msg;
- while ((msg = STAILQ_FIRST(&mbox->messages))) {
- STAILQ_REMOVE_HEAD(&mbox->messages, list);
+ while ((msg = VSTAILQ_FIRST(&mbox->messages))) {
+ VSTAILQ_REMOVE_HEAD(&mbox->messages, list);
free(msg);
}
pthread_cond_destroy(&mbox->has_mail);
@@ -98,7 +98,7 @@
{
pthread_mutex_lock(&mbox->lock);
- STAILQ_INSERT_TAIL(&mbox->messages, msg, list);
+ VSTAILQ_INSERT_TAIL(&mbox->messages, msg, list);
pthread_cond_signal(&mbox->has_mail);
pthread_mutex_unlock(&mbox->lock);
}
@@ -109,10 +109,10 @@
struct message *msg;
pthread_mutex_lock(&mbox->lock);
- while ((msg = STAILQ_FIRST(&mbox->messages)) == NULL && mbox->open)
+ while ((msg = VSTAILQ_FIRST(&mbox->messages)) == NULL && mbox->open)
pthread_cond_wait(&mbox->has_mail, &mbox->lock);
if (msg != NULL)
- STAILQ_REMOVE_HEAD(&mbox->messages, list);
+ VSTAILQ_REMOVE_HEAD(&mbox->messages, list);
pthread_mutex_unlock(&mbox->lock);
return msg;
}
Modified: branches/1.1/bin/varnishtop/varnishtop.c
===================================================================
--- branches/1.1/bin/varnishtop/varnishtop.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/bin/varnishtop/varnishtop.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -47,18 +47,18 @@
#include "libvarnish.h"
#include "shmlog.h"
-#include "queue.h"
+#include "vqueue.h"
#include "varnishapi.h"
struct top {
unsigned char rec[4 + 255];
unsigned clen;
unsigned hash;
- TAILQ_ENTRY(top) list;
+ VTAILQ_ENTRY(top) list;
double count;
};
-static TAILQ_HEAD(tophead, top) top_head = TAILQ_HEAD_INITIALIZER(top_head);
+static VTAILQ_HEAD(tophead, top) top_head = VTAILQ_HEAD_INITIALIZER(top_head);
static unsigned ntop;
@@ -86,7 +86,7 @@
u += *q;
}
- TAILQ_FOREACH(tp, &top_head, list) {
+ VTAILQ_FOREACH(tp, &top_head, list) {
if (tp->hash != u)
continue;
if (tp->rec[0] != p[0])
@@ -105,22 +105,22 @@
tp->hash = u;
tp->count = 1.0;
tp->clen = q - p;
- TAILQ_INSERT_TAIL(&top_head, tp, list);
+ VTAILQ_INSERT_TAIL(&top_head, tp, list);
}
memcpy(tp->rec, p, 4 + p[1]);
while (1) {
- tp2 = TAILQ_PREV(tp, tophead, list);
+ tp2 = VTAILQ_PREV(tp, tophead, list);
if (tp2 == NULL || tp2->count >= tp->count)
break;
- TAILQ_REMOVE(&top_head, tp2, list);
- TAILQ_INSERT_AFTER(&top_head, tp, tp2, list);
+ VTAILQ_REMOVE(&top_head, tp2, list);
+ VTAILQ_INSERT_AFTER(&top_head, tp, tp2, list);
}
while (1) {
- tp2 = TAILQ_NEXT(tp, list);
+ tp2 = VTAILQ_NEXT(tp, list);
if (tp2 == NULL || tp2->count <= tp->count)
break;
- TAILQ_REMOVE(&top_head, tp2, list);
- TAILQ_INSERT_BEFORE(tp, tp2, list);
+ VTAILQ_REMOVE(&top_head, tp2, list);
+ VTAILQ_INSERT_BEFORE(tp, tp2, list);
}
}
@@ -142,7 +142,7 @@
l = 1;
mvprintw(0, 0, "%*s", COLS - 1, VSL_Name());
mvprintw(0, 0, "list length %u", ntop);
- TAILQ_FOREACH_SAFE(tp, &top_head, list, tp2) {
+ VTAILQ_FOREACH_SAFE(tp, &top_head, list, tp2) {
if (++l < LINES) {
int len = tp->rec[1];
if (len > COLS - 20)
@@ -154,7 +154,7 @@
}
tp->count *= .999;
if (tp->count * 10 < t || l > LINES * 10) {
- TAILQ_REMOVE(&top_head, tp, list);
+ VTAILQ_REMOVE(&top_head, tp, list);
free(tp);
ntop--;
}
@@ -246,7 +246,7 @@
struct top *tp, *tp2;
int len;
- TAILQ_FOREACH_SAFE(tp, &top_head, list, tp2) {
+ VTAILQ_FOREACH_SAFE(tp, &top_head, list, tp2) {
if (tp->count <= 1.0)
break;
len = tp->rec[1];
Modified: branches/1.1/configure.ac
===================================================================
--- branches/1.1/configure.ac 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/configure.ac 2007-09-25 08:54:11 UTC (rev 2034)
@@ -50,6 +50,14 @@
LIBS="${save_LIBS}"
AC_SUBST(PTHREAD_LIBS)
+save_LIBS="${LIBS}"
+LIBS=""
+AC_CHECK_LIB(socket, socket)
+AC_CHECK_LIB(getaddrinfo, ns)
+NET_LIBS="${LIBS}"
+LIBS="${save_LIBS}"
+AC_SUBST(NET_LIBS)
+
AC_CHECK_LIBM
AC_SUBST(LIBM)
Modified: branches/1.1/include/Makefile.am
===================================================================
--- branches/1.1/include/Makefile.am 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/include/Makefile.am 2007-09-25 08:54:11 UTC (rev 2034)
@@ -25,7 +25,7 @@
libvarnish.h \
libvcl.h \
miniobj.h \
- queue.h \
+ vqueue.h \
vpf.h \
vsb.h \
vcl.h \
Deleted: branches/1.1/include/queue.h
===================================================================
--- branches/1.1/include/queue.h 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/include/queue.h 2007-09-25 08:54:11 UTC (rev 2034)
@@ -1,676 +0,0 @@
-/* $Id$ */
-/* $NetBSD: queue.h,v 1.45 2006/03/07 17:56:00 pooka Exp $ */
-
-/*
- * Copyright (c) 1991, 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.
- * 3. 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.
- *
- * @(#)queue.h 8.5 (Berkeley) 8/20/94
- */
-
-#ifndef _SYS_QUEUE_H_
-#define _SYS_QUEUE_H_
-
-/*
- * This file defines five types of data structures: singly-linked lists,
- * lists, simple queues, tail queues, and circular queues.
- *
- * A singly-linked list is headed by a single forward pointer. The
- * elements are singly linked for minimum space and pointer manipulation
- * overhead at the expense of O(n) removal for arbitrary elements. New
- * elements can be added to the list after an existing element or at the
- * head of the list. Elements being removed from the head of the list
- * should use the explicit macro for this purpose for optimum
- * efficiency. A singly-linked list may only be traversed in the forward
- * direction. Singly-linked lists are ideal for applications with large
- * datasets and few or no removals or for implementing a LIFO queue.
- *
- * A list is headed by a single forward pointer (or an array of forward
- * pointers for a hash table header). The elements are doubly linked
- * so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before
- * or after an existing element or at the head of the list. A list
- * may only be traversed in the forward direction.
- *
- * A simple queue is headed by a pair of pointers, one the head of the
- * list and the other to the tail of the list. The elements are singly
- * linked to save space, so elements can only be removed from the
- * head of the list. New elements can be added to the list after
- * an existing element, at the head of the list, or at the end of the
- * list. A simple queue may only be traversed in the forward direction.
- *
- * A tail queue is headed by a pair of pointers, one to the head of the
- * list and the other to the tail of the list. The elements are doubly
- * linked so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before or
- * after an existing element, at the head of the list, or at the end of
- * the list. A tail queue may be traversed in either direction.
- *
- * A circle queue is headed by a pair of pointers, one to the head of the
- * list and the other to the tail of the list. The elements are doubly
- * linked so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before or after
- * an existing element, at the head of the list, or at the end of the list.
- * A circle queue may be traversed in either direction, but has a more
- * complex end of list detection.
- *
- * For details on the use of these macros, see the queue(3) manual page.
- */
-
-/*
- * List definitions.
- */
-#define LIST_HEAD(name, type) \
-struct name { \
- struct type *lh_first; /* first element */ \
-}
-
-#define LIST_HEAD_INITIALIZER(head) \
- { NULL }
-
-#define LIST_ENTRY(type) \
-struct { \
- struct type *le_next; /* next element */ \
- struct type **le_prev; /* address of previous next element */ \
-}
-
-/*
- * List functions.
- */
-#if defined(_KERNEL) && defined(QUEUEDEBUG)
-#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) \
- if ((head)->lh_first && \
- (head)->lh_first->field.le_prev != &(head)->lh_first) \
- panic("LIST_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__);
-#define QUEUEDEBUG_LIST_OP(elm, field) \
- if ((elm)->field.le_next && \
- (elm)->field.le_next->field.le_prev != \
- &(elm)->field.le_next) \
- panic("LIST_* forw %p %s:%d", (elm), __FILE__, __LINE__);\
- if (*(elm)->field.le_prev != (elm)) \
- panic("LIST_* back %p %s:%d", (elm), __FILE__, __LINE__);
-#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) \
- (elm)->field.le_next = (void *)1L; \
- (elm)->field.le_prev = (void *)1L;
-#else
-#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field)
-#define QUEUEDEBUG_LIST_OP(elm, field)
-#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field)
-#endif
-
-#define LIST_INIT(head) do { \
- (head)->lh_first = NULL; \
-} while (/*CONSTCOND*/0)
-
-#define LIST_INSERT_AFTER(listelm, elm, field) do { \
- QUEUEDEBUG_LIST_OP((listelm), field) \
- if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
- (listelm)->field.le_next->field.le_prev = \
- &(elm)->field.le_next; \
- (listelm)->field.le_next = (elm); \
- (elm)->field.le_prev = &(listelm)->field.le_next; \
-} while (/*CONSTCOND*/0)
-
-#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
- QUEUEDEBUG_LIST_OP((listelm), field) \
- (elm)->field.le_prev = (listelm)->field.le_prev; \
- (elm)->field.le_next = (listelm); \
- *(listelm)->field.le_prev = (elm); \
- (listelm)->field.le_prev = &(elm)->field.le_next; \
-} while (/*CONSTCOND*/0)
-
-#define LIST_INSERT_HEAD(head, elm, field) do { \
- QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \
- if (((elm)->field.le_next = (head)->lh_first) != NULL) \
- (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
- (head)->lh_first = (elm); \
- (elm)->field.le_prev = &(head)->lh_first; \
-} while (/*CONSTCOND*/0)
-
-#define LIST_REMOVE(elm, field) do { \
- QUEUEDEBUG_LIST_OP((elm), field) \
- if ((elm)->field.le_next != NULL) \
- (elm)->field.le_next->field.le_prev = \
- (elm)->field.le_prev; \
- *(elm)->field.le_prev = (elm)->field.le_next; \
- QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \
-} while (/*CONSTCOND*/0)
-
-#define LIST_FOREACH(var, head, field) \
- for ((var) = ((head)->lh_first); \
- (var); \
- (var) = ((var)->field.le_next))
-
-/*
- * List access methods.
- */
-#define LIST_EMPTY(head) ((head)->lh_first == NULL)
-#define LIST_FIRST(head) ((head)->lh_first)
-#define LIST_NEXT(elm, field) ((elm)->field.le_next)
-
-
-/*
- * Singly-linked List definitions.
- */
-#define SLIST_HEAD(name, type) \
-struct name { \
- struct type *slh_first; /* first element */ \
-}
-
-#define SLIST_HEAD_INITIALIZER(head) \
- { NULL }
-
-#define SLIST_ENTRY(type) \
-struct { \
- struct type *sle_next; /* next element */ \
-}
-
-/*
- * Singly-linked List functions.
- */
-#define SLIST_INIT(head) do { \
- (head)->slh_first = NULL; \
-} while (/*CONSTCOND*/0)
-
-#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
- (elm)->field.sle_next = (slistelm)->field.sle_next; \
- (slistelm)->field.sle_next = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define SLIST_INSERT_HEAD(head, elm, field) do { \
- (elm)->field.sle_next = (head)->slh_first; \
- (head)->slh_first = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define SLIST_REMOVE_HEAD(head, field) do { \
- (head)->slh_first = (head)->slh_first->field.sle_next; \
-} while (/*CONSTCOND*/0)
-
-#define SLIST_REMOVE(head, elm, type, field) do { \
- if ((head)->slh_first == (elm)) { \
- SLIST_REMOVE_HEAD((head), field); \
- } \
- else { \
- struct type *curelm = (head)->slh_first; \
- while(curelm->field.sle_next != (elm)) \
- curelm = curelm->field.sle_next; \
- curelm->field.sle_next = \
- curelm->field.sle_next->field.sle_next; \
- } \
-} while (/*CONSTCOND*/0)
-
-#define SLIST_FOREACH(var, head, field) \
- for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
-
-/*
- * Singly-linked List access methods.
- */
-#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
-#define SLIST_FIRST(head) ((head)->slh_first)
-#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
-
-
-/*
- * Singly-linked Tail queue declarations.
- */
-#define STAILQ_HEAD(name, type) \
-struct name { \
- struct type *stqh_first; /* first element */ \
- struct type **stqh_last; /* addr of last next element */ \
-}
-
-#define STAILQ_HEAD_INITIALIZER(head) \
- { NULL, &(head).stqh_first }
-
-#define STAILQ_ENTRY(type) \
-struct { \
- struct type *stqe_next; /* next element */ \
-}
-
-/*
- * Singly-linked Tail queue functions.
- */
-#define STAILQ_INIT(head) do { \
- (head)->stqh_first = NULL; \
- (head)->stqh_last = &(head)->stqh_first; \
-} while (/*CONSTCOND*/0)
-
-#define STAILQ_INSERT_HEAD(head, elm, field) do { \
- if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \
- (head)->stqh_last = &(elm)->field.stqe_next; \
- (head)->stqh_first = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define STAILQ_INSERT_TAIL(head, elm, field) do { \
- (elm)->field.stqe_next = NULL; \
- *(head)->stqh_last = (elm); \
- (head)->stqh_last = &(elm)->field.stqe_next; \
-} while (/*CONSTCOND*/0)
-
-#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
- if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
- (head)->stqh_last = &(elm)->field.stqe_next; \
- (listelm)->field.stqe_next = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define STAILQ_REMOVE_HEAD(head, field) do { \
- if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
- (head)->stqh_last = &(head)->stqh_first; \
-} while (/*CONSTCOND*/0)
-
-#define STAILQ_REMOVE(head, elm, type, field) do { \
- if ((head)->stqh_first == (elm)) { \
- STAILQ_REMOVE_HEAD((head), field); \
- } else { \
- struct type *curelm = (head)->stqh_first; \
- while (curelm->field.stqe_next != (elm)) \
- curelm = curelm->field.stqe_next; \
- if ((curelm->field.stqe_next = \
- curelm->field.stqe_next->field.stqe_next) == NULL) \
- (head)->stqh_last = &(curelm)->field.stqe_next; \
- } \
-} while (/*CONSTCOND*/0)
-
-#define STAILQ_FOREACH(var, head, field) \
- for ((var) = ((head)->stqh_first); \
- (var); \
- (var) = ((var)->field.stqe_next))
-
-/*
- * Singly-linked Tail queue access methods.
- */
-#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
-#define STAILQ_FIRST(head) ((head)->stqh_first)
-#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
-
-
-/*
- * Simple queue definitions.
- */
-#define SIMPLEQ_HEAD(name, type) \
-struct name { \
- struct type *sqh_first; /* first element */ \
- struct type **sqh_last; /* addr of last next element */ \
-}
-
-#define SIMPLEQ_HEAD_INITIALIZER(head) \
- { NULL, &(head).sqh_first }
-
-#define SIMPLEQ_ENTRY(type) \
-struct { \
- struct type *sqe_next; /* next element */ \
-}
-
-/*
- * Simple queue functions.
- */
-#define SIMPLEQ_INIT(head) do { \
- (head)->sqh_first = NULL; \
- (head)->sqh_last = &(head)->sqh_first; \
-} while (/*CONSTCOND*/0)
-
-#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
- if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
- (head)->sqh_last = &(elm)->field.sqe_next; \
- (head)->sqh_first = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
- (elm)->field.sqe_next = NULL; \
- *(head)->sqh_last = (elm); \
- (head)->sqh_last = &(elm)->field.sqe_next; \
-} while (/*CONSTCOND*/0)
-
-#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
- if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
- (head)->sqh_last = &(elm)->field.sqe_next; \
- (listelm)->field.sqe_next = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
- if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
- (head)->sqh_last = &(head)->sqh_first; \
-} while (/*CONSTCOND*/0)
-
-#define SIMPLEQ_REMOVE(head, elm, type, field) do { \
- if ((head)->sqh_first == (elm)) { \
- SIMPLEQ_REMOVE_HEAD((head), field); \
- } else { \
- struct type *curelm = (head)->sqh_first; \
- while (curelm->field.sqe_next != (elm)) \
- curelm = curelm->field.sqe_next; \
- if ((curelm->field.sqe_next = \
- curelm->field.sqe_next->field.sqe_next) == NULL) \
- (head)->sqh_last = &(curelm)->field.sqe_next; \
- } \
-} while (/*CONSTCOND*/0)
-
-#define SIMPLEQ_FOREACH(var, head, field) \
- for ((var) = ((head)->sqh_first); \
- (var); \
- (var) = ((var)->field.sqe_next))
-
-/*
- * Simple queue access methods.
- */
-#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL)
-#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
-#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
-
-
-/*
- * Tail queue definitions.
- */
-#define _TAILQ_HEAD(name, type, qual) \
-struct name { \
- qual type *tqh_first; /* first element */ \
- qual type *qual *tqh_last; /* addr of last next element */ \
-}
-#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,)
-
-#define TAILQ_HEAD_INITIALIZER(head) \
- { NULL, &(head).tqh_first }
-
-#define _TAILQ_ENTRY(type, qual) \
-struct { \
- qual type *tqe_next; /* next element */ \
- qual type *qual *tqe_prev; /* address of previous next element */\
-}
-#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,)
-
-/*
- * Tail queue functions.
- */
-#if defined(_KERNEL) && defined(QUEUEDEBUG)
-#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) \
- if ((head)->tqh_first && \
- (head)->tqh_first->field.tqe_prev != &(head)->tqh_first) \
- panic("TAILQ_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__);
-#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) \
- if (*(head)->tqh_last != NULL) \
- panic("TAILQ_INSERT_TAIL %p %s:%d", (head), __FILE__, __LINE__);
-#define QUEUEDEBUG_TAILQ_OP(elm, field) \
- if ((elm)->field.tqe_next && \
- (elm)->field.tqe_next->field.tqe_prev != \
- &(elm)->field.tqe_next) \
- panic("TAILQ_* forw %p %s:%d", (elm), __FILE__, __LINE__);\
- if (*(elm)->field.tqe_prev != (elm)) \
- panic("TAILQ_* back %p %s:%d", (elm), __FILE__, __LINE__);
-#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) \
- if ((elm)->field.tqe_next == NULL && \
- (head)->tqh_last != &(elm)->field.tqe_next) \
- panic("TAILQ_PREREMOVE head %p elm %p %s:%d", \
- (head), (elm), __FILE__, __LINE__);
-#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \
- (elm)->field.tqe_next = (void *)1L; \
- (elm)->field.tqe_prev = (void *)1L;
-#else
-#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field)
-#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field)
-#define QUEUEDEBUG_TAILQ_OP(elm, field)
-#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field)
-#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field)
-#endif
-
-#define TAILQ_INIT(head) do { \
- (head)->tqh_first = NULL; \
- (head)->tqh_last = &(head)->tqh_first; \
-} while (/*CONSTCOND*/0)
-
-#define TAILQ_INSERT_HEAD(head, elm, field) do { \
- QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \
- if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
- (head)->tqh_first->field.tqe_prev = \
- &(elm)->field.tqe_next; \
- else \
- (head)->tqh_last = &(elm)->field.tqe_next; \
- (head)->tqh_first = (elm); \
- (elm)->field.tqe_prev = &(head)->tqh_first; \
-} while (/*CONSTCOND*/0)
-
-#define TAILQ_INSERT_TAIL(head, elm, field) do { \
- QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \
- (elm)->field.tqe_next = NULL; \
- (elm)->field.tqe_prev = (head)->tqh_last; \
- *(head)->tqh_last = (elm); \
- (head)->tqh_last = &(elm)->field.tqe_next; \
-} while (/*CONSTCOND*/0)
-
-#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
- QUEUEDEBUG_TAILQ_OP((listelm), field) \
- if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
- (elm)->field.tqe_next->field.tqe_prev = \
- &(elm)->field.tqe_next; \
- else \
- (head)->tqh_last = &(elm)->field.tqe_next; \
- (listelm)->field.tqe_next = (elm); \
- (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
-} while (/*CONSTCOND*/0)
-
-#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
- QUEUEDEBUG_TAILQ_OP((listelm), field) \
- (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
- (elm)->field.tqe_next = (listelm); \
- *(listelm)->field.tqe_prev = (elm); \
- (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
-} while (/*CONSTCOND*/0)
-
-#define TAILQ_REMOVE(head, elm, field) do { \
- QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \
- QUEUEDEBUG_TAILQ_OP((elm), field) \
- if (((elm)->field.tqe_next) != NULL) \
- (elm)->field.tqe_next->field.tqe_prev = \
- (elm)->field.tqe_prev; \
- else \
- (head)->tqh_last = (elm)->field.tqe_prev; \
- *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
- QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \
-} while (/*CONSTCOND*/0)
-
-#define TAILQ_FOREACH(var, head, field) \
- for ((var) = ((head)->tqh_first); \
- (var); \
- (var) = ((var)->field.tqe_next))
-
-#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = TAILQ_FIRST((head)); \
- (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
- (var) = (tvar))
-
-#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
- for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
- (var); \
- (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
-
-/*
- * Tail queue access methods.
- */
-#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
-#define TAILQ_FIRST(head) ((head)->tqh_first)
-#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
-
-#define TAILQ_LAST(head, headname) \
- (*(((struct headname *)((head)->tqh_last))->tqh_last))
-#define TAILQ_PREV(elm, headname, field) \
- (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
-
-
-/*
- * Circular queue definitions.
- */
-#if defined(_KERNEL) && defined(QUEUEDEBUG)
-#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) \
- if ((head)->cqh_first != (void *)(head) && \
- (head)->cqh_first->field.cqe_prev != (void *)(head)) \
- panic("CIRCLEQ head forw %p %s:%d", (head), \
- __FILE__, __LINE__); \
- if ((head)->cqh_last != (void *)(head) && \
- (head)->cqh_last->field.cqe_next != (void *)(head)) \
- panic("CIRCLEQ head back %p %s:%d", (head), \
- __FILE__, __LINE__);
-#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) \
- if ((elm)->field.cqe_next == (void *)(head)) { \
- if ((head)->cqh_last != (elm)) \
- panic("CIRCLEQ elm last %p %s:%d", (elm), \
- __FILE__, __LINE__); \
- } else { \
- if ((elm)->field.cqe_next->field.cqe_prev != (elm)) \
- panic("CIRCLEQ elm forw %p %s:%d", (elm), \
- __FILE__, __LINE__); \
- } \
- if ((elm)->field.cqe_prev == (void *)(head)) { \
- if ((head)->cqh_first != (elm)) \
- panic("CIRCLEQ elm first %p %s:%d", (elm), \
- __FILE__, __LINE__); \
- } else { \
- if ((elm)->field.cqe_prev->field.cqe_next != (elm)) \
- panic("CIRCLEQ elm prev %p %s:%d", (elm), \
- __FILE__, __LINE__); \
- }
-#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) \
- (elm)->field.cqe_next = (void *)1L; \
- (elm)->field.cqe_prev = (void *)1L;
-#else
-#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field)
-#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field)
-#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field)
-#endif
-
-#define CIRCLEQ_HEAD(name, type) \
-struct name { \
- struct type *cqh_first; /* first element */ \
- struct type *cqh_last; /* last element */ \
-}
-
-#define CIRCLEQ_HEAD_INITIALIZER(head) \
- { (void *)&head, (void *)&head }
-
-#define CIRCLEQ_ENTRY(type) \
-struct { \
- struct type *cqe_next; /* next element */ \
- struct type *cqe_prev; /* previous element */ \
-}
-
-/*
- * Circular queue functions.
- */
-#define CIRCLEQ_INIT(head) do { \
- (head)->cqh_first = (void *)(head); \
- (head)->cqh_last = (void *)(head); \
-} while (/*CONSTCOND*/0)
-
-#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
- QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
- QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \
- (elm)->field.cqe_next = (listelm)->field.cqe_next; \
- (elm)->field.cqe_prev = (listelm); \
- if ((listelm)->field.cqe_next == (void *)(head)) \
- (head)->cqh_last = (elm); \
- else \
- (listelm)->field.cqe_next->field.cqe_prev = (elm); \
- (listelm)->field.cqe_next = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
- QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
- QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \
- (elm)->field.cqe_next = (listelm); \
- (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
- if ((listelm)->field.cqe_prev == (void *)(head)) \
- (head)->cqh_first = (elm); \
- else \
- (listelm)->field.cqe_prev->field.cqe_next = (elm); \
- (listelm)->field.cqe_prev = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
- QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
- (elm)->field.cqe_next = (head)->cqh_first; \
- (elm)->field.cqe_prev = (void *)(head); \
- if ((head)->cqh_last == (void *)(head)) \
- (head)->cqh_last = (elm); \
- else \
- (head)->cqh_first->field.cqe_prev = (elm); \
- (head)->cqh_first = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
- QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
- (elm)->field.cqe_next = (void *)(head); \
- (elm)->field.cqe_prev = (head)->cqh_last; \
- if ((head)->cqh_first == (void *)(head)) \
- (head)->cqh_first = (elm); \
- else \
- (head)->cqh_last->field.cqe_next = (elm); \
- (head)->cqh_last = (elm); \
-} while (/*CONSTCOND*/0)
-
-#define CIRCLEQ_REMOVE(head, elm, field) do { \
- QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \
- QUEUEDEBUG_CIRCLEQ_ELM((head), (elm), field) \
- if ((elm)->field.cqe_next == (void *)(head)) \
- (head)->cqh_last = (elm)->field.cqe_prev; \
- else \
- (elm)->field.cqe_next->field.cqe_prev = \
- (elm)->field.cqe_prev; \
- if ((elm)->field.cqe_prev == (void *)(head)) \
- (head)->cqh_first = (elm)->field.cqe_next; \
- else \
- (elm)->field.cqe_prev->field.cqe_next = \
- (elm)->field.cqe_next; \
- QUEUEDEBUG_CIRCLEQ_POSTREMOVE((elm), field) \
-} while (/*CONSTCOND*/0)
-
-#define CIRCLEQ_FOREACH(var, head, field) \
- for ((var) = ((head)->cqh_first); \
- (var) != (const void *)(head); \
- (var) = ((var)->field.cqe_next))
-
-#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
- for ((var) = ((head)->cqh_last); \
- (var) != (const void *)(head); \
- (var) = ((var)->field.cqe_prev))
-
-/*
- * Circular queue access methods.
- */
-#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head))
-#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
-#define CIRCLEQ_LAST(head) ((head)->cqh_last)
-#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
-#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
-
-#define CIRCLEQ_LOOP_NEXT(head, elm, field) \
- (((elm)->field.cqe_next == (void *)(head)) \
- ? ((head)->cqh_first) \
- : (elm->field.cqe_next))
-#define CIRCLEQ_LOOP_PREV(head, elm, field) \
- (((elm)->field.cqe_prev == (void *)(head)) \
- ? ((head)->cqh_last) \
- : (elm->field.cqe_prev))
-
-#endif /* !_SYS_QUEUE_H_ */
Copied: branches/1.1/include/vqueue.h (from rev 2033, trunk/varnish-cache/include/vqueue.h)
===================================================================
--- branches/1.1/include/vqueue.h (rev 0)
+++ branches/1.1/include/vqueue.h 2007-09-25 08:54:11 UTC (rev 2034)
@@ -0,0 +1,495 @@
+/*-
+ * Copyright (c) 1991, 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.
+ * 3. 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.
+ *
+ * @(#)queue.h 8.5 (Berkeley) 8/20/94
+ * $FreeBSD: src/sys/sys/queue.h,v 1.68 2006/10/24 11:20:29 ru Exp $
+ * $Id$
+ */
+
+#ifndef VARNISH_QUEUE_H
+#define VARNISH_QUEUE_H
+
+/*
+ * This file defines four types of data structures: singly-linked lists,
+ * singly-linked tail queues, lists and tail queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The elements
+ * are singly linked for minimum space and pointer manipulation overhead at
+ * the expense of O(n) removal for arbitrary elements. New elements can be
+ * added to the list after an existing element or at the head of the list.
+ * Elements being removed from the head of the list should use the explicit
+ * macro for this purpose for optimum efficiency. A singly-linked list may
+ * only be traversed in the forward direction. Singly-linked lists are ideal
+ * for applications with large datasets and few or no removals or for
+ * implementing a LIFO queue.
+ *
+ * A singly-linked tail queue is headed by a pair of pointers, one to the
+ * head of the list and the other to the tail of the list. The elements are
+ * singly linked for minimum space and pointer manipulation overhead at the
+ * expense of O(n) removal for arbitrary elements. New elements can be added
+ * to the list after an existing element, at the head of the list, or at the
+ * end of the list. Elements being removed from the head of the tail queue
+ * should use the explicit macro for this purpose for optimum efficiency.
+ * A singly-linked tail queue may only be traversed in the forward direction.
+ * Singly-linked tail queues are ideal for applications with large datasets
+ * and few or no removals or for implementing a FIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ *
+ *
+ * VSLIST VLIST VSTAILQ VTAILQ
+ * _HEAD + + + +
+ * _HEAD_INITIALIZER + + + +
+ * _ENTRY + + + +
+ * _INIT + + + +
+ * _EMPTY + + + +
+ * _FIRST + + + +
+ * _NEXT + + + +
+ * _PREV - - - +
+ * _LAST - - + +
+ * _FOREACH + + + +
+ * _FOREACH_SAFE + + + +
+ * _FOREACH_REVERSE - - - +
+ * _FOREACH_REVERSE_SAFE - - - +
+ * _INSERT_HEAD + + + +
+ * _INSERT_BEFORE - + - +
+ * _INSERT_AFTER + + + +
+ * _INSERT_TAIL - - + +
+ * _CONCAT - - + +
+ * _REMOVE_HEAD + - + -
+ * _REMOVE + + + +
+ *
+ */
+
+/*
+ * Singly-linked List declarations.
+ */
+#define VSLIST_HEAD(name, type) \
+struct name { \
+ struct type *vslh_first; /* first element */ \
+}
+
+#define VSLIST_HEAD_INITIALIZER(head) \
+ { NULL }
+
+#define VSLIST_ENTRY(type) \
+struct { \
+ struct type *vsle_next; /* next element */ \
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define VSLIST_EMPTY(head) ((head)->vslh_first == NULL)
+
+#define VSLIST_FIRST(head) ((head)->vslh_first)
+
+#define VSLIST_FOREACH(var, head, field) \
+ for ((var) = VSLIST_FIRST((head)); \
+ (var); \
+ (var) = VSLIST_NEXT((var), field))
+
+#define VSLIST_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = VSLIST_FIRST((head)); \
+ (var) && ((tvar) = VSLIST_NEXT((var), field), 1); \
+ (var) = (tvar))
+
+#define VSLIST_FOREACH_PREVPTR(var, varp, head, field) \
+ for ((varp) = &VSLIST_FIRST((head)); \
+ ((var) = *(varp)) != NULL; \
+ (varp) = &VSLIST_NEXT((var), field))
+
+#define VSLIST_INIT(head) do { \
+ VSLIST_FIRST((head)) = NULL; \
+} while (0)
+
+#define VSLIST_INSERT_AFTER(slistelm, elm, field) do { \
+ VSLIST_NEXT((elm), field) = VSLIST_NEXT((slistelm), field); \
+ VSLIST_NEXT((slistelm), field) = (elm); \
+} while (0)
+
+#define VSLIST_INSERT_HEAD(head, elm, field) do { \
+ VSLIST_NEXT((elm), field) = VSLIST_FIRST((head)); \
+ VSLIST_FIRST((head)) = (elm); \
+} while (0)
+
+#define VSLIST_NEXT(elm, field) ((elm)->field.vsle_next)
+
+#define VSLIST_REMOVE(head, elm, type, field) do { \
+ if (VSLIST_FIRST((head)) == (elm)) { \
+ VSLIST_REMOVE_HEAD((head), field); \
+ } \
+ else { \
+ struct type *curelm = VSLIST_FIRST((head)); \
+ while (VSLIST_NEXT(curelm, field) != (elm)) \
+ curelm = VSLIST_NEXT(curelm, field); \
+ VSLIST_NEXT(curelm, field) = \
+ VSLIST_NEXT(VSLIST_NEXT(curelm, field), field); \
+ } \
+} while (0)
+
+#define VSLIST_REMOVE_HEAD(head, field) do { \
+ VSLIST_FIRST((head)) = VSLIST_NEXT(VSLIST_FIRST((head)), field);\
+} while (0)
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define VSTAILQ_HEAD(name, type) \
+struct name { \
+ struct type *vstqh_first;/* first element */ \
+ struct type **vstqh_last;/* addr of last next element */ \
+}
+
+#define VSTAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).vstqh_first }
+
+#define VSTAILQ_ENTRY(type) \
+struct { \
+ struct type *vstqe_next; /* next element */ \
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define VSTAILQ_CONCAT(head1, head2) do { \
+ if (!VSTAILQ_EMPTY((head2))) { \
+ *(head1)->vstqh_last = (head2)->vstqh_first; \
+ (head1)->vstqh_last = (head2)->vstqh_last; \
+ VSTAILQ_INIT((head2)); \
+ } \
+} while (0)
+
+#define VSTAILQ_EMPTY(head) ((head)->vstqh_first == NULL)
+
+#define VSTAILQ_FIRST(head) ((head)->vstqh_first)
+
+#define VSTAILQ_FOREACH(var, head, field) \
+ for((var) = VSTAILQ_FIRST((head)); \
+ (var); \
+ (var) = VSTAILQ_NEXT((var), field))
+
+
+#define VSTAILQ_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = VSTAILQ_FIRST((head)); \
+ (var) && ((tvar) = VSTAILQ_NEXT((var), field), 1); \
+ (var) = (tvar))
+
+#define VSTAILQ_INIT(head) do { \
+ VSTAILQ_FIRST((head)) = NULL; \
+ (head)->vstqh_last = &VSTAILQ_FIRST((head)); \
+} while (0)
+
+#define VSTAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
+ if ((VSTAILQ_NEXT((elm), field) = VSTAILQ_NEXT((tqelm), field)) == NULL)\
+ (head)->vstqh_last = &VSTAILQ_NEXT((elm), field); \
+ VSTAILQ_NEXT((tqelm), field) = (elm); \
+} while (0)
+
+#define VSTAILQ_INSERT_HEAD(head, elm, field) do { \
+ if ((VSTAILQ_NEXT((elm), field) = VSTAILQ_FIRST((head))) == NULL)\
+ (head)->vstqh_last = &VSTAILQ_NEXT((elm), field); \
+ VSTAILQ_FIRST((head)) = (elm); \
+} while (0)
+
+#define VSTAILQ_INSERT_TAIL(head, elm, field) do { \
+ VSTAILQ_NEXT((elm), field) = NULL; \
+ *(head)->vstqh_last = (elm); \
+ (head)->vstqh_last = &VSTAILQ_NEXT((elm), field); \
+} while (0)
+
+#define VSTAILQ_LAST(head, type, field) \
+ (VSTAILQ_EMPTY((head)) ? \
+ NULL : \
+ ((struct type *)(void *) \
+ ((char *)((head)->vstqh_last) - __offsetof(struct type, field))))
+
+#define VSTAILQ_NEXT(elm, field) ((elm)->field.vstqe_next)
+
+#define VSTAILQ_REMOVE(head, elm, type, field) do { \
+ if (VSTAILQ_FIRST((head)) == (elm)) { \
+ VSTAILQ_REMOVE_HEAD((head), field); \
+ } \
+ else { \
+ struct type *curelm = VSTAILQ_FIRST((head)); \
+ while (VSTAILQ_NEXT(curelm, field) != (elm)) \
+ curelm = VSTAILQ_NEXT(curelm, field); \
+ if ((VSTAILQ_NEXT(curelm, field) = \
+ VSTAILQ_NEXT(VSTAILQ_NEXT(curelm, field), field)) == NULL)\
+ (head)->vstqh_last = &VSTAILQ_NEXT((curelm), field);\
+ } \
+} while (0)
+
+#define VSTAILQ_REMOVE_HEAD(head, field) do { \
+ if ((VSTAILQ_FIRST((head)) = \
+ VSTAILQ_NEXT(VSTAILQ_FIRST((head)), field)) == NULL) \
+ (head)->vstqh_last = &VSTAILQ_FIRST((head)); \
+} while (0)
+
+/*
+ * List declarations.
+ */
+#define VLIST_HEAD(name, type) \
+struct name { \
+ struct type *vlh_first; /* first element */ \
+}
+
+#define VLIST_HEAD_INITIALIZER(head) \
+ { NULL }
+
+#define VLIST_ENTRY(type) \
+struct { \
+ struct type *vle_next; /* next element */ \
+ struct type **vle_prev; /* address of previous next element */ \
+}
+
+/*
+ * List functions.
+ */
+#define VLIST_EMPTY(head) ((head)->vlh_first == NULL)
+
+#define VLIST_FIRST(head) ((head)->vlh_first)
+
+#define VLIST_FOREACH(var, head, field) \
+ for ((var) = VLIST_FIRST((head)); \
+ (var); \
+ (var) = VLIST_NEXT((var), field))
+
+#define VLIST_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = VLIST_FIRST((head)); \
+ (var) && ((tvar) = VLIST_NEXT((var), field), 1); \
+ (var) = (tvar))
+
+#define VLIST_INIT(head) do { \
+ VLIST_FIRST((head)) = NULL; \
+} while (0)
+
+#define VLIST_INSERT_AFTER(listelm, elm, field) do { \
+ if ((VLIST_NEXT((elm), field) = VLIST_NEXT((listelm), field)) != NULL)\
+ VLIST_NEXT((listelm), field)->field.vle_prev = \
+ &VLIST_NEXT((elm), field); \
+ VLIST_NEXT((listelm), field) = (elm); \
+ (elm)->field.vle_prev = &VLIST_NEXT((listelm), field); \
+} while (0)
+
+#define VLIST_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.vle_prev = (listelm)->field.vle_prev; \
+ VLIST_NEXT((elm), field) = (listelm); \
+ *(listelm)->field.vle_prev = (elm); \
+ (listelm)->field.vle_prev = &VLIST_NEXT((elm), field); \
+} while (0)
+
+#define VLIST_INSERT_HEAD(head, elm, field) do { \
+ if ((VLIST_NEXT((elm), field) = VLIST_FIRST((head))) != NULL) \
+ VLIST_FIRST((head))->field.vle_prev = &VLIST_NEXT((elm), field);\
+ VLIST_FIRST((head)) = (elm); \
+ (elm)->field.vle_prev = &VLIST_FIRST((head)); \
+} while (0)
+
+#define VLIST_NEXT(elm, field) ((elm)->field.vle_next)
+
+#define VLIST_REMOVE(elm, field) do { \
+ if (VLIST_NEXT((elm), field) != NULL) \
+ VLIST_NEXT((elm), field)->field.vle_prev = \
+ (elm)->field.vle_prev; \
+ *(elm)->field.vle_prev = VLIST_NEXT((elm), field); \
+} while (0)
+
+/*
+ * Tail queue declarations.
+ */
+#define VTAILQ_HEAD(name, type) \
+struct name { \
+ struct type *vtqh_first; /* first element */ \
+ struct type **vtqh_last; /* addr of last next element */ \
+}
+
+#define VTAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).vtqh_first }
+
+#define VTAILQ_ENTRY(type) \
+struct { \
+ struct type *vtqe_next; /* next element */ \
+ struct type **vtqe_prev; /* address of previous next element */\
+}
+
+/*
+ * Tail queue functions.
+ */
+#define VTAILQ_CONCAT(head1, head2, field) do { \
+ if (!VTAILQ_EMPTY(head2)) { \
+ *(head1)->vtqh_last = (head2)->vtqh_first; \
+ (head2)->vtqh_first->field.vtqe_prev = (head1)->vtqh_last;\
+ (head1)->vtqh_last = (head2)->vtqh_last; \
+ VTAILQ_INIT((head2)); \
+ } \
+} while (0)
+
+#define VTAILQ_EMPTY(head) ((head)->vtqh_first == NULL)
+
+#define VTAILQ_FIRST(head) ((head)->vtqh_first)
+
+#define VTAILQ_FOREACH(var, head, field) \
+ for ((var) = VTAILQ_FIRST((head)); \
+ (var); \
+ (var) = VTAILQ_NEXT((var), field))
+
+#define VTAILQ_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = VTAILQ_FIRST((head)); \
+ (var) && ((tvar) = VTAILQ_NEXT((var), field), 1); \
+ (var) = (tvar))
+
+#define VTAILQ_FOREACH_REVERSE(var, head, headname, field) \
+ for ((var) = VTAILQ_LAST((head), headname); \
+ (var); \
+ (var) = VTAILQ_PREV((var), headname, field))
+
+#define VTAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
+ for ((var) = VTAILQ_LAST((head), headname); \
+ (var) && ((tvar) = VTAILQ_PREV((var), headname, field), 1); \
+ (var) = (tvar))
+
+#define VTAILQ_INIT(head) do { \
+ VTAILQ_FIRST((head)) = NULL; \
+ (head)->vtqh_last = &VTAILQ_FIRST((head)); \
+} while (0)
+
+#define VTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if ((VTAILQ_NEXT((elm), field) = VTAILQ_NEXT((listelm), field)) != NULL)\
+ VTAILQ_NEXT((elm), field)->field.vtqe_prev = \
+ &VTAILQ_NEXT((elm), field); \
+ else { \
+ (head)->vtqh_last = &VTAILQ_NEXT((elm), field); \
+ } \
+ VTAILQ_NEXT((listelm), field) = (elm); \
+ (elm)->field.vtqe_prev = &VTAILQ_NEXT((listelm), field); \
+} while (0)
+
+#define VTAILQ_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.vtqe_prev = (listelm)->field.vtqe_prev; \
+ VTAILQ_NEXT((elm), field) = (listelm); \
+ *(listelm)->field.vtqe_prev = (elm); \
+ (listelm)->field.vtqe_prev = &VTAILQ_NEXT((elm), field); \
+} while (0)
+
+#define VTAILQ_INSERT_HEAD(head, elm, field) do { \
+ if ((VTAILQ_NEXT((elm), field) = VTAILQ_FIRST((head))) != NULL) \
+ VTAILQ_FIRST((head))->field.vtqe_prev = \
+ &VTAILQ_NEXT((elm), field); \
+ else \
+ (head)->vtqh_last = &VTAILQ_NEXT((elm), field); \
+ VTAILQ_FIRST((head)) = (elm); \
+ (elm)->field.vtqe_prev = &VTAILQ_FIRST((head)); \
+} while (0)
+
+#define VTAILQ_INSERT_TAIL(head, elm, field) do { \
+ VTAILQ_NEXT((elm), field) = NULL; \
+ (elm)->field.vtqe_prev = (head)->vtqh_last; \
+ *(head)->vtqh_last = (elm); \
+ (head)->vtqh_last = &VTAILQ_NEXT((elm), field); \
+} while (0)
+
+#define VTAILQ_LAST(head, headname) \
+ (*(((struct headname *)((head)->vtqh_last))->vtqh_last))
+
+#define VTAILQ_NEXT(elm, field) ((elm)->field.vtqe_next)
+
+#define VTAILQ_PREV(elm, headname, field) \
+ (*(((struct headname *)((elm)->field.vtqe_prev))->vtqh_last))
+
+#define VTAILQ_REMOVE(head, elm, field) do { \
+ if ((VTAILQ_NEXT((elm), field)) != NULL) \
+ VTAILQ_NEXT((elm), field)->field.vtqe_prev = \
+ (elm)->field.vtqe_prev; \
+ else { \
+ (head)->vtqh_last = (elm)->field.vtqe_prev; \
+ } \
+ *(elm)->field.vtqe_prev = VTAILQ_NEXT((elm), field); \
+} while (0)
+
+
+#ifdef _KERNEL
+
+/*
+ * XXX insque() and remque() are an old way of handling certain queues.
+ * They bogusly assumes that all queue heads look alike.
+ */
+
+struct quehead {
+ struct quehead *qh_link;
+ struct quehead *qh_rlink;
+};
+
+#ifdef __CC_SUPPORTS___INLINE
+
+static __inline void
+insque(void *a, void *b)
+{
+ struct quehead *element = (struct quehead *)a,
+ *head = (struct quehead *)b;
+
+ element->qh_link = head->qh_link;
+ element->qh_rlink = head;
+ head->qh_link = element;
+ element->qh_link->qh_rlink = element;
+}
+
+static __inline void
+remque(void *a)
+{
+ struct quehead *element = (struct quehead *)a;
+
+ element->qh_link->qh_rlink = element->qh_rlink;
+ element->qh_rlink->qh_link = element->qh_link;
+ element->qh_rlink = 0;
+}
+
+#else /* !__CC_SUPPORTS___INLINE */
+
+void insque(void *a, void *b);
+void remque(void *a);
+
+#endif /* __CC_SUPPORTS___INLINE */
+
+#endif /* _KERNEL */
+
+#endif /* !VARNISH_QUEUE_H */
Modified: branches/1.1/lib/libvcl/vcc_compile.c
===================================================================
--- branches/1.1/lib/libvcl/vcc_compile.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/lib/libvcl/vcc_compile.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -72,7 +72,7 @@
#include
#include "vsb.h"
-#include "queue.h"
+#include "vqueue.h"
#include "vcc_priv.h"
#include "vcc_compile.h"
@@ -103,7 +103,7 @@
mb = calloc(sizeof *mb, 1);
assert(mb != NULL);
mb->ptr = p;
- TAILQ_INSERT_TAIL(&tl->membits, mb, list);
+ VTAILQ_INSERT_TAIL(&tl->membits, mb, list);
}
@@ -259,7 +259,7 @@
pos = 0;
sp = 0;
p = NULL;
- TAILQ_FOREACH(t, &tl->tokens, list) {
+ VTAILQ_FOREACH(t, &tl->tokens, list) {
if (t->cnt == 0)
continue;
assert(t->src != NULL);
@@ -320,7 +320,7 @@
struct source *sp;
Fc(tl, 0, "\nconst char *srcname[%u] = {\n", tl->nsources);
- TAILQ_FOREACH(sp, &tl->sources, list) {
+ VTAILQ_FOREACH(sp, &tl->sources, list) {
Fc(tl, 0, "\t");
EncString(tl->fc, sp->name, NULL, 0);
Fc(tl, 0, ",\n");
@@ -328,7 +328,7 @@
Fc(tl, 0, "};\n");
Fc(tl, 0, "\nconst char *srcbody[%u] = {\n", tl->nsources);
- TAILQ_FOREACH(sp, &tl->sources, list) {
+ VTAILQ_FOREACH(sp, &tl->sources, list) {
Fc(tl, 0, " /* ");
EncString(tl->fc, sp->name, NULL, 0);
Fc(tl, 0, "*/\n");
@@ -423,11 +423,11 @@
struct token *t, *t1, *t2;
struct source *sp;
- TAILQ_FOREACH(t, &tl->tokens, list) {
+ VTAILQ_FOREACH(t, &tl->tokens, list) {
if (t->tok != T_INCLUDE)
continue;
- t1 = TAILQ_NEXT(t, list);
+ t1 = VTAILQ_NEXT(t, list);
assert(t1 != NULL); /* There's always an EOI */
if (t1->tok != CSTR) {
vsb_printf(tl->sb,
@@ -435,7 +435,7 @@
vcc_ErrWhere(tl, t1);
return;
}
- t2 = TAILQ_NEXT(t1, list);
+ t2 = VTAILQ_NEXT(t1, list);
assert(t2 != NULL); /* There's always an EOI */
if (t2->tok != ';') {
vsb_printf(tl->sb,
@@ -450,14 +450,14 @@
vcc_ErrWhere(tl, t1);
return;
}
- TAILQ_INSERT_TAIL(&tl->sources, sp, list);
+ VTAILQ_INSERT_TAIL(&tl->sources, sp, list);
sp->idx = tl->nsources++;
tl->t = t2;
vcc_Lexer(tl, sp);
- TAILQ_REMOVE(&tl->tokens, t, list);
- TAILQ_REMOVE(&tl->tokens, t1, list);
- TAILQ_REMOVE(&tl->tokens, t2, list);
+ VTAILQ_REMOVE(&tl->tokens, t, list);
+ VTAILQ_REMOVE(&tl->tokens, t1, list);
+ VTAILQ_REMOVE(&tl->tokens, t2, list);
if (!tl->err)
vcc_resolve_includes(tl);
return;
@@ -474,11 +474,11 @@
tl = calloc(sizeof *tl, 1);
assert(tl != NULL);
- TAILQ_INIT(&tl->membits);
- TAILQ_INIT(&tl->tokens);
- TAILQ_INIT(&tl->refs);
- TAILQ_INIT(&tl->procs);
- TAILQ_INIT(&tl->sources);
+ VTAILQ_INIT(&tl->membits);
+ VTAILQ_INIT(&tl->tokens);
+ VTAILQ_INIT(&tl->refs);
+ VTAILQ_INIT(&tl->procs);
+ VTAILQ_INIT(&tl->sources);
tl->nsources = 0;
@@ -515,15 +515,15 @@
struct source *sp;
int i;
- while (!TAILQ_EMPTY(&tl->membits)) {
- mb = TAILQ_FIRST(&tl->membits);
- TAILQ_REMOVE(&tl->membits, mb, list);
+ while (!VTAILQ_EMPTY(&tl->membits)) {
+ mb = VTAILQ_FIRST(&tl->membits);
+ VTAILQ_REMOVE(&tl->membits, mb, list);
free(mb->ptr);
free(mb);
}
- while (!TAILQ_EMPTY(&tl->sources)) {
- sp = TAILQ_FIRST(&tl->sources);
- TAILQ_REMOVE(&tl->sources, sp, list);
+ while (!VTAILQ_EMPTY(&tl->sources)) {
+ sp = VTAILQ_FIRST(&tl->sources);
+ VTAILQ_REMOVE(&tl->sources, sp, list);
vcc_destroy_source(sp);
}
@@ -559,7 +559,7 @@
Fi(tl, 0, "\tVRT_alloc_backends(&VCL_conf);\n");
/* Register and lex the main source */
- TAILQ_INSERT_TAIL(&tl->sources, sp, list);
+ VTAILQ_INSERT_TAIL(&tl->sources, sp, list);
sp->idx = tl->nsources++;
vcc_Lexer(tl, sp);
if (tl->err)
@@ -568,7 +568,7 @@
/* Register and lex the default VCL */
sp = vcc_new_source(vcc_default_vcl_b, vcc_default_vcl_e, "Default");
assert(sp != NULL);
- TAILQ_INSERT_TAIL(&tl->sources, sp, list);
+ VTAILQ_INSERT_TAIL(&tl->sources, sp, list);
sp->idx = tl->nsources++;
vcc_Lexer(tl, sp);
if (tl->err)
@@ -585,7 +585,7 @@
return (vcc_DestroyTokenList(tl, NULL));
/* Parse the token string */
- tl->t = TAILQ_FIRST(&tl->tokens);
+ tl->t = VTAILQ_FIRST(&tl->tokens);
vcc_Parse(tl);
if (tl->err)
return (vcc_DestroyTokenList(tl, NULL));
Modified: branches/1.1/lib/libvcl/vcc_compile.h
===================================================================
--- branches/1.1/lib/libvcl/vcc_compile.h 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/lib/libvcl/vcc_compile.h 2007-09-25 08:54:11 UTC (rev 2034)
@@ -29,18 +29,18 @@
* $Id$
*/
-#include "queue.h"
+#include "vqueue.h"
#include "vcl_returns.h"
#define INDENT 2
struct membit {
- TAILQ_ENTRY(membit) list;
+ VTAILQ_ENTRY(membit) list;
void *ptr;
};
struct source {
- TAILQ_ENTRY(source) list;
+ VTAILQ_ENTRY(source) list;
char *name;
const char *b;
const char *e;
@@ -53,17 +53,17 @@
const char *b;
const char *e;
struct source *src;
- TAILQ_ENTRY(token) list;
+ VTAILQ_ENTRY(token) list;
unsigned cnt;
char *dec;
};
-TAILQ_HEAD(tokenhead, token);
+VTAILQ_HEAD(tokenhead, token);
struct tokenlist {
struct tokenhead tokens;
- TAILQ_HEAD(, source) sources;
- TAILQ_HEAD(, membit) membits;
+ VTAILQ_HEAD(, source) sources;
+ VTAILQ_HEAD(, membit) membits;
unsigned nsources;
struct source *src;
struct token *t;
@@ -74,11 +74,11 @@
unsigned cnt;
struct vsb *fc, *fh, *fi, *ff, *fb;
struct vsb *fm[N_METHODS];
- TAILQ_HEAD(, ref) refs;
+ VTAILQ_HEAD(, ref) refs;
struct vsb *sb;
int err;
int nbackend;
- TAILQ_HEAD(, proc) procs;
+ VTAILQ_HEAD(, proc) procs;
struct proc *curproc;
struct proc *mprocs[N_METHODS];
@@ -119,7 +119,7 @@
struct token *name;
unsigned defcnt;
unsigned refcnt;
- TAILQ_ENTRY(ref) list;
+ VTAILQ_ENTRY(ref) list;
};
struct var {
Modified: branches/1.1/lib/libvcl/vcc_token.c
===================================================================
--- branches/1.1/lib/libvcl/vcc_token.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/lib/libvcl/vcc_token.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -35,7 +35,7 @@
#include
#include "vsb.h"
-#include "queue.h"
+#include "vqueue.h"
#include "libvarnish.h"
#include "vcc_priv.h"
@@ -133,7 +133,7 @@
vcc_NextToken(struct tokenlist *tl)
{
- tl->t = TAILQ_NEXT(tl->t, list);
+ tl->t = VTAILQ_NEXT(tl->t, list);
if (tl->t == NULL) {
vsb_printf(tl->sb,
"Ran out of input, something is missing or"
@@ -262,9 +262,9 @@
t->e = e;
t->src = tl->src;
if (tl->t != NULL)
- TAILQ_INSERT_AFTER(&tl->tokens, tl->t, t, list);
+ VTAILQ_INSERT_AFTER(&tl->tokens, tl->t, t, list);
else
- TAILQ_INSERT_TAIL(&tl->tokens, t, list);
+ VTAILQ_INSERT_TAIL(&tl->tokens, t, list);
tl->t = t;
if (0) {
fprintf(stderr, "[%s %.*s] ",
Modified: branches/1.1/lib/libvcl/vcc_xref.c
===================================================================
--- branches/1.1/lib/libvcl/vcc_xref.c 2007-09-25 08:48:14 UTC (rev 2033)
+++ branches/1.1/lib/libvcl/vcc_xref.c 2007-09-25 08:54:11 UTC (rev 2034)
@@ -50,21 +50,21 @@
/*--------------------------------------------------------------------*/
struct proccall {
- TAILQ_ENTRY(proccall) list;
+ VTAILQ_ENTRY(proccall) list;
struct proc *p;
struct token *t;
};
struct procuse {
- TAILQ_ENTRY(procuse) list;
+ VTAILQ_ENTRY(procuse) list;
struct token *t;
struct var *v;
};
struct proc {
- TAILQ_ENTRY(proc) list;
- TAILQ_HEAD(,proccall) calls;
- TAILQ_HEAD(,procuse) uses;
+ VTAILQ_ENTRY(proc) list;
+ VTAILQ_HEAD(,proccall) calls;
+ VTAILQ_HEAD(,procuse) uses;
struct token *name;
unsigned returns;
unsigned exists;
@@ -101,7 +101,7 @@
{
struct ref *r;
- TAILQ_FOREACH(r, &tl->refs, list) {
+ VTAILQ_FOREACH(r, &tl->refs, list) {
if (r->type != type)
continue;
if (vcc_Teq(r->name, t))
@@ -111,7 +111,7 @@
assert(r != NULL);
r->name = t;
r->type = type;
- TAILQ_INSERT_TAIL(&tl->refs, r, list);
+ VTAILQ_INSERT_TAIL(&tl->refs, r, list);
return (r);
}
@@ -150,7 +150,7 @@
const char *type;
int nerr = 0;
- TAILQ_FOREACH(r, &tl->refs, list) {
+ VTAILQ_FOREACH(r, &tl->refs, list) {
if (r->defcnt != 0 && r->refcnt != 0)
continue;
nerr++;
@@ -181,14 +181,14 @@
{
struct proc *p;
- TAILQ_FOREACH(p, &tl->procs, list)
+ VTAILQ_FOREACH(p, &tl->procs, list)
if (vcc_Teq(p->name, t))
return (p);
p = TlAlloc(tl, sizeof *p);
assert(p != NULL);
- TAILQ_INIT(&p->calls);
- TAILQ_INIT(&p->uses);
- TAILQ_INSERT_TAIL(&tl->procs, p, list);
+ VTAILQ_INIT(&p->calls);
+ VTAILQ_INIT(&p->uses);
+ VTAILQ_INSERT_TAIL(&tl->procs, p, list);
p->name = t;
return (p);
}
@@ -215,7 +215,7 @@
assert(pu != NULL);
pu->v = v;
pu->t = tl->t;
- TAILQ_INSERT_TAIL(&tl->curproc->uses, pu, list);
+ VTAILQ_INSERT_TAIL(&tl->curproc->uses, pu, list);
}
void
@@ -229,7 +229,7 @@
assert(pc != NULL);
pc->p = p;
pc->t = t;
- TAILQ_INSERT_TAIL(&tl->curproc->calls, pc, list);
+ VTAILQ_INSERT_TAIL(&tl->curproc->calls, pc, list);
}
void
@@ -275,7 +275,7 @@
return (1);
}
p->active = 1;
- TAILQ_FOREACH(pc, &p->calls, list) {
+ VTAILQ_FOREACH(pc, &p->calls, list) {
if (vcc_CheckActionRecurse(tl, pc->p, returns)) {
vsb_printf(tl->sb, "\n...called from \"%.*s\"\n",
PF(p->name));
@@ -295,7 +295,7 @@
struct method *m;
int i;
- TAILQ_FOREACH(p, &tl->procs, list) {
+ VTAILQ_FOREACH(p, &tl->procs, list) {
i = IsMethod(p->name);
if (i < 0)
continue;
@@ -317,7 +317,7 @@
return (1);
}
}
- TAILQ_FOREACH(p, &tl->procs, list) {
+ VTAILQ_FOREACH(p, &tl->procs, list) {
if (p->called)
continue;
vsb_printf(tl->sb, "Function unused\n");
@@ -332,7 +332,7 @@
{
struct procuse *pu;
- TAILQ_FOREACH(pu, &p->uses, list)
+ VTAILQ_FOREACH(pu, &p->uses, list)
if (!(pu->v->methods & m->bitval))
return (pu);
return (NULL);
@@ -355,7 +355,7 @@
vcc_ErrWhere(tl, p->name);
return (1);
}
- TAILQ_FOREACH(pc, &p->calls, list) {
+ VTAILQ_FOREACH(pc, &p->calls, list) {
if (vcc_CheckUseRecurse(tl, pc->p, m)) {
vsb_printf(tl->sb, "\n...called from \"%.*s\"\n",
PF(p->name));
@@ -374,7 +374,7 @@
struct procuse *pu;
int i;
- TAILQ_FOREACH(p, &tl->procs, list) {
+ VTAILQ_FOREACH(p, &tl->procs, list) {
i = IsMethod(p->name);
if (i < 0)
continue;
From phk at projects.linpro.no Tue Sep 25 10:24:34 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 12:24:34 +0200 (CEST)
Subject: r2035 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925102434.7EE591EC21D@projects.linpro.no>
Author: phk
Date: 2007-09-25 12:24:34 +0200 (Tue, 25 Sep 2007)
New Revision: 2035
Modified:
trunk/varnish-cache/bin/varnishd/flint.lnt
Log:
Catch up with sys/queue.h changes
Modified: trunk/varnish-cache/bin/varnishd/flint.lnt
===================================================================
--- trunk/varnish-cache/bin/varnishd/flint.lnt 2007-09-25 08:54:11 UTC (rev 2034)
+++ trunk/varnish-cache/bin/varnishd/flint.lnt 2007-09-25 10:24:34 UTC (rev 2035)
@@ -28,12 +28,11 @@
-e785 // Too few initializers for aggregate
-e786 // String concatenation within initializer
--emacro(740, TAILQ_PREV) // Unusual pointer cast (incompatible indirect types)
--emacro(740, TAILQ_LAST) // Unusual pointer cast (incompatible indirect types)
--emacro((826), TAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small)
--emacro((826), TAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small)
+-emacro(740, VTAILQ_PREV) // Unusual pointer cast (incompatible indirect types)
+-emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types)
+-emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small)
+-emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small)
-
-esym(534, sprintf) // Ignoring return value of function
-esym(534, asprintf) // Ignoring return value of function
-esym(534, printf) // Ignoring return value of function
From phk at projects.linpro.no Tue Sep 25 10:25:51 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 12:25:51 +0200 (CEST)
Subject: r2036 - in trunk/varnish-cache: bin/varnishd include lib/libvarnish
Message-ID: <20070925102551.A4F3A1EC1D1@projects.linpro.no>
Author: phk
Date: 2007-09-25 12:25:51 +0200 (Tue, 25 Sep 2007)
New Revision: 2036
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_ban.c
trunk/varnish-cache/bin/varnishd/cache_cli.c
trunk/varnish-cache/bin/varnishd/cache_pool.c
trunk/varnish-cache/bin/varnishd/cache_vcl.c
trunk/varnish-cache/bin/varnishd/mgt_child.c
trunk/varnish-cache/bin/varnishd/mgt_cli.c
trunk/varnish-cache/bin/varnishd/mgt_param.c
trunk/varnish-cache/bin/varnishd/mgt_vcc.c
trunk/varnish-cache/include/cli_priv.h
trunk/varnish-cache/lib/libvarnish/cli.c
trunk/varnish-cache/lib/libvarnish/cli_common.c
Log:
Make the arguments to CLI functions const-const.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 10:24:34 UTC (rev 2035)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 10:25:51 UTC (rev 2036)
@@ -413,8 +413,8 @@
/* cache_ban.c */
void AddBan(const char *, int hash);
void BAN_Init(void);
-void cli_func_url_purge(struct cli *cli, char **av, void *priv);
-void cli_func_hash_purge(struct cli *cli, char **av, void *priv);
+void cli_func_url_purge(struct cli *cli, const char * const *av, void *priv);
+void cli_func_hash_purge(struct cli *cli, const char * const *av, void *priv);
void BAN_NewObj(struct object *o);
int BAN_CheckObject(struct object *o, const char *url, const char *hash);
Modified: trunk/varnish-cache/bin/varnishd/cache_ban.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_ban.c 2007-09-25 10:24:34 UTC (rev 2035)
+++ trunk/varnish-cache/bin/varnishd/cache_ban.c 2007-09-25 10:25:51 UTC (rev 2036)
@@ -102,7 +102,7 @@
}
void
-cli_func_url_purge(struct cli *cli, char **av, void *priv)
+cli_func_url_purge(struct cli *cli, const char * const *av, void *priv)
{
(void)priv;
@@ -111,7 +111,7 @@
}
void
-cli_func_hash_purge(struct cli *cli, char **av, void *priv)
+cli_func_hash_purge(struct cli *cli, const char * const *av, void *priv)
{
(void)priv;
Modified: trunk/varnish-cache/bin/varnishd/cache_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_cli.c 2007-09-25 10:24:34 UTC (rev 2035)
+++ trunk/varnish-cache/bin/varnishd/cache_cli.c 2007-09-25 10:25:51 UTC (rev 2036)
@@ -47,7 +47,7 @@
/*--------------------------------------------------------------------*/
static void
-cli_func_start(struct cli *cli, char **av, void *priv)
+cli_func_start(struct cli *cli, const char * const *av, void *priv)
{
(void)cli;
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-25 10:24:34 UTC (rev 2035)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-25 10:25:51 UTC (rev 2036)
@@ -434,7 +434,7 @@
/*--------------------------------------------------------------------*/
void
-cli_func_dump_pool(struct cli *cli, char **av, void *priv)
+cli_func_dump_pool(struct cli *cli, const char * const *av, void *priv)
{
(void)cli;
Modified: trunk/varnish-cache/bin/varnishd/cache_vcl.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vcl.c 2007-09-25 10:24:34 UTC (rev 2035)
+++ trunk/varnish-cache/bin/varnishd/cache_vcl.c 2007-09-25 10:25:51 UTC (rev 2036)
@@ -195,7 +195,7 @@
/*--------------------------------------------------------------------*/
void
-cli_func_config_list(struct cli *cli, char **av, void *priv)
+cli_func_config_list(struct cli *cli, const char * const *av, void *priv)
{
struct vcls *vcl;
@@ -210,7 +210,7 @@
}
void
-cli_func_config_load(struct cli *cli, char **av, void *priv)
+cli_func_config_load(struct cli *cli, const char * const *av, void *priv)
{
(void)av;
@@ -221,7 +221,7 @@
}
void
-cli_func_config_discard(struct cli *cli, char **av, void *priv)
+cli_func_config_discard(struct cli *cli, const char * const *av, void *priv)
{
struct vcls *vcl;
@@ -257,7 +257,7 @@
}
void
-cli_func_config_use(struct cli *cli, char **av, void *priv)
+cli_func_config_use(struct cli *cli, const char * const *av, void *priv)
{
struct vcls *vcl;
Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_child.c 2007-09-25 10:24:34 UTC (rev 2035)
+++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2007-09-25 10:25:51 UTC (rev 2036)
@@ -435,7 +435,7 @@
/*--------------------------------------------------------------------*/
void
-mcf_server_startstop(struct cli *cli, char **av, void *priv)
+mcf_server_startstop(struct cli *cli, const char * const *av, void *priv)
{
(void)av;
@@ -452,7 +452,7 @@
/*--------------------------------------------------------------------*/
void
-mcf_server_status(struct cli *cli, char **av, void *priv)
+mcf_server_status(struct cli *cli, const char * const *av, void *priv)
{
(void)av;
(void)priv;
Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2007-09-25 10:24:34 UTC (rev 2035)
+++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2007-09-25 10:25:51 UTC (rev 2036)
@@ -62,7 +62,7 @@
/*--------------------------------------------------------------------*/
static void
-mcf_stats(struct cli *cli, char **av, void *priv)
+mcf_stats(struct cli *cli, const char * const *av, void *priv)
{
(void)av;
@@ -82,10 +82,11 @@
*/
static void
-mcf_passthru(struct cli *cli, char **av, void *priv)
+mcf_passthru(struct cli *cli, const char * const *av, void *priv)
{
struct vsb *sb;
- char *p;
+ const char *p;
+ char *q;
unsigned u;
int i;
@@ -127,10 +128,10 @@
xxxassert(i == vsb_len(sb));
vsb_delete(sb);
- i = cli_readres(cli_i, &u, &p, params->cli_timeout);
+ i = cli_readres(cli_i, &u, &q, params->cli_timeout);
cli_result(cli, u);
- cli_out(cli, "%s", p);
- free(p);
+ cli_out(cli, "%s", q);
+ free(q);
}
Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-09-25 10:24:34 UTC (rev 2035)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-09-25 10:25:51 UTC (rev 2036)
@@ -766,7 +766,7 @@
/*--------------------------------------------------------------------*/
void
-mcf_param_show(struct cli *cli, char **av, void *priv)
+mcf_param_show(struct cli *cli, const char * const *av, void *priv)
{
struct parspec *pp;
const char *p, *q;
@@ -854,7 +854,7 @@
/*--------------------------------------------------------------------*/
void
-mcf_param_set(struct cli *cli, char **av, void *priv)
+mcf_param_set(struct cli *cli, const char * const *av, void *priv)
{
(void)priv;
Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-09-25 10:24:34 UTC (rev 2035)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-09-25 10:25:51 UTC (rev 2036)
@@ -474,7 +474,7 @@
/*--------------------------------------------------------------------*/
void
-mcf_config_inline(struct cli *cli, char **av, void *priv)
+mcf_config_inline(struct cli *cli, const char * const *av, void *priv)
{
char *vf, *p;
struct vsb *sb;
@@ -504,7 +504,7 @@
}
void
-mcf_config_load(struct cli *cli, char **av, void *priv)
+mcf_config_load(struct cli *cli, const char * const *av, void *priv)
{
char *vf;
struct vsb *sb;
@@ -550,7 +550,7 @@
}
void
-mcf_config_use(struct cli *cli, char **av, void *priv)
+mcf_config_use(struct cli *cli, const char * const *av, void *priv)
{
unsigned status;
char *p;
@@ -577,7 +577,7 @@
}
void
-mcf_config_discard(struct cli *cli, char **av, void *priv)
+mcf_config_discard(struct cli *cli, const char * const *av, void *priv)
{
unsigned status;
char *p;
@@ -602,7 +602,7 @@
}
void
-mcf_config_list(struct cli *cli, char **av, void *priv)
+mcf_config_list(struct cli *cli, const char * const *av, void *priv)
{
unsigned status;
char *p;
@@ -628,7 +628,7 @@
* XXX: This should take an option argument to show all (include) files
*/
void
-mcf_config_show(struct cli *cli, char **av, void *priv)
+mcf_config_show(struct cli *cli, const char * const *av, void *priv)
{
struct vclprog *vp;
void *dlh, *sym;
Modified: trunk/varnish-cache/include/cli_priv.h
===================================================================
--- trunk/varnish-cache/include/cli_priv.h 2007-09-25 10:24:34 UTC (rev 2035)
+++ trunk/varnish-cache/include/cli_priv.h 2007-09-25 10:25:51 UTC (rev 2036)
@@ -37,7 +37,7 @@
struct cli; /* NB: struct cli is opaque at this level. */
-typedef void cli_func_t(struct cli*, char **av, void *priv);
+typedef void cli_func_t(struct cli*, const char * const *av, void *priv);
struct cli_proto {
/* These must match the CLI_* macros in cli.h */
Modified: trunk/varnish-cache/lib/libvarnish/cli.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/cli.c 2007-09-25 10:24:34 UTC (rev 2035)
+++ trunk/varnish-cache/lib/libvarnish/cli.c 2007-09-25 10:25:51 UTC (rev 2036)
@@ -46,7 +46,7 @@
*/
void
-cli_func_help(struct cli *cli, char **av, void *priv)
+cli_func_help(struct cli *cli, const char * const *av, void *priv)
{
struct cli_proto *cp;
@@ -123,7 +123,7 @@
break;
}
- cp->func(cli, av, cp->priv);
+ cp->func(cli, (const char * const *)av, cp->priv);
} while (0);
FreeArgv(av);
Modified: trunk/varnish-cache/lib/libvarnish/cli_common.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/cli_common.c 2007-09-25 10:24:34 UTC (rev 2035)
+++ trunk/varnish-cache/lib/libvarnish/cli_common.c 2007-09-25 10:25:51 UTC (rev 2036)
@@ -179,7 +179,7 @@
/*--------------------------------------------------------------------*/
void
-cli_func_ping(struct cli *cli, char **av, void *priv)
+cli_func_ping(struct cli *cli, const char * const *av, void *priv)
{
time_t t;
From phk at projects.linpro.no Tue Sep 25 10:32:24 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 12:32:24 +0200 (CEST)
Subject: r2037 - in trunk/varnish-cache: include lib/libvarnish
Message-ID: <20070925103224.79CDE1EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-25 12:32:24 +0200 (Tue, 25 Sep 2007)
New Revision: 2037
Modified:
trunk/varnish-cache/include/libvarnish.h
trunk/varnish-cache/lib/libvarnish/time.c
Log:
Make Tim_format() take a double time argument
Modified: trunk/varnish-cache/include/libvarnish.h
===================================================================
--- trunk/varnish-cache/include/libvarnish.h 2007-09-25 10:25:51 UTC (rev 2036)
+++ trunk/varnish-cache/include/libvarnish.h 2007-09-25 10:32:24 UTC (rev 2037)
@@ -46,7 +46,7 @@
uint32_t crc32_l(const void *p1, unsigned l);
/* from libvarnish/time.c */
-void TIM_format(time_t t, char *p);
+void TIM_format(double t, char *p);
time_t TIM_parse(const char *p);
double TIM_mono(void);
double TIM_real(void);
Modified: trunk/varnish-cache/lib/libvarnish/time.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/time.c 2007-09-25 10:25:51 UTC (rev 2036)
+++ trunk/varnish-cache/lib/libvarnish/time.c 2007-09-25 10:32:24 UTC (rev 2037)
@@ -87,11 +87,13 @@
}
void
-TIM_format(time_t t, char *p)
+TIM_format(double t, char *p)
{
struct tm tm;
+ time_t tt;
- gmtime_r(&t, &tm);
+ tt = (time_t) t;
+ gmtime_r(&tt, &tm);
strftime(p, 30, "%a, %d %b %Y %T GMT", &tm);
}
From phk at projects.linpro.no Tue Sep 25 10:35:44 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 12:35:44 +0200 (CEST)
Subject: r2038 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925103544.521A41EC21D@projects.linpro.no>
Author: phk
Date: 2007-09-25 12:35:44 +0200 (Tue, 25 Sep 2007)
New Revision: 2038
Modified:
trunk/varnish-cache/bin/varnishd/stevedore.h
trunk/varnish-cache/bin/varnishd/storage_file.c
trunk/varnish-cache/bin/varnishd/storage_malloc.c
Log:
Constification of certain storage functions
Modified: trunk/varnish-cache/bin/varnishd/stevedore.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.h 2007-09-25 10:32:24 UTC (rev 2037)
+++ trunk/varnish-cache/bin/varnishd/stevedore.h 2007-09-25 10:35:44 UTC (rev 2038)
@@ -38,8 +38,8 @@
typedef void storage_init_f(struct stevedore *, const char *spec);
typedef void storage_open_f(struct stevedore *);
typedef struct storage *storage_alloc_f(struct stevedore *, size_t size);
-typedef void storage_trim_f(struct storage *, size_t size);
-typedef void storage_free_f(struct storage *);
+typedef void storage_trim_f(const struct storage *, size_t size);
+typedef void storage_free_f(const struct storage *);
struct stevedore {
const char *name;
Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c 2007-09-25 10:32:24 UTC (rev 2037)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c 2007-09-25 10:35:44 UTC (rev 2038)
@@ -660,7 +660,7 @@
/*--------------------------------------------------------------------*/
static void
-smf_trim(struct storage *s, size_t size)
+smf_trim(const struct storage *s, size_t size)
{
struct smf *smf;
struct smf_sc *sc;
@@ -688,7 +688,7 @@
/*--------------------------------------------------------------------*/
static void
-smf_free(struct storage *s)
+smf_free(const struct storage *s)
{
struct smf *smf;
struct smf_sc *sc;
Modified: trunk/varnish-cache/bin/varnishd/storage_malloc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_malloc.c 2007-09-25 10:32:24 UTC (rev 2037)
+++ trunk/varnish-cache/bin/varnishd/storage_malloc.c 2007-09-25 10:35:44 UTC (rev 2038)
@@ -66,7 +66,7 @@
}
static void
-sma_free(struct storage *s)
+sma_free(const struct storage *s)
{
struct sma *sma;
@@ -79,7 +79,7 @@
}
static void
-sma_trim(struct storage *s, size_t size)
+sma_trim(const struct storage *s, size_t size)
{
struct sma *sma;
void *p;
From phk at projects.linpro.no Tue Sep 25 10:37:00 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 12:37:00 +0200 (CEST)
Subject: r2039 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925103700.190AC1EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-25 12:36:59 +0200 (Tue, 25 Sep 2007)
New Revision: 2039
Modified:
trunk/varnish-cache/bin/varnishd/common.h
trunk/varnish-cache/bin/varnishd/tcp.c
Log:
Constification
Modified: trunk/varnish-cache/bin/varnishd/common.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/common.h 2007-09-25 10:35:44 UTC (rev 2038)
+++ trunk/varnish-cache/bin/varnishd/common.h 2007-09-25 10:36:59 UTC (rev 2039)
@@ -41,6 +41,6 @@
#define TCP_ADDRBUFSIZE 64
#define TCP_PORTBUFSIZE 16
-void TCP_name(struct sockaddr *addr, unsigned l, char *abuf, unsigned alen, char *pbuf, unsigned plen);
+void TCP_name(const struct sockaddr *addr, unsigned l, char *abuf, unsigned alen, char *pbuf, unsigned plen);
void TCP_myname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen);
int TCP_filter_http(int sock);
Modified: trunk/varnish-cache/bin/varnishd/tcp.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/tcp.c 2007-09-25 10:35:44 UTC (rev 2038)
+++ trunk/varnish-cache/bin/varnishd/tcp.c 2007-09-25 10:36:59 UTC (rev 2039)
@@ -51,7 +51,7 @@
/*--------------------------------------------------------------------*/
void
-TCP_name(struct sockaddr *addr, unsigned l, char *abuf, unsigned alen, char *pbuf, unsigned plen)
+TCP_name(const struct sockaddr *addr, unsigned l, char *abuf, unsigned alen, char *pbuf, unsigned plen)
{
int i;
From phk at projects.linpro.no Tue Sep 25 11:05:26 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 13:05:26 +0200 (CEST)
Subject: r2040 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925110526.1C2B81EC21D@projects.linpro.no>
Author: phk
Date: 2007-09-25 13:05:25 +0200 (Tue, 25 Sep 2007)
New Revision: 2040
Modified:
trunk/varnish-cache/bin/varnishd/mgt_vcc.c
Log:
If the C-compiler fails, we don't know if it created the output file or not.
Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-09-25 10:36:59 UTC (rev 2039)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-09-25 11:05:25 UTC (rev 2040)
@@ -263,7 +263,7 @@
/* If the compiler complained, or exited non-zero, fail */
if (i || j) {
- AZ(unlink(of));
+ (void)unlink(of); /* May or may not have created file */
free(of);
return (NULL);
}
From phk at projects.linpro.no Tue Sep 25 11:11:15 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 13:11:15 +0200 (CEST)
Subject: r2041 - in trunk/varnish-cache: bin/varnishd include lib/libvcl
Message-ID: <20070925111115.C4BC31EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-25 13:11:15 +0200 (Tue, 25 Sep 2007)
New Revision: 2041
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c
trunk/varnish-cache/bin/varnishd/cache_backend.c
trunk/varnish-cache/bin/varnishd/cache_backend_random.c
trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
trunk/varnish-cache/bin/varnishd/cache_http.c
trunk/varnish-cache/bin/varnishd/cache_pool.c
trunk/varnish-cache/bin/varnishd/cache_session.c
trunk/varnish-cache/bin/varnishd/cache_vary.c
trunk/varnish-cache/bin/varnishd/cache_ws.c
trunk/varnish-cache/bin/varnishd/hash_classic.c
trunk/varnish-cache/bin/varnishd/hash_simple_list.c
trunk/varnish-cache/bin/varnishd/hash_slinger.h
trunk/varnish-cache/bin/varnishd/mgt_child.c
trunk/varnish-cache/bin/varnishd/mgt_cli.c
trunk/varnish-cache/bin/varnishd/mgt_event.h
trunk/varnish-cache/bin/varnishd/rfc2616.c
trunk/varnish-cache/bin/varnishd/stevedore.c
trunk/varnish-cache/bin/varnishd/stevedore.h
trunk/varnish-cache/bin/varnishd/storage_file.c
trunk/varnish-cache/bin/varnishd/varnishd.c
trunk/varnish-cache/include/vrt.h
trunk/varnish-cache/lib/libvcl/vcc_backend.c
trunk/varnish-cache/lib/libvcl/vcc_compile.c
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Mega-Const'ification
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 11:11:15 UTC (rev 2041)
@@ -94,7 +94,7 @@
unsigned WS_Reserve(struct ws *ws, unsigned bytes);
void WS_Release(struct ws *ws, unsigned bytes);
void WS_ReleaseP(struct ws *ws, char *ptr);
-void WS_Assert(struct ws *ws);
+void WS_Assert(const struct ws *ws);
void WS_Reset(struct ws *ws);
char *WS_Alloc(struct ws *ws, unsigned bytes);
@@ -332,13 +332,13 @@
/* Backend method */
-typedef struct vbe_conn *vbe_getfd_f(struct sess *sp);
+typedef struct vbe_conn *vbe_getfd_f(const struct sess *sp);
typedef void vbe_close_f(struct worker *w, struct vbe_conn *vc);
typedef void vbe_recycle_f(struct worker *w, struct vbe_conn *vc);
typedef void vbe_init_f(void);
-typedef const char *vbe_gethostname_f(struct backend *);
-typedef void vbe_cleanup_f(struct backend *);
-typedef void vbe_updatehealth_f(struct sess *sp, struct vbe_conn *vc, int);
+typedef const char *vbe_gethostname_f(const struct backend *);
+typedef void vbe_cleanup_f(const struct backend *);
+typedef void vbe_updatehealth_f(const struct sess *sp, const struct vbe_conn *vc, int);
struct backend_method {
const char *name;
@@ -388,7 +388,7 @@
/* cache_backend.c */
void VBE_Init(void);
-struct vbe_conn *VBE_GetFd(struct sess *sp);
+struct vbe_conn *VBE_GetFd(const struct sess *sp);
void VBE_ClosedFd(struct worker *w, struct vbe_conn *vc);
void VBE_RecycleFd(struct worker *w, struct vbe_conn *vc);
struct bereq * VBE_new_bereq(void);
@@ -399,7 +399,7 @@
struct backend *VBE_NewBackend(struct backend_method *method);
struct vbe_conn *VBE_NewConn(void);
void VBE_ReleaseConn(struct vbe_conn *);
-void VBE_UpdateHealth(struct sess *sp, struct vbe_conn *, int);
+void VBE_UpdateHealth(const struct sess *sp, const struct vbe_conn *, int);
/* convenience functions for backend methods */
int VBE_TryConnect(const struct sess *sp, const struct addrinfo *ai);
@@ -449,7 +449,7 @@
const char *http_StatusMessage(int);
void HTTP_Init(void);
void http_ClrHeader(struct http *to);
-unsigned http_Write(struct worker *w, struct http *hp, int resp);
+unsigned http_Write(struct worker *w, const struct http *hp, int resp);
void http_CopyResp(struct http *to, const struct http *fm);
void http_SetResp(struct http *to, const char *proto, const char *status, const char *response);
void http_FilterFields(struct worker *w, int fd, struct http *to, const struct http *fm, unsigned how);
@@ -493,14 +493,14 @@
void WRK_Reset(struct worker *w, int *fd);
unsigned WRK_Flush(struct worker *w);
unsigned WRK_Write(struct worker *w, const void *ptr, int len);
-unsigned WRK_WriteH(struct worker *w, struct http_hdr *hh, const char *suf);
+unsigned WRK_WriteH(struct worker *w, const struct http_hdr *hh, const char *suf);
#ifdef HAVE_SENDFILE
void WRK_Sendfile(struct worker *w, int fd, off_t off, unsigned len);
#endif /* HAVE_SENDFILE */
/* cache_session.c [SES] */
void SES_Init(void);
-struct sess *SES_New(struct sockaddr *addr, unsigned len);
+struct sess *SES_New(const struct sockaddr *addr, unsigned len);
void SES_Delete(struct sess *sp);
void SES_RefSrcAddr(struct sess *sp);
void SES_Charge(struct sess *sp);
@@ -530,8 +530,8 @@
void SYN_ErrorPage(struct sess *sp, int status, const char *reason, int ttl);
/* cache_vary.c */
-void VRY_Create(struct sess *sp);
-int VRY_Match(struct sess *sp, unsigned char *vary);
+void VRY_Create(const struct sess *sp);
+int VRY_Match(const struct sess *sp, const unsigned char *vary);
/* cache_vcl.c */
void VCL_Init(void);
@@ -554,7 +554,7 @@
#endif
/* rfc2616.c */
-int RFC2616_cache_policy(struct sess *sp, struct http *hp);
+int RFC2616_cache_policy(const struct sess *sp, const struct http *hp);
#if 1
#define MTX pthread_mutex_t
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -73,7 +73,7 @@
}
static void
-vca_kev(struct kevent *kp)
+vca_kev(const struct kevent *kp)
{
int i, j;
struct sess *sp;
Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -267,7 +267,7 @@
/*--------------------------------------------------------------------*/
struct vbe_conn *
-VBE_GetFd(struct sess *sp)
+VBE_GetFd(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -314,7 +314,7 @@
* details and comments about this function.
*/
void
-VBE_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int a)
+VBE_UpdateHealth(const struct sess *sp, const struct vbe_conn *vc, int a)
{
struct backend *b;
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -84,7 +84,7 @@
*/
static int
-ber_conn_try_list(struct sess *sp, struct brspec *bs)
+ber_conn_try_list(const struct sess *sp, struct brspec *bs)
{
struct addrinfo *ai, *from;
int s, loops;
@@ -170,7 +170,7 @@
/*--------------------------------------------------------------------*/
static int
-ber_conn_try(struct sess *sp, struct backend *bp, struct brspec *bs)
+ber_conn_try(const struct sess *sp, struct backend *bp, struct brspec *bs)
{
int s;
@@ -217,7 +217,7 @@
*/
static struct vbe_conn *
-ber_nextfd(struct sess *sp)
+ber_nextfd(const struct sess *sp)
{
struct vbe_conn *vc;
struct backend *bp;
@@ -292,7 +292,7 @@
}
static struct vbe_conn *
-ber_GetFd(struct sess *sp)
+ber_GetFd(const struct sess *sp)
{
struct vbe_conn *vc;
unsigned n;
@@ -350,7 +350,7 @@
/*--------------------------------------------------------------------*/
static void
-ber_Cleanup(struct backend *b)
+ber_Cleanup(const struct backend *b)
{
struct ber *ber;
struct vbe_conn *vbe;
@@ -386,7 +386,7 @@
/* Will return the hostname of the first backend in the list */
static const char *
-ber_GetHostname(struct backend *b)
+ber_GetHostname(const struct backend *b)
{
struct ber *ber;
@@ -402,7 +402,7 @@
* towards neutral (0) as time passes
*/
static void
-ber_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int add)
+ber_UpdateHealth(const struct sess *sp, const struct vbe_conn *vc, int add)
{
struct brspec *bs, *first;
struct ber *ber;
@@ -438,7 +438,7 @@
/*--------------------------------------------------------------------*/
void
-VRT_init_random_backend(struct backend **bp, struct vrt_random_backend *t)
+VRT_init_random_backend(struct backend **bp, const struct vrt_random_backend *t)
{
struct backend *b;
struct ber *ber;
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -83,7 +83,7 @@
*/
static int
-brr_conn_try_list(struct sess *sp, struct bspec *bs)
+brr_conn_try_list(const struct sess *sp, struct bspec *bs)
{
struct addrinfo *ai, *from;
int s, loops;
@@ -169,7 +169,7 @@
/*--------------------------------------------------------------------*/
static int
-brr_conn_try(struct sess *sp, struct backend *bp, struct bspec *bs)
+brr_conn_try(const struct sess *sp, struct backend *bp, struct bspec *bs)
{
int s;
@@ -215,7 +215,7 @@
*/
static struct vbe_conn *
-brr_nextfd(struct sess *sp)
+brr_nextfd(const struct sess *sp)
{
struct vbe_conn *vc;
struct backend *bp;
@@ -277,7 +277,7 @@
}
static struct vbe_conn *
-brr_GetFd(struct sess *sp)
+brr_GetFd(const struct sess *sp)
{
struct vbe_conn *vc;
unsigned n;
@@ -335,7 +335,7 @@
/*--------------------------------------------------------------------*/
static void
-brr_Cleanup(struct backend *b)
+brr_Cleanup(const struct backend *b)
{
struct brr *brr;
struct vbe_conn *vbe;
@@ -371,7 +371,7 @@
/* Will return the hostname of the first backend in the list */
static const char *
-brr_GetHostname(struct backend *b)
+brr_GetHostname(const struct backend *b)
{
struct brr *brr;
@@ -387,7 +387,7 @@
* towards neutral (0) as time passes
*/
static void
-brr_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int add)
+brr_UpdateHealth(const struct sess *sp, const struct vbe_conn *vc, int add)
{
struct bspec *bs, *first;
struct brr *brr;
@@ -424,7 +424,7 @@
/*--------------------------------------------------------------------*/
void
-VRT_init_round_robin_backend(struct backend **bp, struct vrt_round_robin_backend *t)
+VRT_init_round_robin_backend(struct backend **bp, const struct vrt_round_robin_backend *t)
{
struct backend *b;
struct brr *brr;
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -67,7 +67,7 @@
*/
static int
-bes_conn_try_list(struct sess *sp, struct bes *bes)
+bes_conn_try_list(const struct sess *sp, struct bes *bes)
{
struct addrinfo *ai, *from;
int s, loops;
@@ -154,7 +154,7 @@
/*--------------------------------------------------------------------*/
static int
-bes_conn_try(struct sess *sp, struct backend *bp)
+bes_conn_try(const struct sess *sp, struct backend *bp)
{
int s;
struct bes *bes;
@@ -200,7 +200,7 @@
*/
static struct vbe_conn *
-bes_nextfd(struct sess *sp)
+bes_nextfd(const struct sess *sp)
{
struct vbe_conn *vc;
struct backend *bp;
@@ -250,7 +250,7 @@
/*--------------------------------------------------------------------*/
static struct vbe_conn *
-bes_GetFd(struct sess *sp)
+bes_GetFd(const struct sess *sp)
{
struct vbe_conn *vc;
unsigned n;
@@ -309,7 +309,7 @@
/*--------------------------------------------------------------------*/
static void
-bes_Cleanup(struct backend *b)
+bes_Cleanup(const struct backend *b)
{
struct bes *bes;
struct vbe_conn *vbe;
@@ -334,7 +334,7 @@
/*--------------------------------------------------------------------*/
static const char *
-bes_GetHostname(struct backend *b)
+bes_GetHostname(const struct backend *b)
{
struct bes *bes;
@@ -357,7 +357,7 @@
/*--------------------------------------------------------------------*/
void
-VRT_init_simple_backend(struct backend **bp, struct vrt_simple_backend *t)
+VRT_init_simple_backend(struct backend **bp, const struct vrt_simple_backend *t)
{
struct backend *b;
struct bes *bes;
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -986,7 +986,7 @@
/*--------------------------------------------------------------------*/
unsigned
-http_Write(struct worker *w, struct http *hp, int resp)
+http_Write(struct worker *w, const struct http *hp, int resp)
{
unsigned u, l;
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -108,7 +108,7 @@
}
unsigned
-WRK_WriteH(struct worker *w, struct http_hdr *hh, const char *suf)
+WRK_WriteH(struct worker *w, const struct http_hdr *hh, const char *suf)
{
unsigned u;
Modified: trunk/varnish-cache/bin/varnishd/cache_session.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_session.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/cache_session.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -209,7 +209,7 @@
/*--------------------------------------------------------------------*/
static void
-ses_sum_acct(struct acct *sum, struct acct *inc)
+ses_sum_acct(struct acct *sum, const struct acct *inc)
{
sum->sess += inc->sess;
@@ -256,7 +256,7 @@
/*--------------------------------------------------------------------*/
struct sess *
-SES_New(struct sockaddr *addr, unsigned len)
+SES_New(const struct sockaddr *addr, unsigned len)
{
struct sessmem *sm;
struct sess *sp;
Modified: trunk/varnish-cache/bin/varnishd/cache_vary.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vary.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/cache_vary.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -61,7 +61,7 @@
#include "cache.h"
void
-VRY_Create(struct sess *sp)
+VRY_Create(const struct sess *sp)
{
char *v, *p, *q, *h, *e;
struct vsb *sb, *sbh;
@@ -129,7 +129,7 @@
}
int
-VRY_Match(struct sess *sp, unsigned char *vary)
+VRY_Match(const struct sess *sp, const unsigned char *vary)
{
char *h, *e;
int i, l, lh;
@@ -137,7 +137,7 @@
while (*vary) {
/* Look for header */
- i = http_GetHdr(sp->http, (char*)vary, &h);
+ i = http_GetHdr(sp->http, (const char*)vary, &h);
vary += *vary + 2;
/* Expected length of header (or 0xffff) */
Modified: trunk/varnish-cache/bin/varnishd/cache_ws.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/cache_ws.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -46,7 +46,7 @@
#include "cache.h"
void
-WS_Assert(struct ws *ws)
+WS_Assert(const struct ws *ws)
{
assert(ws != NULL);
Modified: trunk/varnish-cache/bin/varnishd/hash_classic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/hash_classic.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -119,7 +119,7 @@
*/
static struct objhead *
-hcl_lookup(struct sess *sp, struct objhead *noh)
+hcl_lookup(const struct sess *sp, struct objhead *noh)
{
struct objhead *roh;
struct hcl_entry *he, *he2;
@@ -213,7 +213,7 @@
*/
static int
-hcl_deref(struct objhead *oh)
+hcl_deref(const struct objhead *oh)
{
struct hcl_entry *he;
struct hcl_hd *hp;
Modified: trunk/varnish-cache/bin/varnishd/hash_simple_list.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_simple_list.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/hash_simple_list.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -71,7 +71,7 @@
*/
static struct objhead *
-hsl_lookup(struct sess *sp, struct objhead *nobj)
+hsl_lookup(const struct sess *sp, struct objhead *nobj)
{
struct hsl_entry *he, *he2;
int i;
@@ -116,7 +116,7 @@
*/
static int
-hsl_deref(struct objhead *obj)
+hsl_deref(const struct objhead *obj)
{
struct hsl_entry *he;
int ret;
Modified: trunk/varnish-cache/bin/varnishd/hash_slinger.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_slinger.h 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/hash_slinger.h 2007-09-25 11:11:15 UTC (rev 2041)
@@ -33,8 +33,8 @@
typedef int hash_init_f(const char *);
typedef void hash_start_f(void);
-typedef struct objhead *hash_lookup_f(struct sess *sp, struct objhead *nobj);
-typedef int hash_deref_f(struct objhead *obj);
+typedef struct objhead *hash_lookup_f(const struct sess *sp, struct objhead *nobj);
+typedef int hash_deref_f(const struct objhead *obj);
struct hash_slinger {
const char *name;
Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_child.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -81,7 +81,7 @@
/*--------------------------------------------------------------------*/
static int
-child_listener(struct ev *e, int what)
+child_listener(const struct ev *e, int what)
{
int i;
char buf[BUFSIZ];
@@ -105,7 +105,7 @@
/*--------------------------------------------------------------------*/
static int
-child_poker(struct ev *e, int what)
+child_poker(const struct ev *e, int what)
{
(void)e;
@@ -290,7 +290,7 @@
/*--------------------------------------------------------------------*/
static int
-mgt_sigchld(struct ev *e, int what)
+mgt_sigchld(const struct ev *e, int what)
{
int status;
pid_t r;
@@ -353,7 +353,7 @@
/*--------------------------------------------------------------------*/
static int
-mgt_sigint(struct ev *e, int what)
+mgt_sigint(const struct ev *e, int what)
{
(void)e;
Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -293,7 +293,7 @@
};
static int
-mgt_cli_callback(struct ev *e, int what)
+mgt_cli_callback(const struct ev *e, int what)
{
struct cli_port *cp;
char *p, *q;
@@ -391,7 +391,7 @@
}
static int
-telnet_accept(struct ev *ev, int what)
+telnet_accept(const struct ev *ev, int what)
{
struct sockaddr_storage addr;
socklen_t addrlen;
Modified: trunk/varnish-cache/bin/varnishd/mgt_event.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_event.h 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/mgt_event.h 2007-09-25 11:11:15 UTC (rev 2041)
@@ -36,7 +36,7 @@
struct ev;
struct evbase;
-typedef int ev_cb_f(struct ev *, int what);
+typedef int ev_cb_f(const struct ev *, int what);
struct ev {
unsigned magic;
Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/rfc2616.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/rfc2616.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -99,7 +99,7 @@
#endif
static double
-RFC2616_Ttl(const struct sess *sp, struct http *hp, struct object *obj)
+RFC2616_Ttl(const struct sess *sp, const struct http *hp, struct object *obj)
{
int retirement_age;
unsigned u1, u2;
@@ -163,7 +163,7 @@
}
int
-RFC2616_cache_policy(struct sess *sp, struct http *hp)
+RFC2616_cache_policy(const struct sess *sp, const struct http *hp)
{
int body = 0;
Modified: trunk/varnish-cache/bin/varnishd/stevedore.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/stevedore.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -72,7 +72,7 @@
}
void
-STV_trim(struct storage *st, size_t size)
+STV_trim(const struct storage *st, size_t size)
{
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
@@ -82,7 +82,7 @@
}
void
-STV_free(struct storage *st)
+STV_free(const struct storage *st)
{
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
Modified: trunk/varnish-cache/bin/varnishd/stevedore.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/stevedore.h 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/stevedore.h 2007-09-25 11:11:15 UTC (rev 2041)
@@ -36,7 +36,7 @@
struct iovec;
typedef void storage_init_f(struct stevedore *, const char *spec);
-typedef void storage_open_f(struct stevedore *);
+typedef void storage_open_f(const struct stevedore *);
typedef struct storage *storage_alloc_f(struct stevedore *, size_t size);
typedef void storage_trim_f(const struct storage *, size_t size);
typedef void storage_free_f(const struct storage *);
@@ -56,7 +56,7 @@
};
struct storage *STV_alloc(struct sess *sp, size_t size);
-void STV_trim(struct storage *st, size_t size);
-void STV_free(struct storage *st);
+void STV_trim(const struct storage *st, size_t size);
+void STV_free(const struct storage *st);
void STV_add(const char *spec);
void STV_open(void);
Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -373,7 +373,7 @@
}
static void
-remfree(struct smf_sc *sc, struct smf *sp)
+remfree(const struct smf_sc *sc, struct smf *sp)
{
size_t b;
@@ -601,7 +601,7 @@
}
static void
-smf_open(struct stevedore *st)
+smf_open(const struct stevedore *st)
{
struct smf_sc *sc;
off_t fail = 1 << 30; /* XXX: where is OFF_T_MAX ? */
Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -77,7 +77,7 @@
/*--------------------------------------------------------------------*/
static int
-cmp_hash(struct hash_slinger *s, const char *p, const char *q)
+cmp_hash(const struct hash_slinger *s, const char *p, const char *q)
{
if (strlen(s->name) != q - p)
return (1);
@@ -350,7 +350,7 @@
/*--------------------------------------------------------------------*/
static void
-cli_check(struct cli *cli)
+cli_check(const struct cli *cli)
{
if (cli->result == CLIS_OK) {
vsb_clear(cli->sb);
Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/include/vrt.h 2007-09-25 11:11:15 UTC (rev 2041)
@@ -115,9 +115,9 @@
/* Backend related */
-void VRT_init_simple_backend(struct backend **, struct vrt_simple_backend *);
-void VRT_init_round_robin_backend(struct backend **, struct vrt_round_robin_backend *);
-void VRT_init_random_backend(struct backend **, struct vrt_random_backend *);
+void VRT_init_simple_backend(struct backend **, const struct vrt_simple_backend *);
+void VRT_init_round_robin_backend(struct backend **, const struct vrt_round_robin_backend *);
+void VRT_init_random_backend(struct backend **, const struct vrt_random_backend *);
void VRT_fini_backend(struct backend *);
char *VRT_IP_string(struct sess *sp, struct sockaddr *sa);
Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -172,7 +172,7 @@
}
vcc_NextToken(tl);
- Fc(tl, 0, "\nstatic struct vrt_simple_backend sbe_%.*s = {\n",
+ Fc(tl, 0, "\nstatic const struct vrt_simple_backend sbe_%.*s = {\n",
PF(t_be));
Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(t_be));
if (t_port != NULL)
Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -341,7 +341,7 @@
Fc(tl, 0, "\nstatic struct backend\t*backends[%d];\n", tl->nbackend);
- Fc(tl, 0, "\nstruct VCL_conf VCL_conf = {\n");
+ Fc(tl, 0, "\nconst struct VCL_conf VCL_conf = {\n");
Fc(tl, 0, "\t.magic = VCL_CONF_MAGIC,\n");
Fc(tl, 0, "\t.init_func = VGC_Init,\n");
Fc(tl, 0, "\t.fini_func = VGC_Fini,\n");
@@ -558,7 +558,7 @@
vcl_output_lang_h(tl->fh);
Fh(tl, 0, "\n/* ---===### VCC generated below here ###===---*/\n");
- Fh(tl, 0, "\nextern struct VCL_conf VCL_conf;\n");
+ Fh(tl, 0, "\nextern const struct VCL_conf VCL_conf;\n");
/* Register and lex the main source */
VTAILQ_INSERT_TAIL(&tl->sources, sp, list);
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-25 11:05:25 UTC (rev 2040)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-25 11:11:15 UTC (rev 2041)
@@ -493,9 +493,9 @@
vsb_cat(sb, "\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "/* Backend related */\n");
- vsb_cat(sb, "void VRT_init_simple_backend(struct backend **, struct vrt_simple_backend *);\n");
- vsb_cat(sb, "void VRT_init_round_robin_backend(struct backend **, struct vrt_round_robin_backend *);\n");
- vsb_cat(sb, "void VRT_init_random_backend(struct backend **, struct vrt_random_backend *);\n");
+ vsb_cat(sb, "void VRT_init_simple_backend(struct backend **, const struct vrt_simple_backend *);\n");
+ vsb_cat(sb, "void VRT_init_round_robin_backend(struct backend **, const struct vrt_round_robin_backend *);\n");
+ vsb_cat(sb, "void VRT_init_random_backend(struct backend **, const struct vrt_random_backend *);\n");
vsb_cat(sb, "void VRT_fini_backend(struct backend *);\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "char *VRT_IP_string(struct sess *sp, struct sockaddr *sa);\n");
From phk at projects.linpro.no Tue Sep 25 11:51:49 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 13:51:49 +0200 (CEST)
Subject: r2042 - in trunk/varnish-cache: bin/varnishd include lib/libvcl
Message-ID: <20070925115149.B19651EC21D@projects.linpro.no>
Author: phk
Date: 2007-09-25 13:51:49 +0200 (Tue, 25 Sep 2007)
New Revision: 2042
Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt.c
trunk/varnish-cache/bin/varnishd/cache_vrt_acl.c
trunk/varnish-cache/bin/varnishd/cache_vrt_re.c
trunk/varnish-cache/include/vrt.h
trunk/varnish-cache/include/vrt_obj.h
trunk/varnish-cache/lib/libvcl/vcc_acl.c
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
Log:
Constify a lot of the VRT API
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-25 11:51:49 UTC (rev 2042)
@@ -63,7 +63,7 @@
/*--------------------------------------------------------------------*/
void
-VRT_count(struct sess *sp, unsigned u)
+VRT_count(const struct sess *sp, unsigned u)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -101,7 +101,7 @@
}
char *
-VRT_GetHdr(struct sess *sp, enum gethdr_e where, const char *n)
+VRT_GetHdr(const struct sess *sp, enum gethdr_e where, const char *n)
{
char *p;
struct http *hp;
@@ -155,7 +155,7 @@
/*--------------------------------------------------------------------*/
void
-VRT_SetHdr(struct sess *sp , enum gethdr_e where, const char *hdr, const char *p, ...)
+VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr, const char *p, ...)
{
struct http *hp;
va_list ap;
@@ -198,7 +198,7 @@
#define VRT_DO_HDR(obj, hdr, http, fld) \
void \
-VRT_l_##obj##_##hdr(struct sess *sp, const char *p, ...) \
+VRT_l_##obj##_##hdr(const struct sess *sp, const char *p, ...) \
{ \
va_list ap; \
\
@@ -221,7 +221,7 @@
VRT_DO_HDR(resp, response, sp->http, HTTP_HDR_RESPONSE)
void
-VRT_l_obj_status(struct sess *sp, int num)
+VRT_l_obj_status(const struct sess *sp, int num)
{
char *p;
@@ -235,7 +235,7 @@
}
int
-VRT_r_obj_status(struct sess *sp)
+VRT_r_obj_status(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
@@ -243,7 +243,7 @@
}
void
-VRT_l_resp_status(struct sess *sp, int num)
+VRT_l_resp_status(const struct sess *sp, int num)
{
char *p;
@@ -279,7 +279,7 @@
*/
void
-VRT_l_obj_ttl(struct sess *sp, double a)
+VRT_l_obj_ttl(const struct sess *sp, double a)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -294,7 +294,7 @@
}
double
-VRT_r_obj_ttl(struct sess *sp)
+VRT_r_obj_ttl(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
@@ -305,7 +305,7 @@
#define VOBJ(type,onm,field) \
void \
-VRT_l_obj_##onm(struct sess *sp, type a) \
+VRT_l_obj_##onm(const struct sess *sp, type a) \
{ \
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ \
@@ -313,7 +313,7 @@
} \
\
type \
-VRT_r_obj_##onm(struct sess *sp) \
+VRT_r_obj_##onm(const struct sess *sp) \
{ \
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ \
@@ -343,7 +343,7 @@
#define VREQ(n1, n2) \
const char * \
-VRT_r_req_##n1(struct sess *sp) \
+VRT_r_req_##n1(const struct sess *sp) \
{ \
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \
CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC); \
@@ -357,7 +357,7 @@
/*--------------------------------------------------------------------*/
const char *
-VRT_r_resp_proto(struct sess *sp)
+VRT_r_resp_proto(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
@@ -365,7 +365,7 @@
}
const char *
-VRT_r_resp_response(struct sess *sp)
+VRT_r_resp_response(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
@@ -373,7 +373,7 @@
}
int
-VRT_r_resp_status(struct sess *sp)
+VRT_r_resp_status(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
@@ -383,7 +383,7 @@
/*--------------------------------------------------------------------*/
struct sockaddr *
-VRT_r_client_ip(struct sess *sp)
+VRT_r_client_ip(const struct sess *sp)
{
return (sp->sockaddr);
@@ -428,7 +428,7 @@
/*--------------------------------------------------------------------*/
double
-VRT_r_now(struct sess *sp)
+VRT_r_now(const struct sess *sp)
{
(void)sp;
@@ -436,7 +436,7 @@
}
double
-VRT_r_obj_lastuse(struct sess *sp)
+VRT_r_obj_lastuse(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -445,18 +445,18 @@
}
int
-VRT_r_backend_health(struct sess *sp)
+VRT_r_backend_health(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
- return sp->backend->health;
+ return (sp->backend->health);
}
/*--------------------------------------------------------------------*/
char *
-VRT_IP_string(struct sess *sp, struct sockaddr *sa)
+VRT_IP_string(const struct sess *sp, const struct sockaddr *sa)
{
char h[64], p[8], *q;
socklen_t len = 0;
@@ -483,7 +483,7 @@
}
char *
-VRT_int_string(struct sess *sp, int num)
+VRT_int_string(const struct sess *sp, int num)
{
char *p;
int size = 12;
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_acl.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_acl.c 2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_acl.c 2007-09-25 11:51:49 UTC (rev 2042)
@@ -60,7 +60,7 @@
};
static int
-vrt_acl_vsl(struct sess *sp, const char *acln, struct vrt_acl *ap, int r)
+vrt_acl_vsl(const struct sess *sp, const char *acln, const struct vrt_acl *ap, int r)
{
AN(ap);
@@ -83,7 +83,7 @@
}
int
-VRT_acl_match(struct sess *sp, struct sockaddr *sa, const char *acln, struct vrt_acl *ap)
+VRT_acl_match(const struct sess *sp, struct sockaddr *sa, const char *acln, const struct vrt_acl *ap)
{
struct addrinfo *a1;
struct sockaddr_in *sin1, *sin2;
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2007-09-25 11:51:49 UTC (rev 2042)
@@ -102,7 +102,7 @@
}
const char *
-VRT_regsub(struct sess *sp, const char *str, void *re, const char *sub)
+VRT_regsub(const struct sess *sp, const char *str, void *re, const char *sub)
{
regmatch_t pm[10];
regex_t *t;
Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/include/vrt.h 2007-09-25 11:51:49 UTC (rev 2042)
@@ -87,7 +87,7 @@
};
/* ACL related */
-int VRT_acl_match(struct sess *, struct sockaddr *, const char *, struct vrt_acl *);
+int VRT_acl_match(const struct sess *, struct sockaddr *, const char *, const struct vrt_acl *);
void VRT_acl_init(struct vrt_acl *);
void VRT_acl_fini(struct vrt_acl *);
@@ -96,18 +96,18 @@
void VRT_re_fini(void *);
int VRT_re_match(const char *, void *re);
int VRT_re_test(struct vsb *, const char *, int sub);
-const char *VRT_regsub(struct sess *sp, const char *, void *, const char *);
+const char *VRT_regsub(const struct sess *sp, const char *, void *, const char *);
void VRT_purge(const char *, int hash);
-void VRT_count(struct sess *, unsigned);
+void VRT_count(const struct sess *, unsigned);
int VRT_rewrite(const char *, const char *);
void VRT_error(struct sess *, unsigned, const char *);
int VRT_switch_config(const char *);
enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ };
-char *VRT_GetHdr(struct sess *, enum gethdr_e where, const char *);
-void VRT_SetHdr(struct sess *, enum gethdr_e where, const char *, const char *, ...);
+char *VRT_GetHdr(const struct sess *, enum gethdr_e where, const char *);
+void VRT_SetHdr(const struct sess *, enum gethdr_e where, const char *, const char *, ...);
void VRT_handling(struct sess *sp, unsigned hand);
/* Simple stuff */
@@ -120,8 +120,8 @@
void VRT_init_random_backend(struct backend **, const struct vrt_random_backend *);
void VRT_fini_backend(struct backend *);
-char *VRT_IP_string(struct sess *sp, struct sockaddr *sa);
-char *VRT_int_string(struct sess *sp, int);
+char *VRT_IP_string(const struct sess *sp, const struct sockaddr *sa);
+char *VRT_int_string(const struct sess *sp, int);
#define VRT_done(sp, hand) \
do { \
Modified: trunk/varnish-cache/include/vrt_obj.h
===================================================================
--- trunk/varnish-cache/include/vrt_obj.h 2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/include/vrt_obj.h 2007-09-25 11:51:49 UTC (rev 2042)
@@ -10,41 +10,41 @@
void VRT_l_backend_port(struct backend *, const char *);
void VRT_l_backend_dnsttl(struct backend *, double);
void VRT_l_backend_set(struct backend *, struct vrt_backend_entry *);
-struct sockaddr * VRT_r_client_ip(struct sess *);
+struct sockaddr * VRT_r_client_ip(const struct sess *);
struct sockaddr * VRT_r_server_ip(struct sess *);
-const char * VRT_r_req_request(struct sess *);
-void VRT_l_req_request(struct sess *, const char *, ...);
-const char * VRT_r_req_url(struct sess *);
-void VRT_l_req_url(struct sess *, const char *, ...);
-const char * VRT_r_req_proto(struct sess *);
-void VRT_l_req_proto(struct sess *, const char *, ...);
+const char * VRT_r_req_request(const struct sess *);
+void VRT_l_req_request(const struct sess *, const char *, ...);
+const char * VRT_r_req_url(const struct sess *);
+void VRT_l_req_url(const struct sess *, const char *, ...);
+const char * VRT_r_req_proto(const struct sess *);
+void VRT_l_req_proto(const struct sess *, const char *, ...);
void VRT_l_req_hash(struct sess *, const char *);
struct backend * VRT_r_req_backend(struct sess *);
void VRT_l_req_backend(struct sess *, struct backend *);
-const char * VRT_r_bereq_request(struct sess *);
-void VRT_l_bereq_request(struct sess *, const char *, ...);
-const char * VRT_r_bereq_url(struct sess *);
-void VRT_l_bereq_url(struct sess *, const char *, ...);
-const char * VRT_r_bereq_proto(struct sess *);
-void VRT_l_bereq_proto(struct sess *, const char *, ...);
-const char * VRT_r_obj_proto(struct sess *);
-void VRT_l_obj_proto(struct sess *, const char *, ...);
-int VRT_r_obj_status(struct sess *);
-void VRT_l_obj_status(struct sess *, int);
-const char * VRT_r_obj_response(struct sess *);
-void VRT_l_obj_response(struct sess *, const char *, ...);
-unsigned VRT_r_obj_valid(struct sess *);
-void VRT_l_obj_valid(struct sess *, unsigned);
-unsigned VRT_r_obj_cacheable(struct sess *);
-void VRT_l_obj_cacheable(struct sess *, unsigned);
-double VRT_r_obj_ttl(struct sess *);
-void VRT_l_obj_ttl(struct sess *, double);
-double VRT_r_obj_lastuse(struct sess *);
-const char * VRT_r_resp_proto(struct sess *);
-void VRT_l_resp_proto(struct sess *, const char *, ...);
-int VRT_r_resp_status(struct sess *);
-void VRT_l_resp_status(struct sess *, int);
-const char * VRT_r_resp_response(struct sess *);
-void VRT_l_resp_response(struct sess *, const char *, ...);
-double VRT_r_now(struct sess *);
-int VRT_r_backend_health(struct sess *);
+const char * VRT_r_bereq_request(const struct sess *);
+void VRT_l_bereq_request(const struct sess *, const char *, ...);
+const char * VRT_r_bereq_url(const struct sess *);
+void VRT_l_bereq_url(const struct sess *, const char *, ...);
+const char * VRT_r_bereq_proto(const struct sess *);
+void VRT_l_bereq_proto(const struct sess *, const char *, ...);
+const char * VRT_r_obj_proto(const struct sess *);
+void VRT_l_obj_proto(const struct sess *, const char *, ...);
+int VRT_r_obj_status(const struct sess *);
+void VRT_l_obj_status(const struct sess *, int);
+const char * VRT_r_obj_response(const struct sess *);
+void VRT_l_obj_response(const struct sess *, const char *, ...);
+unsigned VRT_r_obj_valid(const struct sess *);
+void VRT_l_obj_valid(const struct sess *, unsigned);
+unsigned VRT_r_obj_cacheable(const struct sess *);
+void VRT_l_obj_cacheable(const struct sess *, unsigned);
+double VRT_r_obj_ttl(const struct sess *);
+void VRT_l_obj_ttl(const struct sess *, double);
+double VRT_r_obj_lastuse(const struct sess *);
+const char * VRT_r_resp_proto(const struct sess *);
+void VRT_l_resp_proto(const struct sess *, const char *, ...);
+int VRT_r_resp_status(const struct sess *);
+void VRT_l_resp_status(const struct sess *, int);
+const char * VRT_r_resp_response(const struct sess *);
+void VRT_l_resp_response(const struct sess *, const char *, ...);
+double VRT_r_now(const struct sess *);
+int VRT_r_backend_health(const struct sess *);
Modified: trunk/varnish-cache/lib/libvcl/vcc_acl.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_acl.c 2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/lib/libvcl/vcc_acl.c 2007-09-25 11:51:49 UTC (rev 2042)
@@ -42,7 +42,7 @@
vcc_acl_top(struct tokenlist *tl, const char *acln)
{
- Fh(tl, 1, "\nstatic struct vrt_acl acl_%s[] = {\n", acln);
+ Fh(tl, 1, "\nstatic const struct vrt_acl acl_%s[] = {\n", acln);
tl->hindent += INDENT;
}
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-25 11:51:49 UTC (rev 2042)
@@ -465,7 +465,7 @@
vsb_cat(sb, "};\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "/* ACL related */\n");
- vsb_cat(sb, "int VRT_acl_match(struct sess *, struct sockaddr *, const char *, struct vrt_acl *);\n");
+ vsb_cat(sb, "int VRT_acl_match(const struct sess *, struct sockaddr *, const char *, const struct vrt_acl *);\n");
vsb_cat(sb, "void VRT_acl_init(struct vrt_acl *);\n");
vsb_cat(sb, "void VRT_acl_fini(struct vrt_acl *);\n");
vsb_cat(sb, "\n");
@@ -474,18 +474,18 @@
vsb_cat(sb, "void VRT_re_fini(void *);\n");
vsb_cat(sb, "int VRT_re_match(const char *, void *re);\n");
vsb_cat(sb, "int VRT_re_test(struct vsb *, const char *, int sub);\n");
- vsb_cat(sb, "const char *VRT_regsub(struct sess *sp, const char *, void *, const char *);\n");
+ vsb_cat(sb, "const char *VRT_regsub(const struct sess *sp, const char *, void *, const char *);\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "void VRT_purge(const char *, int hash);\n");
vsb_cat(sb, "\n");
- vsb_cat(sb, "void VRT_count(struct sess *, unsigned);\n");
+ vsb_cat(sb, "void VRT_count(const struct sess *, unsigned);\n");
vsb_cat(sb, "int VRT_rewrite(const char *, const char *);\n");
vsb_cat(sb, "void VRT_error(struct sess *, unsigned, const char *);\n");
vsb_cat(sb, "int VRT_switch_config(const char *);\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ };\n");
- vsb_cat(sb, "char *VRT_GetHdr(struct sess *, enum gethdr_e where, const char *);\n");
- vsb_cat(sb, "void VRT_SetHdr(struct sess *, enum gethdr_e where, const char *, const char *, ...);\n");
+ vsb_cat(sb, "char *VRT_GetHdr(const struct sess *, enum gethdr_e where, const char *);\n");
+ vsb_cat(sb, "void VRT_SetHdr(const struct sess *, enum gethdr_e where, const char *, const char *, ...);\n");
vsb_cat(sb, "void VRT_handling(struct sess *sp, unsigned hand);\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "/* Simple stuff */\n");
@@ -498,8 +498,8 @@
vsb_cat(sb, "void VRT_init_random_backend(struct backend **, const struct vrt_random_backend *);\n");
vsb_cat(sb, "void VRT_fini_backend(struct backend *);\n");
vsb_cat(sb, "\n");
- vsb_cat(sb, "char *VRT_IP_string(struct sess *sp, struct sockaddr *sa);\n");
- vsb_cat(sb, "char *VRT_int_string(struct sess *sp, int);\n");
+ vsb_cat(sb, "char *VRT_IP_string(const struct sess *sp, const struct sockaddr *sa);\n");
+ vsb_cat(sb, "char *VRT_int_string(const struct sess *sp, int);\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "#define VRT_done(sp, hand) \\\n");
vsb_cat(sb, " do { \\\n");
@@ -518,42 +518,42 @@
vsb_cat(sb, "void VRT_l_backend_port(struct backend *, const char *);\n");
vsb_cat(sb, "void VRT_l_backend_dnsttl(struct backend *, double);\n");
vsb_cat(sb, "void VRT_l_backend_set(struct backend *, struct vrt_backend_entry *);\n");
- vsb_cat(sb, "struct sockaddr * VRT_r_client_ip(struct sess *);\n");
+ vsb_cat(sb, "struct sockaddr * VRT_r_client_ip(const struct sess *);\n");
vsb_cat(sb, "struct sockaddr * VRT_r_server_ip(struct sess *);\n");
- vsb_cat(sb, "const char * VRT_r_req_request(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_req_request(struct sess *, const char *, ...);\n");
- vsb_cat(sb, "const char * VRT_r_req_url(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_req_url(struct sess *, const char *, ...);\n");
- vsb_cat(sb, "const char * VRT_r_req_proto(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_req_proto(struct sess *, const char *, ...);\n");
+ vsb_cat(sb, "const char * VRT_r_req_request(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_req_request(const struct sess *, const char *, ...);\n");
+ vsb_cat(sb, "const char * VRT_r_req_url(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_req_url(const struct sess *, const char *, ...);\n");
+ vsb_cat(sb, "const char * VRT_r_req_proto(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_req_proto(const struct sess *, const char *, ...);\n");
vsb_cat(sb, "void VRT_l_req_hash(struct sess *, const char *);\n");
vsb_cat(sb, "struct backend * VRT_r_req_backend(struct sess *);\n");
vsb_cat(sb, "void VRT_l_req_backend(struct sess *, struct backend *);\n");
- vsb_cat(sb, "const char * VRT_r_bereq_request(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_bereq_request(struct sess *, const char *, ...);\n");
- vsb_cat(sb, "const char * VRT_r_bereq_url(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_bereq_url(struct sess *, const char *, ...);\n");
- vsb_cat(sb, "const char * VRT_r_bereq_proto(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_bereq_proto(struct sess *, const char *, ...);\n");
- vsb_cat(sb, "const char * VRT_r_obj_proto(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_proto(struct sess *, const char *, ...);\n");
- vsb_cat(sb, "int VRT_r_obj_status(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_status(struct sess *, int);\n");
- vsb_cat(sb, "const char * VRT_r_obj_response(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_response(struct sess *, const char *, ...);\n");
- vsb_cat(sb, "unsigned VRT_r_obj_valid(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_valid(struct sess *, unsigned);\n");
- vsb_cat(sb, "unsigned VRT_r_obj_cacheable(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_cacheable(struct sess *, unsigned);\n");
- vsb_cat(sb, "double VRT_r_obj_ttl(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_ttl(struct sess *, double);\n");
- vsb_cat(sb, "double VRT_r_obj_lastuse(struct sess *);\n");
- vsb_cat(sb, "const char * VRT_r_resp_proto(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_resp_proto(struct sess *, const char *, ...);\n");
- vsb_cat(sb, "int VRT_r_resp_status(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_resp_status(struct sess *, int);\n");
- vsb_cat(sb, "const char * VRT_r_resp_response(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_resp_response(struct sess *, const char *, ...);\n");
- vsb_cat(sb, "double VRT_r_now(struct sess *);\n");
- vsb_cat(sb, "int VRT_r_backend_health(struct sess *);\n");
+ vsb_cat(sb, "const char * VRT_r_bereq_request(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_bereq_request(const struct sess *, const char *, ...);\n");
+ vsb_cat(sb, "const char * VRT_r_bereq_url(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_bereq_url(const struct sess *, const char *, ...);\n");
+ vsb_cat(sb, "const char * VRT_r_bereq_proto(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_bereq_proto(const struct sess *, const char *, ...);\n");
+ vsb_cat(sb, "const char * VRT_r_obj_proto(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_obj_proto(const struct sess *, const char *, ...);\n");
+ vsb_cat(sb, "int VRT_r_obj_status(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_obj_status(const struct sess *, int);\n");
+ vsb_cat(sb, "const char * VRT_r_obj_response(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_obj_response(const struct sess *, const char *, ...);\n");
+ vsb_cat(sb, "unsigned VRT_r_obj_valid(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_obj_valid(const struct sess *, unsigned);\n");
+ vsb_cat(sb, "unsigned VRT_r_obj_cacheable(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_obj_cacheable(const struct sess *, unsigned);\n");
+ vsb_cat(sb, "double VRT_r_obj_ttl(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_obj_ttl(const struct sess *, double);\n");
+ vsb_cat(sb, "double VRT_r_obj_lastuse(const struct sess *);\n");
+ vsb_cat(sb, "const char * VRT_r_resp_proto(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_resp_proto(const struct sess *, const char *, ...);\n");
+ vsb_cat(sb, "int VRT_r_resp_status(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_resp_status(const struct sess *, int);\n");
+ vsb_cat(sb, "const char * VRT_r_resp_response(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_resp_response(const struct sess *, const char *, ...);\n");
+ vsb_cat(sb, "double VRT_r_now(const struct sess *);\n");
+ vsb_cat(sb, "int VRT_r_backend_health(const struct sess *);\n");
}
Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2007-09-25 11:11:15 UTC (rev 2041)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2007-09-25 11:51:49 UTC (rev 2042)
@@ -32,10 +32,10 @@
# Objects available in backends
set beobj {
- { backend.host WO HOSTNAME {} }
- { backend.port WO PORTNAME {} }
- { backend.dnsttl WO TIME {} }
- { backend.set WO SET {} }
+ { backend.host WO HOSTNAME {} "struct backend *"}
+ { backend.port WO PORTNAME {} "struct backend *"}
+ { backend.dnsttl WO TIME {} "struct backend *"}
+ { backend.set WO SET {} "struct backend *"}
}
# Variables available in sessions
@@ -46,116 +46,138 @@
{ client.ip
RO IP
{recv pipe pass hash miss hit fetch deliver }
+ "const struct sess *"
}
{ client.bandwidth # Not implemented yet
NO
+ { }
+ "const struct sess *"
}
{ server.ip
RO IP
{recv pipe pass hash miss hit fetch deliver }
+ "struct sess *"
}
# Request paramters
{ req.request
RW STRING
{recv pipe pass hash miss hit fetch }
+ "const struct sess *"
}
{ req.url
RW STRING
{recv pipe pass hash miss hit fetch }
+ "const struct sess *"
}
{ req.proto
RW STRING
{recv pipe pass hash miss hit fetch }
+ "const struct sess *"
}
{ req.http.
- RW HEADER
+ RW HDR_REQ
{recv pipe pass hash miss hit fetch }
- HDR_REQ
+ "const struct sess *"
}
# Possibly misnamed, not really part of the request
{ req.hash
WO HASH
{ hash }
+ "struct sess *"
}
{ req.backend
RW BACKEND
{recv pipe pass hash miss hit fetch }
+ "struct sess *"
}
# Request sent to backend
{ bereq.request
RW STRING
{ pipe pass miss }
+ "const struct sess *"
}
{ bereq.url
RW STRING
{ pipe pass miss }
+ "const struct sess *"
}
{ bereq.proto
RW STRING
{ pipe pass miss }
+ "const struct sess *"
}
{ bereq.http.
- RW HEADER
+ RW HDR_BEREQ
{ pipe pass miss }
- HDR_BEREQ
+ "const struct sess *"
}
# The (possibly) cached object
{ obj.proto
RW STRING
{ hit fetch }
+ "const struct sess *"
}
{ obj.status
RW INT
{ fetch }
+ "const struct sess *"
}
{ obj.response
RW STRING
{ fetch }
+ "const struct sess *"
}
{ obj.http.
- RW HEADER
+ RW HDR_OBJ
{ hit fetch }
- HDR_OBJ
+ "const struct sess *"
}
{ obj.valid
RW BOOL
{ hit fetch discard timeout}
+ "const struct sess *"
}
{ obj.cacheable
RW BOOL
{ hit fetch discard timeout}
+ "const struct sess *"
}
{ obj.ttl
RW TIME
{ hit fetch discard timeout}
+ "const struct sess *"
}
{ obj.lastuse
RO TIME
{ hit fetch deliver discard timeout}
+ "const struct sess *"
}
# The response we send back
{ resp.proto
RW STRING
{ deliver }
+ "const struct sess *"
}
{ resp.status
RW INT
{ deliver }
+ "const struct sess *"
}
{ resp.response
RW STRING
{ deliver }
+ "const struct sess *"
}
{ resp.http.
- RW HEADER
+ RW HDR_RESP
{ deliver }
- HDR_RESP
+ "const struct sess *"
}
# Miscellaneous
@@ -164,24 +186,29 @@
{ now
RO TIME
{recv pipe pass hash miss hit fetch deliver discard timeout}
+ "const struct sess *"
}
{ backend.health RO INT
{recv pipe pass hash miss hit fetch deliver discard timeout}
+ "const struct sess *"
}
}
-set tt(IP) "struct sockaddr *"
-set tt(STRING) "const char *"
-set tt(BOOL) "unsigned"
-set tt(BACKEND) "struct backend *"
-set tt(TIME) "double"
-set tt(INT) "int"
-set tt(HEADER) "const char *"
-set tt(HOSTNAME) "const char *"
-set tt(PORTNAME) "const char *"
-set tt(HASH) "const char *"
-set tt(SET) "struct vrt_backend_entry *"
+set tt(IP) "struct sockaddr *"
+set tt(STRING) "const char *"
+set tt(BOOL) "unsigned"
+set tt(BACKEND) "struct backend *"
+set tt(TIME) "double"
+set tt(INT) "int"
+set tt(HDR_RESP) "const char *"
+set tt(HDR_OBJ) "const char *"
+set tt(HDR_REQ) "const char *"
+set tt(HDR_BEREQ) "const char *"
+set tt(HOSTNAME) "const char *"
+set tt(PORTNAME) "const char *"
+set tt(HASH) "const char *"
+set tt(SET) "struct vrt_backend_entry *"
#----------------------------------------------------------------------
# Boilerplate warning for all generated files.
@@ -216,7 +243,7 @@
return [string range $l 3 end]
}
-proc vars {v ty pa} {
+proc vars {v pa} {
global tt fo fp
regsub -all "#\[^\n\]*\n" $v "" v
@@ -226,10 +253,15 @@
set a [lindex $v 1]
if {$a == "NO"} continue
set t [lindex $v 2]
- puts $fo "\t\{ \"$n\", $t, [string length $n],"
+ set ty [lindex $v 4]
+ if {[regexp HDR_ $t]} {
+ puts $fo "\t\{ \"$n\", HEADER, [string length $n],"
+ } else {
+ puts $fo "\t\{ \"$n\", $t, [string length $n],"
+ }
if {$a == "RO" || $a == "RW"} {
puts $fo "\t \"VRT_r_${m}($pa)\","
- if {$t != "HEADER"} {
+ if {![regexp HDR_ $t]} {
puts $fp "$tt($t) VRT_r_${m}($ty);"
}
} else {
@@ -237,7 +269,7 @@
}
if {$a == "WO" || $a == "RW"} {
puts $fo "\t \"VRT_l_${m}($pa, \","
- if {$t == "HEADER"} {
+ if {[regexp HDR_ $t]} {
} elseif {$t == "STRING"} {
puts $fp "void VRT_l_${m}($ty, $tt($t), ...);"
} else {
@@ -247,10 +279,10 @@
puts $fo "\t NULL,"
}
puts $fo "\t V_$a,"
- if {$t != "HEADER"} {
+ if {![regexp HDR_ $t]} {
puts $fo "\t 0,"
} else {
- puts $fo "\t \"[lindex $v 4]\","
+ puts $fo "\t \"$t\","
}
puts $fo "\t [method_map [lindex $v 3]]"
puts $fo "\t\},"
@@ -264,13 +296,13 @@
puts $fo ""
puts $fo "struct var vcc_be_vars\[\] = {"
-vars $beobj "struct backend *" "backend"
+vars $beobj "backend"
puts $fo "};"
puts $fo ""
puts $fo "struct var vcc_vars\[\] = {"
-vars $spobj "struct sess *" "sp"
+vars $spobj "sp"
puts $fo "};"
close $fp
From phk at projects.linpro.no Tue Sep 25 13:19:07 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Tue, 25 Sep 2007 15:19:07 +0200 (CEST)
Subject: r2043 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070925131907.A3E931EC2AE@projects.linpro.no>
Author: phk
Date: 2007-09-25 15:19:07 +0200 (Tue, 25 Sep 2007)
New Revision: 2043
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_acceptor.c
trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c
trunk/varnish-cache/bin/varnishd/cache_backend_random.c
trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_http.c
trunk/varnish-cache/bin/varnishd/cache_pool.c
trunk/varnish-cache/bin/varnishd/flint.lnt
trunk/varnish-cache/bin/varnishd/heritage.h
trunk/varnish-cache/bin/varnishd/mgt_event.c
trunk/varnish-cache/bin/varnishd/mgt_vcc.c
trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
More flexelint nit-picking of various sorts
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 11:51:49 UTC (rev 2042)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 13:19:07 UTC (rev 2043)
@@ -161,8 +161,8 @@
int *wfd;
unsigned werr; /* valid after WRK_Flush() */
struct iovec iov[MAX_IOVS];
- unsigned niov;
- size_t liov;
+ int niov;
+ ssize_t liov;
struct VCL_conf *vcl;
struct srcaddr *srcaddr;
@@ -446,7 +446,7 @@
void HSH_Init(void);
/* cache_http.c */
-const char *http_StatusMessage(int);
+const char *http_StatusMessage(unsigned);
void HTTP_Init(void);
void http_ClrHeader(struct http *to);
unsigned http_Write(struct worker *w, const struct http *hp, int resp);
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-09-25 11:51:49 UTC (rev 2042)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-09-25 13:19:07 UTC (rev 2043)
@@ -135,9 +135,10 @@
socklen_t l;
struct sockaddr_storage addr_s;
struct sockaddr *addr;
- int i, j;
+ int i;
struct pollfd *pfd;
struct listen_sock *ls;
+ unsigned u;
(void)arg;
@@ -171,16 +172,16 @@
&tv_rcvtimeo, sizeof tv_rcvtimeo));
}
i = poll(pfd, heritage.nsocks, 1000);
- for (j = 0; j < heritage.nsocks; j++) {
- if (pfd[j].revents == 0)
+ for (u = 0; u < heritage.nsocks; u++) {
+ if (pfd[u].revents == 0)
continue;
VSL_stats->client_conn++;
l = sizeof addr_s;
addr = (void*)&addr_s;
- i = accept(pfd[j].fd, addr, &l);
+ i = accept(pfd[u].fd, addr, &l);
if (i < 0) {
if (errno != EAGAIN) {
- VSL(SLT_Debug, pfd[j].fd,
+ VSL(SLT_Debug, pfd[u].fd,
"Accept failed errno=%d", errno);
/* XXX: stats ? */
}
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2007-09-25 11:51:49 UTC (rev 2042)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c 2007-09-25 13:19:07 UTC (rev 2043)
@@ -56,7 +56,7 @@
/*--------------------------------------------------------------------*/
static void
-vca_pollspace(int fd)
+vca_pollspace(unsigned fd)
{
struct pollfd *p;
unsigned u, v;
@@ -82,7 +82,9 @@
static void
vca_poll(int fd)
{
- vca_pollspace(fd);
+
+ assert(fd >= 0);
+ vca_pollspace((unsigned)fd);
pollfd[fd].fd = fd;
pollfd[fd].events = POLLIN;
}
@@ -90,7 +92,9 @@
static void
vca_unpoll(int fd)
{
- vca_pollspace(fd);
+
+ assert(fd >= 0);
+ vca_pollspace((unsigned)fd);
pollfd[fd].fd = -1;
pollfd[fd].events = 0;
}
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-25 11:51:49 UTC (rev 2042)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-25 13:19:07 UTC (rev 2043)
@@ -299,7 +299,7 @@
for (n = 1; n < 5; n++) {
vc = ber_nextfd(sp);
if (vc == NULL) {
- usleep(100000 * n);
+ AZ(usleep(100000 * n));
continue;
}
assert(vc->fd >= 0);
@@ -371,7 +371,7 @@
break;
VTAILQ_REMOVE(&bs->connlist, vbe, list);
if (vbe->fd >= 0)
- close(vbe->fd);
+ AZ(close(vbe->fd));
free(vbe);
}
bstmp = bs;
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-25 11:51:49 UTC (rev 2042)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-25 13:19:07 UTC (rev 2043)
@@ -284,7 +284,7 @@
for (n = 1; n < 5; n++) {
vc = brr_nextfd(sp);
if (vc == NULL) {
- usleep(100000 * n);
+ AZ(usleep(100000 * n));
continue;
}
assert(vc->fd >= 0);
@@ -356,7 +356,7 @@
break;
VTAILQ_REMOVE(&bs->connlist, vbe, list);
if (vbe->fd >= 0)
- close(vbe->fd);
+ AZ(close(vbe->fd));
free(vbe);
}
bstmp = bs;
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-25 11:51:49 UTC (rev 2042)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-25 13:19:07 UTC (rev 2043)
@@ -53,13 +53,17 @@
{
int i;
unsigned char *p;
- off_t cl;
+ uintmax_t cll;
+ unsigned cl;
struct storage *st;
- cl = strtoumax(b, NULL, 0);
- if (cl == 0)
+ cll = strtoumax(b, NULL, 0);
+ if (cll == 0)
return (0);
+ cl = (unsigned)cll;
+ assert((uintmax_t)cl == cll); /* Protect against bogusly large values */
+
st = STV_alloc(sp, cl);
VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
st->len = cl;
@@ -89,7 +93,7 @@
int i;
char *q;
struct storage *st;
- unsigned u, v;
+ unsigned u, v, w;
char buf[20]; /* XXX: arbitrary */
char *bp, *be;
@@ -157,17 +161,16 @@
v = u;
/* Handle anything left in our buffer first */
- i = pdiff(q, bp);
- assert(i >= 0);
- if (i > v)
- i = v;
- if (i != 0) {
- memcpy(st->ptr + st->len, q, i);
- st->len += i;
- sp->obj->len += i;
- u -= i;
- v -= i;
- q += i;
+ w = pdiff(q, bp);
+ if (w > v)
+ w = v;
+ if (w != 0) {
+ memcpy(st->ptr + st->len, q, w);
+ st->len += w;
+ sp->obj->len += w;
+ u -= w;
+ v -= w;
+ q += w;
}
if (u == 0)
break;
@@ -263,7 +266,8 @@
struct http *hp, *hp2;
struct storage *st;
struct bereq *bereq;
- int len, mklen, is_head;
+ int mklen, is_head;
+ unsigned len;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 11:51:49 UTC (rev 2042)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 13:19:07 UTC (rev 2043)
@@ -89,7 +89,7 @@
}
static void
-WSLH(struct worker *w, enum httptag t, int fd, const struct http *hp, int hdr)
+WSLH(struct worker *w, enum httptag t, int fd, const struct http *hp, unsigned hdr)
{
WSLR(w, http2shmlog(hp, t), fd, hp->hd[hdr].b, hp->hd[hdr].e);
@@ -146,7 +146,7 @@
};
const char *
-http_StatusMessage(int status)
+http_StatusMessage(unsigned status)
{
struct http_msg *mp;
@@ -237,7 +237,7 @@
http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr)
{
char *h;
- int fl;
+ unsigned fl;
if (!http_GetHdr(hp, hdr, &h))
return (0);
@@ -273,7 +273,6 @@
{
struct http *hp = sp->http;
char *p, *q;
- int i;
unsigned u;
if (!http_GetHdr(hp, H_Connection, &p)) {
@@ -289,10 +288,10 @@
for (q = p + 1; *q; q++)
if (*q == ',' || isspace(*q))
break;
- i = pdiff(p, q);
- if (i == 5 && !strncasecmp(p, "close", i))
+ u = pdiff(p, q);
+ if (u == 5 && !strncasecmp(p, "close", u))
sp->doclose = "Connection: close";
- u = http_findhdr(hp, i, p);
+ u = http_findhdr(hp, u, p);
if (u != 0)
hp->hdf[u] |= HDF_FILTER;
if (!*q)
@@ -346,7 +345,7 @@
http_Read(struct http *hp, int fd, void *p, unsigned len)
{
int i;
- int u;
+ unsigned u;
char *b = p;
u = 0;
@@ -363,7 +362,7 @@
hp->pl_s = hp->pl_e = NULL;
if (len > 0) {
i = read(fd, b, len);
- if (i < 0)
+ if (i < 0) /* XXX i == 0 ?? */
return (i);
u += i;
}
@@ -904,7 +903,7 @@
http_PutField(struct worker *w, int fd, struct http *to, int field, const char *string)
{
char *p;
- int l;
+ unsigned l;
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
l = strlen(string);
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-25 11:51:49 UTC (rev 2042)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-25 13:19:07 UTC (rev 2043)
@@ -94,7 +94,7 @@
unsigned
WRK_Flush(struct worker *w)
{
- int i;
+ ssize_t i;
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
if (*w->wfd < 0 || w->niov == 0 || w->werr)
@@ -133,7 +133,7 @@
if (len == -1)
len = strlen(ptr);
if (w->niov == MAX_IOVS)
- WRK_Flush(w);
+ (void)WRK_Flush(w);
w->iov[w->niov].iov_base = (void*)(uintptr_t)ptr;
w->iov[w->niov].iov_len = len;
w->liov += len;
@@ -394,7 +394,7 @@
(void)priv;
while (1) {
wrk_addpools(params->wthread_pools);
- sleep(1);
+ AZ(sleep(1));
if (VSL_stats->n_wrk <= params->wthread_min)
continue;
now = TIM_real();
@@ -415,7 +415,6 @@
assert(1 == write(w->pipe[1], w, 1));
}
}
- INCOMPL();
}
/*--------------------------------------------------------------------*/
Modified: trunk/varnish-cache/bin/varnishd/flint.lnt
===================================================================
--- trunk/varnish-cache/bin/varnishd/flint.lnt 2007-09-25 11:51:49 UTC (rev 2042)
+++ trunk/varnish-cache/bin/varnishd/flint.lnt 2007-09-25 13:19:07 UTC (rev 2043)
@@ -32,6 +32,7 @@
-emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types)
-emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small)
-emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small)
+-emacro(506, VTAILQ_FOREACH_SAFE) // constant value boolean
-esym(534, sprintf) // Ignoring return value of function
-esym(534, asprintf) // Ignoring return value of function
Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h 2007-09-25 11:51:49 UTC (rev 2042)
+++ trunk/varnish-cache/bin/varnishd/heritage.h 2007-09-25 13:19:07 UTC (rev 2043)
@@ -53,7 +53,7 @@
/* Sockets from which to accept connections */
struct listen_sock_head socks;
- int nsocks;
+ unsigned nsocks;
/* Share memory log fd and size (incl header) */
int vsl_fd;
Modified: trunk/varnish-cache/bin/varnishd/mgt_event.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_event.c 2007-09-25 11:51:49 UTC (rev 2042)
+++ trunk/varnish-cache/bin/varnishd/mgt_event.c 2007-09-25 13:19:07 UTC (rev 2043)
@@ -55,7 +55,7 @@
};
static struct evsig *ev_sigs;
-static unsigned ev_nsig;
+static int ev_nsig;
struct evbase {
unsigned magic;
Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-09-25 11:51:49 UTC (rev 2042)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-09-25 13:19:07 UTC (rev 2043)
@@ -297,7 +297,7 @@
csrc = VCC_Compile(sb, b, e);
if (csrc != NULL) {
if (C_flag)
- fputs(csrc, stdout);
+ (void)fputs(csrc, stdout);
vf = mgt_CallCc(csrc, sb);
if (C_flag && vf != NULL)
AZ(unlink(vf));
@@ -500,7 +500,7 @@
free(p);
return;
}
- mgt_vcc_add(av[2], vf);
+ (void)mgt_vcc_add(av[2], vf);
}
void
@@ -531,7 +531,7 @@
free(p);
return;
}
- mgt_vcc_add(av[2], vf);
+ (void)mgt_vcc_add(av[2], vf);
}
static struct vclprog *
Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c 2007-09-25 11:51:49 UTC (rev 2042)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c 2007-09-25 13:19:07 UTC (rev 2043)
@@ -79,9 +79,9 @@
static int
cmp_hash(const struct hash_slinger *s, const char *p, const char *q)
{
- if (strlen(s->name) != q - p)
+ if (strlen(s->name) != (q - p))
return (1);
- if (strncmp(s->name, p, q - p))
+ if (strncmp(s->name, p, (q - p)))
return (1);
return (0);
}
@@ -288,7 +288,7 @@
/* close the rest */
for (i = 5; i < getdtablesize(); i++)
- close(i);
+ (void)close(i);
pfd[0].fd = pipes[0][0];
pfd[0].events = POLLIN;
From phk at projects.linpro.no Wed Sep 26 18:56:18 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Wed, 26 Sep 2007 20:56:18 +0200 (CEST)
Subject: r2044 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070926185618.74E1E1EC2B5@projects.linpro.no>
Author: phk
Date: 2007-09-26 20:56:18 +0200 (Wed, 26 Sep 2007)
New Revision: 2044
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_http.c
trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
struct http_hdr is more than that, it is a general text handle, so
typedef it as "txt" instead.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-25 13:19:07 UTC (rev 2043)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-26 18:56:18 UTC (rev 2044)
@@ -102,10 +102,10 @@
* HTTP Request/Response/Header handling structure.
*/
-struct http_hdr {
+typedef struct {
char *b;
char *e;
-};
+} txt;
enum httpwhence {
HTTP_Rx,
@@ -124,7 +124,7 @@
unsigned char conds; /* If-* headers present */
enum httpwhence logtag;
- struct http_hdr hd[HTTP_HDR_MAX];
+ txt hd[HTTP_HDR_MAX];
unsigned char hdf[HTTP_HDR_MAX];
#define HDF_FILTER (1 << 0) /* Filtered by Connection */
unsigned nhd;
@@ -493,7 +493,7 @@
void WRK_Reset(struct worker *w, int *fd);
unsigned WRK_Flush(struct worker *w);
unsigned WRK_Write(struct worker *w, const void *ptr, int len);
-unsigned WRK_WriteH(struct worker *w, const struct http_hdr *hh, const char *suf);
+unsigned WRK_WriteH(struct worker *w, const txt *hh, const char *suf);
#ifdef HAVE_SENDFILE
void WRK_Sendfile(struct worker *w, int fd, off_t off, unsigned len);
#endif /* HAVE_SENDFILE */
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-25 13:19:07 UTC (rev 2043)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-26 18:56:18 UTC (rev 2044)
@@ -174,7 +174,7 @@
static int
-http_IsHdr(const struct http_hdr *hh, const char *hdr)
+http_IsHdr(const txt *hh, const char *hdr)
{
unsigned l;
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-25 13:19:07 UTC (rev 2043)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-26 18:56:18 UTC (rev 2044)
@@ -108,7 +108,7 @@
}
unsigned
-WRK_WriteH(struct worker *w, const struct http_hdr *hh, const char *suf)
+WRK_WriteH(struct worker *w, const txt *hh, const char *suf)
{
unsigned u;
From phk at projects.linpro.no Wed Sep 26 18:59:28 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Wed, 26 Sep 2007 20:59:28 +0200 (CEST)
Subject: r2045 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070926185928.734AA1EC2B2@projects.linpro.no>
Author: phk
Date: 2007-09-26 20:59:28 +0200 (Wed, 26 Sep 2007)
New Revision: 2045
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Convert the received request and pipelined bytes into txt's.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-26 18:56:18 UTC (rev 2044)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-26 18:59:28 UTC (rev 2045)
@@ -118,8 +118,8 @@
#define HTTP_MAGIC 0x6428b5c9
struct ws ws[1];
- char *rx_s, *rx_e; /* Received Request */
- char *pl_s, *pl_e; /* Pipelined bytes */
+ txt rx; /* Received Request */
+ txt pl; /* Pipelined bytes */
unsigned char conds; /* If-* headers present */
enum httpwhence logtag;
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-26 18:56:18 UTC (rev 2044)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-26 18:59:28 UTC (rev 2045)
@@ -229,7 +229,7 @@
sp->step = STP_RECV;
return (0);
}
- if (sp->http->pl_s < sp->http->pl_e) {
+ if (sp->http->pl.b < sp->http->pl.e) {
VSL_stats->sess_readahead++;
sp->step = STP_AGAIN;
return (0);
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-26 18:56:18 UTC (rev 2044)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-26 18:59:28 UTC (rev 2045)
@@ -326,7 +326,7 @@
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
/* Filter into object */
hp2 = &sp->obj->http;
- len = pdiff(hp->rx_s, hp->rx_e);
+ len = pdiff(hp->rx.b, hp->rx.e);
len += 256; /* margin for content-length etc */
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-26 18:56:18 UTC (rev 2044)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-26 18:59:28 UTC (rev 2045)
@@ -321,20 +321,20 @@
http_GetTail(struct http *hp, unsigned len, char **b, char **e)
{
- if (hp->pl_s >= hp->pl_e)
+ if (hp->pl.b >= hp->pl.e)
return (0);
if (len == 0)
- len = pdiff(hp->pl_s, hp->pl_e);
+ len = pdiff(hp->pl.b, hp->pl.e);
- if (hp->pl_s + len > hp->pl_e)
- len = pdiff(hp->pl_s, hp->pl_e);
+ if (hp->pl.b + len > hp->pl.e)
+ len = pdiff(hp->pl.b, hp->pl.e);
if (len == 0)
return (0);
- *b = hp->pl_s;
- *e = hp->pl_s + len;
- hp->pl_s += len;
- assert(hp->pl_s <= hp->pl_e);
+ *b = hp->pl.b;
+ *e = hp->pl.b + len;
+ hp->pl.b += len;
+ assert(hp->pl.b <= hp->pl.e);
return (1);
}
@@ -349,17 +349,17 @@
char *b = p;
u = 0;
- if (hp->pl_s < hp->pl_e) {
- u = pdiff(hp->pl_s, hp->pl_e);
+ if (hp->pl.b < hp->pl.e) {
+ u = pdiff(hp->pl.b, hp->pl.e);
if (u > len)
u = len;
- memcpy(b, hp->pl_s, u);
- hp->pl_s += u;
+ memcpy(b, hp->pl.b, u);
+ hp->pl.b += u;
b += u;
len -= u;
}
- if (hp->pl_e == hp->pl_s)
- hp->pl_s = hp->pl_e = NULL;
+ if (hp->pl.e == hp->pl.b)
+ hp->pl.b = hp->pl.e = NULL;
if (len > 0) {
i = read(fd, b, len);
if (i < 0) /* XXX i == 0 ?? */
@@ -410,8 +410,8 @@
hp->nhd = HTTP_HDR_FIRST;
hp->conds = 0;
r = NULL; /* For FlexeLint */
- assert(p < hp->rx_e); /* http_header_complete() guarantees this */
- for (; p < hp->rx_e; p = r) {
+ assert(p < hp->rx.e); /* http_header_complete() guarantees this */
+ for (; p < hp->rx.e; p = r) {
/* XXX: handle continuation lines */
q = strchr(p, '\n');
assert(q != NULL);
@@ -449,11 +449,11 @@
char *p;
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- /* Assert a NUL at rx_e */
- assert(hp->rx_s < hp->rx_e);
+ /* Assert a NUL at rx.e */
+ assert(hp->rx.b < hp->rx.e);
hp->logtag = HTTP_Rx;
- for (p = hp->rx_s ; isspace(*p); p++)
+ for (p = hp->rx.b ; isspace(*p); p++)
continue;
/* First, the request type (GET/HEAD etc) */
@@ -468,7 +468,7 @@
while (isspace(*p) && *p != '\n')
p++;
if (*p == '\n') {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx_s, hp->rx_e);
+ WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
return (400);
}
hp->hd[HTTP_HDR_URL].b = p;
@@ -477,7 +477,7 @@
hp->hd[HTTP_HDR_URL].e = p;
WSLH(w, HTTP_T_URL, fd, hp, HTTP_HDR_URL);
if (*p == '\n') {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx_s, hp->rx_e);
+ WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
return (400);
}
*p++ = '\0';
@@ -486,7 +486,7 @@
while (isspace(*p) && *p != '\n')
p++;
if (*p == '\n') {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx_s, hp->rx_e);
+ WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
return (400);
}
hp->hd[HTTP_HDR_PROTO].b = p;
@@ -499,7 +499,7 @@
while (isspace(*p) && *p != '\n')
p++;
if (*p != '\n') {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx_s, hp->rx_e);
+ WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
return (400);
}
*p++ = '\0';
@@ -515,15 +515,15 @@
char *p, *q;
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- /* Assert a NUL at rx_e */
- assert(hp->rx_s < hp->rx_e);
+ /* Assert a NUL at rx.e */
+ assert(hp->rx.b < hp->rx.e);
hp->logtag = HTTP_Rx;
- for (p = hp->rx_s ; isspace(*p); p++)
+ for (p = hp->rx.b ; isspace(*p); p++)
continue;
if (memcmp(p, "HTTP/1.", 7)) {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx_s, hp->rx_e);
+ WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
return (400);
}
/* First, protocol */
@@ -571,12 +571,12 @@
char *p;
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- assert(*hp->rx_e == '\0');
+ assert(*hp->rx.e == '\0');
/* Skip any leading white space */
- for (p = hp->rx_s ; p < hp->rx_e && isspace(*p); p++)
+ for (p = hp->rx.b ; p < hp->rx.e && isspace(*p); p++)
continue;
- if (p >= hp->rx_e) {
- hp->rx_e = hp->rx_s;
+ if (p >= hp->rx.e) {
+ hp->rx.e = hp->rx.b;
return (0);
}
while (1) {
@@ -591,11 +591,11 @@
break;
}
p++;
- WS_ReleaseP(hp->ws, hp->rx_e);
- if (p != hp->rx_e) {
- hp->pl_s = p;
- hp->pl_e = hp->rx_e;
- hp->rx_e = p;
+ WS_ReleaseP(hp->ws, hp->rx.e);
+ if (p != hp->rx.e) {
+ hp->pl.b = p;
+ hp->pl.e = hp->rx.e;
+ hp->rx.e = p;
}
/* XXX: Check this stuff... */
return (1);
@@ -612,22 +612,22 @@
WS_Assert(hp->ws);
WS_Reset(hp->ws);
WS_Reserve(hp->ws, 0);
- hp->rx_s = hp->ws->f;
- hp->rx_e = hp->rx_s;
- if (hp->pl_s != NULL) {
- l = pdiff(hp->pl_s, hp->pl_e);
- memmove(hp->rx_s, hp->pl_s, l);
- hp->rx_e = hp->rx_s + l;
- hp->pl_s = hp->pl_e = NULL;
+ hp->rx.b = hp->ws->f;
+ hp->rx.e = hp->rx.b;
+ if (hp->pl.b != NULL) {
+ l = pdiff(hp->pl.b, hp->pl.e);
+ memmove(hp->rx.b, hp->pl.b, l);
+ hp->rx.e = hp->rx.b + l;
+ hp->pl.b = hp->pl.e = NULL;
}
- *hp->rx_e = '\0';
+ *hp->rx.e = '\0';
}
int
http_RecvPrepAgain(struct http *hp)
{
http_RecvPrep(hp);
- if (hp->rx_s == hp->rx_e)
+ if (hp->rx.b == hp->rx.e)
return (0);
return (http_header_complete(hp));
}
@@ -640,35 +640,35 @@
unsigned l;
int i;
- l = pdiff(hp->rx_e, hp->ws->e) - 1;
+ l = pdiff(hp->rx.e, hp->ws->e) - 1;
l /= 2; /* Don't fill all of workspace with read-ahead */
if (l <= 1) {
VSL(SLT_HttpError, fd, "Received too much");
- VSLR(SLT_HttpGarbage, fd, hp->rx_s, hp->rx_e);
- hp->rx_s = hp->rx_e = NULL;
+ VSLR(SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
+ hp->rx.b = hp->rx.e = NULL;
WS_Release(hp->ws, 0);
return (1);
}
errno = 0;
- i = read(fd, hp->rx_e, l - 1);
+ i = read(fd, hp->rx.e, l - 1);
if (i > 0) {
- hp->rx_e += i;
- *hp->rx_e = '\0';
+ hp->rx.e += i;
+ *hp->rx.e = '\0';
if (http_header_complete(hp))
return(0);
return (-1);
}
- if (hp->rx_e != hp->rx_s) {
+ if (hp->rx.e != hp->rx.b) {
VSL(SLT_HttpError, fd,
"Received (only) %d bytes, errno %d",
- hp->rx_e - hp->rx_s, errno);
- VSLR(SLT_Debug, fd, hp->rx_s, hp->rx_e);
+ hp->rx.e - hp->rx.b, errno);
+ VSLR(SLT_Debug, fd, hp->rx.b, hp->rx.e);
} else if (errno == 0)
VSL(SLT_HttpError, fd, "Received nothing");
else
VSL(SLT_HttpError, fd, "Received errno %d", errno);
- hp->rx_s = hp->rx_e = NULL;
+ hp->rx.b = hp->rx.e = NULL;
WS_Release(hp->ws, 0);
return(2);
}
From phk at projects.linpro.no Wed Sep 26 19:15:25 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Wed, 26 Sep 2007 21:15:25 +0200 (CEST)
Subject: r2046 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070926191525.E9B321EC1D1@projects.linpro.no>
Author: phk
Date: 2007-09-26 21:15:25 +0200 (Wed, 26 Sep 2007)
New Revision: 2046
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_http.c
trunk/varnish-cache/bin/varnishd/shmlog.c
Log:
Use the new txt type more extensively, it does improve readability a bit.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-26 18:59:28 UTC (rev 2045)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-26 19:15:25 UTC (rev 2046)
@@ -509,9 +509,9 @@
void VSL_Init(void);
#ifdef SHMLOGHEAD_MAGIC
-void VSLR(enum shmlogtag tag, int id, const char *b, const char *e);
+void VSLR(enum shmlogtag tag, int id, txt t);
void VSL(enum shmlogtag tag, int id, const char *fmt, ...);
-void WSLR(struct worker *w, enum shmlogtag tag, int id, const char *b, const char *e);
+void WSLR(struct worker *w, enum shmlogtag tag, int id, txt t);
void WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...);
void WSL_Flush(struct worker *w);
#define INCOMPL() do { \
@@ -602,3 +602,25 @@
return
((unsigned)((const unsigned char *)e - (const unsigned char *)b));
}
+
+static inline void
+Tcheck(const txt t)
+{
+
+ AN(t.b);
+ AN(t.e);
+ assert(t.b <= t.e);
+}
+
+/*
+ * unsigned length of a txt
+ */
+
+static inline unsigned
+Tlen(const txt t)
+{
+
+ Tcheck(t);
+ return
+ ((unsigned)(t.e - t.b));
+}
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-26 18:59:28 UTC (rev 2045)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-26 19:15:25 UTC (rev 2046)
@@ -92,7 +92,7 @@
WSLH(struct worker *w, enum httptag t, int fd, const struct http *hp, unsigned hdr)
{
- WSLR(w, http2shmlog(hp, t), fd, hp->hd[hdr].b, hp->hd[hdr].e);
+ WSLR(w, http2shmlog(hp, t), fd, hp->hd[hdr]);
}
/*--------------------------------------------------------------------*/
@@ -325,16 +325,16 @@
return (0);
if (len == 0)
- len = pdiff(hp->pl.b, hp->pl.e);
+ len = Tlen(hp->pl);
if (hp->pl.b + len > hp->pl.e)
- len = pdiff(hp->pl.b, hp->pl.e);
+ len = Tlen(hp->pl);
if (len == 0)
return (0);
*b = hp->pl.b;
*e = hp->pl.b + len;
hp->pl.b += len;
- assert(hp->pl.b <= hp->pl.e);
+ Tcheck(hp->pl);
return (1);
}
@@ -350,7 +350,7 @@
u = 0;
if (hp->pl.b < hp->pl.e) {
- u = pdiff(hp->pl.b, hp->pl.e);
+ u = Tlen(hp->pl);
if (u > len)
u = len;
memcpy(b, hp->pl.b, u);
@@ -435,7 +435,7 @@
hp->nhd++;
} else {
VSL_stats->losthdr++;
- WSLR(w, SLT_LostHeader, fd, p, q);
+ WSL(w, SLT_LostHeader, fd, "%.*s", q - p, p);
}
}
return (0);
@@ -450,7 +450,7 @@
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
/* Assert a NUL at rx.e */
- assert(hp->rx.b < hp->rx.e);
+ Tcheck(hp->rx);
hp->logtag = HTTP_Rx;
for (p = hp->rx.b ; isspace(*p); p++)
@@ -468,7 +468,7 @@
while (isspace(*p) && *p != '\n')
p++;
if (*p == '\n') {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
+ WSLR(w, SLT_HttpGarbage, fd, hp->rx);
return (400);
}
hp->hd[HTTP_HDR_URL].b = p;
@@ -477,7 +477,7 @@
hp->hd[HTTP_HDR_URL].e = p;
WSLH(w, HTTP_T_URL, fd, hp, HTTP_HDR_URL);
if (*p == '\n') {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
+ WSLR(w, SLT_HttpGarbage, fd, hp->rx);
return (400);
}
*p++ = '\0';
@@ -486,7 +486,7 @@
while (isspace(*p) && *p != '\n')
p++;
if (*p == '\n') {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
+ WSLR(w, SLT_HttpGarbage, fd, hp->rx);
return (400);
}
hp->hd[HTTP_HDR_PROTO].b = p;
@@ -499,7 +499,7 @@
while (isspace(*p) && *p != '\n')
p++;
if (*p != '\n') {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
+ WSLR(w, SLT_HttpGarbage, fd, hp->rx);
return (400);
}
*p++ = '\0';
@@ -516,14 +516,14 @@
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
/* Assert a NUL at rx.e */
- assert(hp->rx.b < hp->rx.e);
+ Tcheck(hp->rx);
hp->logtag = HTTP_Rx;
for (p = hp->rx.b ; isspace(*p); p++)
continue;
if (memcmp(p, "HTTP/1.", 7)) {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
+ WSLR(w, SLT_HttpGarbage, fd, hp->rx);
return (400);
}
/* First, protocol */
@@ -615,7 +615,7 @@
hp->rx.b = hp->ws->f;
hp->rx.e = hp->rx.b;
if (hp->pl.b != NULL) {
- l = pdiff(hp->pl.b, hp->pl.e);
+ l = Tlen(hp->pl);
memmove(hp->rx.b, hp->pl.b, l);
hp->rx.e = hp->rx.b + l;
hp->pl.b = hp->pl.e = NULL;
@@ -644,7 +644,7 @@
l /= 2; /* Don't fill all of workspace with read-ahead */
if (l <= 1) {
VSL(SLT_HttpError, fd, "Received too much");
- VSLR(SLT_HttpGarbage, fd, hp->rx.b, hp->rx.e);
+ VSLR(SLT_HttpGarbage, fd, hp->rx);
hp->rx.b = hp->rx.e = NULL;
WS_Release(hp->ws, 0);
return (1);
@@ -663,7 +663,7 @@
VSL(SLT_HttpError, fd,
"Received (only) %d bytes, errno %d",
hp->rx.e - hp->rx.b, errno);
- VSLR(SLT_Debug, fd, hp->rx.b, hp->rx.e);
+ VSLR(SLT_Debug, fd, hp->rx);
} else if (errno == 0)
VSL(SLT_HttpError, fd, "Received nothing");
else
@@ -767,7 +767,7 @@
to->nhd++;
} else {
VSL_stats->losthdr++;
- WSLR(w, SLT_LostHeader, fd, fm->hd[n].b, fm->hd[n].e);
+ WSLR(w, SLT_LostHeader, fd, fm->hd[n]);
}
}
@@ -855,7 +855,7 @@
WSLH(w, htt, fd, hp, u);
continue;
}
- l = pdiff(hp->hd[u].b, hp->hd[u].e);
+ l = Tlen(hp->hd[u]);
p = WS_Alloc(hp->ws, l + 1);
if (p != NULL) {
WSLH(w, htt, fd, hp, u);
@@ -863,7 +863,7 @@
hp->hd[u].b = p;
hp->hd[u].e = p + l;
} else {
- WSLR(w, SLT_LostHeader, fd, hp->hd[u].b, hp->hd[u].e);
+ WSLR(w, SLT_LostHeader, fd, hp->hd[u]);
hp->hd[u].b = NULL;
hp->hd[u].e = NULL;
}
Modified: trunk/varnish-cache/bin/varnishd/shmlog.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/shmlog.c 2007-09-26 18:59:28 UTC (rev 2045)
+++ trunk/varnish-cache/bin/varnishd/shmlog.c 2007-09-26 19:15:25 UTC (rev 2046)
@@ -83,20 +83,18 @@
/*--------------------------------------------------------------------*/
void
-VSLR(enum shmlogtag tag, int id, const char *b, const char *e)
+VSLR(enum shmlogtag tag, int id, txt t)
{
unsigned char *p;
unsigned l;
- assert(b != NULL);
- if (e == NULL)
- e = strchr(b, '\0');
+ Tcheck(t);
/* Truncate */
- l = pdiff(b, e);
+ l = Tlen(t);
if (l > 255) {
l = 255;
- e = b + l;
+ t.e = t.b + l;
}
/* Only hold the lock while we find our space */
@@ -117,7 +115,7 @@
p[1] = l & 0xff;
p[2] = (id >> 8) & 0xff;
p[3] = id & 0xff;
- memcpy(p + 4, b, l);
+ memcpy(p + 4, t.b, l);
p[4 + l] = '\0';
/* XXX: memory barrier */
p[0] = tag;
@@ -131,12 +129,15 @@
va_list ap;
unsigned char *p;
unsigned n;
+ txt t;
AN(fmt);
va_start(ap, fmt);
if (strchr(fmt, '%') == NULL) {
- VSLR(tag, id, fmt, NULL);
+ t.b = (void*)(uintptr_t)fmt;
+ t.e = strchr(fmt, '\0');
+ VSLR(tag, id, t);
return;
}
@@ -200,20 +201,18 @@
/*--------------------------------------------------------------------*/
void
-WSLR(struct worker *w, enum shmlogtag tag, int id, const char *b, const char *e)
+WSLR(struct worker *w, enum shmlogtag tag, int id, txt t)
{
unsigned char *p;
unsigned l;
- assert(b != NULL);
- if (e == NULL)
- e = strchr(b, '\0');
+ Tcheck(t);
/* Truncate */
- l = pdiff(b, e);
+ l = Tlen(t);
if (l > 255) {
l = 255;
- e = b + l;
+ t.e = t.b + l;
}
assert(w->wlp < w->wle);
@@ -229,7 +228,7 @@
p[1] = l & 0xff;
p[2] = (id >> 8) & 0xff;
p[3] = id & 0xff;
- memcpy(p + 4, b, l);
+ memcpy(p + 4, t.b, l);
p[4 + l] = '\0';
p[0] = tag;
w->wlr++;
@@ -243,12 +242,15 @@
va_list ap;
unsigned char *p;
unsigned n;
+ txt t;
AN(fmt);
va_start(ap, fmt);
if (strchr(fmt, '%') == NULL) {
- WSLR(w, tag, id, fmt, NULL);
+ t.b = (void*)(uintptr_t)fmt;
+ t.e = strchr(fmt, '\0');
+ WSLR(w, tag, id, t);
return;
}
From phk at projects.linpro.no Wed Sep 26 19:20:18 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Wed, 26 Sep 2007 21:20:18 +0200 (CEST)
Subject: r2047 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070926192018.2ABF11EC2B5@projects.linpro.no>
Author: phk
Date: 2007-09-26 21:20:17 +0200 (Wed, 26 Sep 2007)
New Revision: 2047
Modified:
trunk/varnish-cache/bin/varnishd/cache_fetch.c
Log:
another place we can use Tlen
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-26 19:15:25 UTC (rev 2046)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-26 19:20:17 UTC (rev 2047)
@@ -326,7 +326,7 @@
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
/* Filter into object */
hp2 = &sp->obj->http;
- len = pdiff(hp->rx.b, hp->rx.e);
+ len = Tlen(hp->rx);
len += 256; /* margin for content-length etc */
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
From phk at projects.linpro.no Wed Sep 26 19:38:04 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Wed, 26 Sep 2007 21:38:04 +0200 (CEST)
Subject: r2048 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070926193804.AD8541EC2B2@projects.linpro.no>
Author: phk
Date: 2007-09-26 21:38:04 +0200 (Wed, 26 Sep 2007)
New Revision: 2048
Modified:
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
More txt'ing
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-26 19:20:17 UTC (rev 2047)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-26 19:38:04 UTC (rev 2048)
@@ -178,8 +178,7 @@
{
unsigned l;
- AN(hh->b);
- AN(hh->e);
+ Tcheck(*hh);
AN(hdr);
l = hdr[0];
assert(l == strlen(hdr + 1));
@@ -196,8 +195,7 @@
unsigned u;
for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) {
- AN(hp->hd[u].b);
- AN(hp->hd[u].e);
+ Tcheck(hp->hd[u]);
if (hp->hd[u].e < hp->hd[u].b + l + 1)
continue;
if (hp->hd[u].b[l] != ':')
@@ -375,7 +373,7 @@
http_GetStatus(const struct http *hp)
{
- AN(hp->hd[HTTP_HDR_STATUS].b);
+ Tcheck(hp->hd[HTTP_HDR_STATUS]);
return (strtoul(hp->hd[HTTP_HDR_STATUS].b,
NULL /* XXX */, 10));
}
@@ -383,14 +381,16 @@
const char *
http_GetProto(const struct http *hp)
{
- AN(hp->hd[HTTP_HDR_PROTO].b);
+
+ Tcheck(hp->hd[HTTP_HDR_PROTO]);
return (hp->hd[HTTP_HDR_PROTO].b);
}
const char *
http_GetReq(const struct http *hp)
{
- AN(hp->hd[HTTP_HDR_REQ].b);
+
+ Tcheck(hp->hd[HTTP_HDR_REQ]);
return (hp->hd[HTTP_HDR_REQ].b);
}
@@ -626,6 +626,7 @@
int
http_RecvPrepAgain(struct http *hp)
{
+
http_RecvPrep(hp);
if (hp->rx.b == hp->rx.e)
return (0);
@@ -706,9 +707,8 @@
{
assert(n < HTTP_HDR_MAX);
- AN(fm->hd[n].b);
- to->hd[n].b = fm->hd[n].b;
- to->hd[n].e = fm->hd[n].e;
+ Tcheck(fm->hd[n]);
+ to->hd[n] = fm->hd[n];
to->hdf[n] = fm->hdf[n];
}
@@ -760,10 +760,9 @@
CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
assert(n < HTTP_HDR_MAX);
- AN(fm->hd[n].b);
+ Tcheck(fm->hd[n]);
if (to->nhd < HTTP_HDR_MAX) {
- to->hd[to->nhd].b = fm->hd[n].b;
- to->hd[to->nhd].e = fm->hd[n].e;
+ to->hd[to->nhd] = fm->hd[n];
to->nhd++;
} else {
VSL_stats->losthdr++;
From phk at projects.linpro.no Wed Sep 26 19:43:56 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Wed, 26 Sep 2007 21:43:56 +0200 (CEST)
Subject: r2049 - trunk/varnish-cache/lib/libvcl
Message-ID: <20070926194356.9B5C11EC2B2@projects.linpro.no>
Author: phk
Date: 2007-09-26 21:43:56 +0200 (Wed, 26 Sep 2007)
New Revision: 2049
Modified:
trunk/varnish-cache/lib/libvcl/vcc_acl.c
Log:
don't make acl's const, they are not.
Reported by: Martin Aspeli
Modified: trunk/varnish-cache/lib/libvcl/vcc_acl.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_acl.c 2007-09-26 19:38:04 UTC (rev 2048)
+++ trunk/varnish-cache/lib/libvcl/vcc_acl.c 2007-09-26 19:43:56 UTC (rev 2049)
@@ -42,7 +42,7 @@
vcc_acl_top(struct tokenlist *tl, const char *acln)
{
- Fh(tl, 1, "\nstatic const struct vrt_acl acl_%s[] = {\n", acln);
+ Fh(tl, 1, "\nstatic struct vrt_acl acl_%s[] = {\n", acln);
tl->hindent += INDENT;
}
From des at projects.linpro.no Thu Sep 27 10:08:31 2007
From: des at projects.linpro.no (des at projects.linpro.no)
Date: Thu, 27 Sep 2007 12:08:31 +0200 (CEST)
Subject: r2050 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070927100831.3DA7C1EC1D1@projects.linpro.no>
Author: des
Date: 2007-09-27 12:08:30 +0200 (Thu, 27 Sep 2007)
New Revision: 2050
Modified:
trunk/varnish-cache/bin/varnishd/cache_expire.c
Log:
Use CHECK_OBJ_ORNULL().
Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-09-26 19:43:56 UTC (rev 2049)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2007-09-27 10:08:30 UTC (rev 2050)
@@ -181,8 +181,7 @@
while (1) {
LOCK(&exp_mtx);
o = binheap_root(exp_heap);
- if (o != NULL)
- CHECK_OBJ(o, OBJECT_MAGIC);
+ CHECK_OBJ_ORNULL(o, OBJECT_MAGIC);
if (o == NULL || o->ttl > t + expearly) {
UNLOCK(&exp_mtx);
AZ(sleep(1));
From phk at projects.linpro.no Fri Sep 28 10:29:12 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 28 Sep 2007 12:29:12 +0200 (CEST)
Subject: r2051 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070928102912.99D0C1EC21E@projects.linpro.no>
Author: phk
Date: 2007-09-28 12:29:12 +0200 (Fri, 28 Sep 2007)
New Revision: 2051
Modified:
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_fetch.c
trunk/varnish-cache/bin/varnishd/cache_http.c
trunk/varnish-cache/bin/varnishd/cache_session.c
Log:
Preparation for implementation of restarts: Move the ws from http to
the containing object (session or obj).
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-27 10:08:30 UTC (rev 2050)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-28 10:29:12 UTC (rev 2051)
@@ -117,7 +117,7 @@
unsigned magic;
#define HTTP_MAGIC 0x6428b5c9
- struct ws ws[1];
+ struct ws *ws;
txt rx; /* Received Request */
txt pl; /* Pipelined bytes */
@@ -186,8 +186,7 @@
unsigned magic;
#define BEREQ_MAGIC 0x3b6d250c
VTAILQ_ENTRY(bereq) list;
- void *space;
- unsigned len;
+ struct ws ws[1];
struct http http[1];
};
@@ -217,6 +216,7 @@
unsigned xid;
struct objhead *objhead;
+ struct ws ws_o[1];
unsigned char *vary;
unsigned heap_idx;
@@ -285,6 +285,7 @@
/* HTTP request */
const char *doclose;
struct http *http;
+ struct ws ws[1];
/* Timestamps, all on TIM_real() timescale */
double t_open;
@@ -460,7 +461,7 @@
void http_PrintfHeader(struct worker *w, int fd, struct http *to, const char *fmt, ...);
void http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr);
void http_SetH(struct http *to, unsigned n, const char *fm);
-void http_Setup(struct http *ht, void *space, unsigned len);
+void http_Setup(struct http *ht, struct ws *ws);
int http_GetHdr(const struct http *hp, const char *hdr, char **ptr);
int http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr);
int http_GetStatus(const struct http *hp);
@@ -475,7 +476,7 @@
int http_RecvHead(struct http *hp, int fd);
int http_DissectRequest(struct worker *w, struct http *sp, int fd);
int http_DissectResponse(struct worker *w, struct http *sp, int fd);
-void http_DoConnection(struct sess *sp);
+const char *http_DoConnection(struct http *hp);
void http_CopyHome(struct worker *w, int fd, struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-27 10:08:30 UTC (rev 2050)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2007-09-28 10:29:12 UTC (rev 2051)
@@ -147,10 +147,9 @@
if (bereq == NULL)
return (NULL);
bereq->magic = BEREQ_MAGIC;
- bereq->space = bereq + 1;
- bereq->len = len;
+ WS_Init(bereq->ws, bereq + 1, len);
}
- http_Setup(bereq->http, bereq->space, bereq->len);
+ http_Setup(bereq->http, bereq->ws);
return (bereq);
}
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-27 10:08:30 UTC (rev 2050)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-28 10:29:12 UTC (rev 2051)
@@ -763,7 +763,7 @@
return (0);
}
- http_DoConnection(sp);
+ sp->doclose = http_DoConnection(sp->http);
/* By default we use the first backend */
AZ(sp->backend);
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-27 10:08:30 UTC (rev 2050)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-28 10:29:12 UTC (rev 2051)
@@ -332,7 +332,8 @@
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
b = malloc(len);
AN(b);
- http_Setup(hp2, b, len);
+ WS_Init(sp->obj->ws_o, b, len);
+ http_Setup(hp2, sp->obj->ws_o);
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
hp2->logtag = HTTP_Obj;
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-27 10:08:30 UTC (rev 2050)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-28 10:29:12 UTC (rev 2051)
@@ -160,13 +160,12 @@
/*--------------------------------------------------------------------*/
void
-http_Setup(struct http *hp, void *space, unsigned len)
+http_Setup(struct http *hp, struct ws *ws)
{
- assert(len > 0);
memset(hp, 0, sizeof *hp);
hp->magic = HTTP_MAGIC;
- WS_Init(hp->ws, space, len);
+ hp->ws = ws;
hp->nhd = HTTP_HDR_FIRST;
}
@@ -266,18 +265,19 @@
/*--------------------------------------------------------------------*/
-void
-http_DoConnection(struct sess *sp)
+const char *
+http_DoConnection(struct http *hp)
{
- struct http *hp = sp->http;
char *p, *q;
+ const char *ret;
unsigned u;
if (!http_GetHdr(hp, H_Connection, &p)) {
if (strcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.1"))
- sp->doclose = "not HTTP/1.1";
- return;
+ return ("not HTTP/1.1");
+ return (NULL);
}
+ ret = NULL;
for (; *p; p++) {
if (isspace(*p))
continue;
@@ -288,7 +288,7 @@
break;
u = pdiff(p, q);
if (u == 5 && !strncasecmp(p, "close", u))
- sp->doclose = "Connection: close";
+ ret = "Connection: close";
u = http_findhdr(hp, u, p);
if (u != 0)
hp->hdf[u] |= HDF_FILTER;
@@ -296,6 +296,7 @@
break;
p = q;
}
+ return (ret);
}
/*--------------------------------------------------------------------*/
Modified: trunk/varnish-cache/bin/varnishd/cache_session.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_session.c 2007-09-27 10:08:30 UTC (rev 2050)
+++ trunk/varnish-cache/bin/varnishd/cache_session.c 2007-09-28 10:29:12 UTC (rev 2051)
@@ -302,7 +302,6 @@
memset(sp, 0, sizeof *sp);
sp->magic = SESS_MAGIC;
sp->mem = sm;
- sp->http = &sm->http;
sp->sockaddr = (void*)(&sm->sockaddr[0]);
sp->sockaddrlen = sizeof(sm->sockaddr[0]);
sp->mysockaddr = (void*)(&sm->sockaddr[1]);
@@ -319,7 +318,9 @@
sp->sockaddrlen = len;
}
- http_Setup(&sm->http, (void *)(sm + 1), sm->workspace);
+ WS_Init(sp->ws, (void *)(sm + 1), sm->workspace);
+ sp->http = &sm->http;
+ http_Setup(sp->http, sp->ws);
return (sp);
}
From phk at projects.linpro.no Fri Sep 28 11:07:15 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 28 Sep 2007 13:07:15 +0200 (CEST)
Subject: r2052 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070928110715.1E6E01EC1D1@projects.linpro.no>
Author: phk
Date: 2007-09-28 13:07:14 +0200 (Fri, 28 Sep 2007)
New Revision: 2052
Modified:
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Push the http structure out of the early bits of the reception code.
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-28 10:29:12 UTC (rev 2051)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-28 11:07:14 UTC (rev 2052)
@@ -563,28 +563,33 @@
}
/*--------------------------------------------------------------------
- * Return nonzero if we have a complete HTTP request.
+ * Check if we have a complete HTTP request or response yet between the
+ * two pointers given.
+ *
+ * Return values:
+ * -1 No, and you can nuke the (white-space) content.
+ * 0 No, keep trying
+ * >0 Yes, it is this many bytes long.
*/
static int
-http_header_complete(struct http *hp)
+http_header_complete(const char *b, const char *e)
{
- char *p;
+ const char *p;
- CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- assert(*hp->rx.e == '\0');
+ AN(b);
+ AN(e);
+ assert(b <= e);
+ assert(*e == '\0');
/* Skip any leading white space */
- for (p = hp->rx.b ; p < hp->rx.e && isspace(*p); p++)
+ for (p = b ; isspace(*p); p++)
continue;
- if (p >= hp->rx.e) {
- hp->rx.e = hp->rx.b;
- return (0);
- }
+ if (*p == '\0')
+ return (-1);
while (1) {
- /* XXX: we could save location of all linebreaks for later */
p = strchr(p, '\n');
if (p == NULL)
- return (0); /* XXX: Could cache p */
+ return (0);
p++;
if (*p == '\r')
p++;
@@ -592,14 +597,7 @@
break;
}
p++;
- WS_ReleaseP(hp->ws, hp->rx.e);
- if (p != hp->rx.e) {
- hp->pl.b = p;
- hp->pl.e = hp->rx.e;
- hp->rx.e = p;
- }
- /* XXX: Check this stuff... */
- return (1);
+ return (p - b);
}
/*--------------------------------------------------------------------*/
@@ -627,11 +625,23 @@
int
http_RecvPrepAgain(struct http *hp)
{
+ int i;
http_RecvPrep(hp);
if (hp->rx.b == hp->rx.e)
return (0);
- return (http_header_complete(hp));
+ i = http_header_complete(hp->rx.b, hp->rx.e);
+ if (i == -1)
+ hp->rx.e = hp->rx.b;
+ if (i <= 0)
+ return (0);
+ WS_ReleaseP(hp->ws, hp->rx.e);
+ if (hp->rx.e != hp->rx.b + i) {
+ hp->pl.b = hp->rx.b + i;
+ hp->pl.e = hp->rx.e;
+ hp->rx.e = hp->pl.b;
+ }
+ return (i);
}
/*--------------------------------------------------------------------*/
@@ -656,9 +666,18 @@
if (i > 0) {
hp->rx.e += i;
*hp->rx.e = '\0';
- if (http_header_complete(hp))
- return(0);
- return (-1);
+ i = http_header_complete(hp->rx.b, hp->rx.e);
+ if (i == -1)
+ hp->rx.e = hp->rx.b;
+ if (i == 0)
+ return (-1);
+ WS_ReleaseP(hp->ws, hp->rx.e);
+ if (hp->rx.e != hp->rx.b + i) {
+ hp->pl.b = hp->rx.b + i;
+ hp->pl.e = hp->rx.e;
+ hp->rx.e = hp->pl.b;
+ }
+ return (0);
}
if (hp->rx.e != hp->rx.b) {
From phk at projects.linpro.no Fri Sep 28 13:04:53 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 28 Sep 2007 15:04:53 +0200 (CEST)
Subject: r2053 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070928130453.BBB611EC42F@projects.linpro.no>
Author: phk
Date: 2007-09-28 15:04:53 +0200 (Fri, 28 Sep 2007)
New Revision: 2053
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
Log:
Move the WS_ prototypes down where they belong.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-28 11:07:14 UTC (rev 2052)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-28 13:04:53 UTC (rev 2053)
@@ -90,14 +90,6 @@
char *r; /* (R)eserved length */
};
-void WS_Init(struct ws *ws, void *space, unsigned len);
-unsigned WS_Reserve(struct ws *ws, unsigned bytes);
-void WS_Release(struct ws *ws, unsigned bytes);
-void WS_ReleaseP(struct ws *ws, char *ptr);
-void WS_Assert(const struct ws *ws);
-void WS_Reset(struct ws *ws);
-char *WS_Alloc(struct ws *ws, unsigned bytes);
-
/*--------------------------------------------------------------------
* HTTP Request/Response/Header handling structure.
*/
@@ -554,6 +546,16 @@
cli_func_t cli_func_dump_pool;
#endif
+/* cache_ws.c */
+
+void WS_Init(struct ws *ws, void *space, unsigned len);
+unsigned WS_Reserve(struct ws *ws, unsigned bytes);
+void WS_Release(struct ws *ws, unsigned bytes);
+void WS_ReleaseP(struct ws *ws, char *ptr);
+void WS_Assert(const struct ws *ws);
+void WS_Reset(struct ws *ws);
+char *WS_Alloc(struct ws *ws, unsigned bytes);
+
/* rfc2616.c */
int RFC2616_cache_policy(const struct sess *sp, const struct http *hp);
From phk at projects.linpro.no Fri Sep 28 13:13:12 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 28 Sep 2007 15:13:12 +0200 (CEST)
Subject: r2054 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070928131312.428271EC1D1@projects.linpro.no>
Author: phk
Date: 2007-09-28 15:13:11 +0200 (Fri, 28 Sep 2007)
New Revision: 2054
Added:
trunk/varnish-cache/bin/varnishd/cache_httpconn.c
Modified:
trunk/varnish-cache/bin/varnishd/Makefile.am
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Initial split of code which transfer HTTP protocol messages
over sockets and things which manipulate them in memory.
Modified: trunk/varnish-cache/bin/varnishd/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishd/Makefile.am 2007-09-28 13:04:53 UTC (rev 2053)
+++ trunk/varnish-cache/bin/varnishd/Makefile.am 2007-09-28 13:13:11 UTC (rev 2054)
@@ -22,6 +22,7 @@
cache_fetch.c \
cache_hash.c \
cache_http.c \
+ cache_httpconn.c \
cache_main.c \
cache_pool.c \
cache_pipe.c \
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-28 13:04:53 UTC (rev 2053)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-28 13:13:11 UTC (rev 2054)
@@ -122,6 +122,16 @@
unsigned nhd;
};
+struct http_conn {
+ unsigned magic;
+#define HTTP_CONN_MAGIC 0x3e19edd1
+
+ struct http *http;
+ struct ws *ws;
+ txt rxbuf;
+ txt pipeline;
+};
+
/*--------------------------------------------------------------------*/
struct acct {
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-28 13:04:53 UTC (rev 2053)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-28 13:13:11 UTC (rev 2054)
@@ -317,60 +317,6 @@
/*--------------------------------------------------------------------*/
int
-http_GetTail(struct http *hp, unsigned len, char **b, char **e)
-{
-
- if (hp->pl.b >= hp->pl.e)
- return (0);
-
- if (len == 0)
- len = Tlen(hp->pl);
-
- if (hp->pl.b + len > hp->pl.e)
- len = Tlen(hp->pl);
- if (len == 0)
- return (0);
- *b = hp->pl.b;
- *e = hp->pl.b + len;
- hp->pl.b += len;
- Tcheck(hp->pl);
- return (1);
-}
-
-/*--------------------------------------------------------------------*/
-/* Read from fd, but soak up any tail first */
-
-int
-http_Read(struct http *hp, int fd, void *p, unsigned len)
-{
- int i;
- unsigned u;
- char *b = p;
-
- u = 0;
- if (hp->pl.b < hp->pl.e) {
- u = Tlen(hp->pl);
- if (u > len)
- u = len;
- memcpy(b, hp->pl.b, u);
- hp->pl.b += u;
- b += u;
- len -= u;
- }
- if (hp->pl.e == hp->pl.b)
- hp->pl.b = hp->pl.e = NULL;
- if (len > 0) {
- i = read(fd, b, len);
- if (i < 0) /* XXX i == 0 ?? */
- return (i);
- u += i;
- }
- return (u);
-}
-
-/*--------------------------------------------------------------------*/
-
-int
http_GetStatus(const struct http *hp)
{
@@ -561,157 +507,9 @@
return (http_dissect_hdrs(w, hp, fd, p));
}
-
-/*--------------------------------------------------------------------
- * Check if we have a complete HTTP request or response yet between the
- * two pointers given.
- *
- * Return values:
- * -1 No, and you can nuke the (white-space) content.
- * 0 No, keep trying
- * >0 Yes, it is this many bytes long.
- */
-
-static int
-http_header_complete(const char *b, const char *e)
-{
- const char *p;
-
- AN(b);
- AN(e);
- assert(b <= e);
- assert(*e == '\0');
- /* Skip any leading white space */
- for (p = b ; isspace(*p); p++)
- continue;
- if (*p == '\0')
- return (-1);
- while (1) {
- p = strchr(p, '\n');
- if (p == NULL)
- return (0);
- p++;
- if (*p == '\r')
- p++;
- if (*p == '\n')
- break;
- }
- p++;
- return (p - b);
-}
-
/*--------------------------------------------------------------------*/
void
-http_RecvPrep(struct http *hp)
-{
- unsigned l;
-
- CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- WS_Assert(hp->ws);
- WS_Reset(hp->ws);
- WS_Reserve(hp->ws, 0);
- hp->rx.b = hp->ws->f;
- hp->rx.e = hp->rx.b;
- if (hp->pl.b != NULL) {
- l = Tlen(hp->pl);
- memmove(hp->rx.b, hp->pl.b, l);
- hp->rx.e = hp->rx.b + l;
- hp->pl.b = hp->pl.e = NULL;
- }
- *hp->rx.e = '\0';
-}
-
-int
-http_RecvPrepAgain(struct http *hp)
-{
- int i;
-
- http_RecvPrep(hp);
- if (hp->rx.b == hp->rx.e)
- return (0);
- i = http_header_complete(hp->rx.b, hp->rx.e);
- if (i == -1)
- hp->rx.e = hp->rx.b;
- if (i <= 0)
- return (0);
- WS_ReleaseP(hp->ws, hp->rx.e);
- if (hp->rx.e != hp->rx.b + i) {
- hp->pl.b = hp->rx.b + i;
- hp->pl.e = hp->rx.e;
- hp->rx.e = hp->pl.b;
- }
- return (i);
-}
-
-/*--------------------------------------------------------------------*/
-
-int
-http_RecvSome(int fd, struct http *hp)
-{
- unsigned l;
- int i;
-
- l = pdiff(hp->rx.e, hp->ws->e) - 1;
- l /= 2; /* Don't fill all of workspace with read-ahead */
- if (l <= 1) {
- VSL(SLT_HttpError, fd, "Received too much");
- VSLR(SLT_HttpGarbage, fd, hp->rx);
- hp->rx.b = hp->rx.e = NULL;
- WS_Release(hp->ws, 0);
- return (1);
- }
- errno = 0;
- i = read(fd, hp->rx.e, l - 1);
- if (i > 0) {
- hp->rx.e += i;
- *hp->rx.e = '\0';
- i = http_header_complete(hp->rx.b, hp->rx.e);
- if (i == -1)
- hp->rx.e = hp->rx.b;
- if (i == 0)
- return (-1);
- WS_ReleaseP(hp->ws, hp->rx.e);
- if (hp->rx.e != hp->rx.b + i) {
- hp->pl.b = hp->rx.b + i;
- hp->pl.e = hp->rx.e;
- hp->rx.e = hp->pl.b;
- }
- return (0);
- }
-
- if (hp->rx.e != hp->rx.b) {
- VSL(SLT_HttpError, fd,
- "Received (only) %d bytes, errno %d",
- hp->rx.e - hp->rx.b, errno);
- VSLR(SLT_Debug, fd, hp->rx);
- } else if (errno == 0)
- VSL(SLT_HttpError, fd, "Received nothing");
- else
- VSL(SLT_HttpError, fd, "Received errno %d", errno);
- hp->rx.b = hp->rx.e = NULL;
- WS_Release(hp->ws, 0);
- return(2);
-}
-
-/*--------------------------------------------------------------------*/
-
-int
-http_RecvHead(struct http *hp, int fd)
-{
- int i;
-
- CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- http_RecvPrep(hp);
- do
- i = http_RecvSome(fd, hp);
- while (i == -1);
- return (i);
-}
-
-/*--------------------------------------------------------------------*/
-
-void
http_SetH(struct http *to, unsigned n, const char *fm)
{
Added: trunk/varnish-cache/bin/varnishd/cache_httpconn.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_httpconn.c (rev 0)
+++ trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-09-28 13:13:11 UTC (rev 2054)
@@ -0,0 +1,241 @@
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006-2007 Linpro AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp
+ *
+ * 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: cache_http.c 2052 2007-09-28 11:07:14Z phk $
+ *
+ * HTTP protocol requests
+ */
+
+#include
+#include
+#include
+
+#include "shmlog.h"
+#include "cache.h"
+
+/*--------------------------------------------------------------------
+ * Check if we have a complete HTTP request or response yet between the
+ * two pointers given.
+ *
+ * Return values:
+ * -1 No, and you can nuke the (white-space) content.
+ * 0 No, keep trying
+ * >0 Yes, it is this many bytes long.
+ */
+
+static int
+http_header_complete(const char *b, const char *e)
+{
+ const char *p;
+
+ AN(b);
+ AN(e);
+ assert(b <= e);
+ assert(*e == '\0');
+ /* Skip any leading white space */
+ for (p = b ; isspace(*p); p++)
+ continue;
+ if (*p == '\0')
+ return (-1);
+ while (1) {
+ p = strchr(p, '\n');
+ if (p == NULL)
+ return (0);
+ p++;
+ if (*p == '\r')
+ p++;
+ if (*p == '\n')
+ break;
+ }
+ p++;
+ return (p - b);
+}
+
+/*--------------------------------------------------------------------*/
+
+void
+http_RecvPrep(struct http *hp)
+{
+ unsigned l;
+
+ CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
+ WS_Assert(hp->ws);
+ WS_Reset(hp->ws);
+ WS_Reserve(hp->ws, 0);
+ hp->rx.b = hp->ws->f;
+ hp->rx.e = hp->rx.b;
+ if (hp->pl.b != NULL) {
+ l = Tlen(hp->pl);
+ memmove(hp->rx.b, hp->pl.b, l);
+ hp->rx.e = hp->rx.b + l;
+ hp->pl.b = hp->pl.e = NULL;
+ }
+ *hp->rx.e = '\0';
+}
+
+int
+http_RecvPrepAgain(struct http *hp)
+{
+ int i;
+
+ http_RecvPrep(hp);
+ if (hp->rx.b == hp->rx.e)
+ return (0);
+ i = http_header_complete(hp->rx.b, hp->rx.e);
+ if (i == -1)
+ hp->rx.e = hp->rx.b;
+ if (i <= 0)
+ return (0);
+ WS_ReleaseP(hp->ws, hp->rx.e);
+ if (hp->rx.e != hp->rx.b + i) {
+ hp->pl.b = hp->rx.b + i;
+ hp->pl.e = hp->rx.e;
+ hp->rx.e = hp->pl.b;
+ }
+ return (i);
+}
+
+/*--------------------------------------------------------------------*/
+
+int
+http_RecvSome(int fd, struct http *hp)
+{
+ unsigned l;
+ int i;
+
+ l = pdiff(hp->rx.e, hp->ws->e) - 1;
+ l /= 2; /* Don't fill all of workspace with read-ahead */
+ if (l <= 1) {
+ VSL(SLT_HttpError, fd, "Received too much");
+ VSLR(SLT_HttpGarbage, fd, hp->rx);
+ hp->rx.b = hp->rx.e = NULL;
+ WS_Release(hp->ws, 0);
+ return (1);
+ }
+ errno = 0;
+ i = read(fd, hp->rx.e, l - 1);
+ if (i > 0) {
+ hp->rx.e += i;
+ *hp->rx.e = '\0';
+ i = http_header_complete(hp->rx.b, hp->rx.e);
+ if (i == -1)
+ hp->rx.e = hp->rx.b;
+ if (i == 0)
+ return (-1);
+ WS_ReleaseP(hp->ws, hp->rx.e);
+ if (hp->rx.e != hp->rx.b + i) {
+ hp->pl.b = hp->rx.b + i;
+ hp->pl.e = hp->rx.e;
+ hp->rx.e = hp->pl.b;
+ }
+ return (0);
+ }
+
+ if (hp->rx.e != hp->rx.b) {
+ VSL(SLT_HttpError, fd,
+ "Received (only) %d bytes, errno %d",
+ hp->rx.e - hp->rx.b, errno);
+ VSLR(SLT_Debug, fd, hp->rx);
+ } else if (errno == 0)
+ VSL(SLT_HttpError, fd, "Received nothing");
+ else
+ VSL(SLT_HttpError, fd, "Received errno %d", errno);
+ hp->rx.b = hp->rx.e = NULL;
+ WS_Release(hp->ws, 0);
+ return(2);
+}
+
+/*--------------------------------------------------------------------*/
+
+int
+http_RecvHead(struct http *hp, int fd)
+{
+ int i;
+
+ CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
+ http_RecvPrep(hp);
+ do
+ i = http_RecvSome(fd, hp);
+ while (i == -1);
+ return (i);
+}
+
+/*--------------------------------------------------------------------*/
+
+int
+http_GetTail(struct http *hp, unsigned len, char **b, char **e)
+{
+
+ if (hp->pl.b >= hp->pl.e)
+ return (0);
+
+ if (len == 0)
+ len = Tlen(hp->pl);
+
+ if (hp->pl.b + len > hp->pl.e)
+ len = Tlen(hp->pl);
+ if (len == 0)
+ return (0);
+ *b = hp->pl.b;
+ *e = hp->pl.b + len;
+ hp->pl.b += len;
+ Tcheck(hp->pl);
+ return (1);
+}
+
+/*--------------------------------------------------------------------*/
+/* Read from fd, but soak up any tail first */
+
+int
+http_Read(struct http *hp, int fd, void *p, unsigned len)
+{
+ int i;
+ unsigned u;
+ char *b = p;
+
+ u = 0;
+ if (hp->pl.b < hp->pl.e) {
+ u = Tlen(hp->pl);
+ if (u > len)
+ u = len;
+ memcpy(b, hp->pl.b, u);
+ hp->pl.b += u;
+ b += u;
+ len -= u;
+ }
+ if (hp->pl.e == hp->pl.b)
+ hp->pl.b = hp->pl.e = NULL;
+ if (len > 0) {
+ i = read(fd, b, len);
+ if (i < 0) /* XXX i == 0 ?? */
+ return (i);
+ u += i;
+ }
+ return (u);
+}
+
From phk at projects.linpro.no Fri Sep 28 20:13:48 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Fri, 28 Sep 2007 22:13:48 +0200 (CEST)
Subject: r2055 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070928201348.A790B1EC46B@projects.linpro.no>
Author: phk
Date: 2007-09-28 22:13:48 +0200 (Fri, 28 Sep 2007)
New Revision: 2055
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_acceptor.c
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_http.c
trunk/varnish-cache/bin/varnishd/cache_httpconn.c
trunk/varnish-cache/bin/varnishd/cache_pipe.c
Log:
Complete the split of HTTP-editing and HTTP-transmission functions.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-28 13:13:11 UTC (rev 2054)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-28 20:13:48 UTC (rev 2055)
@@ -110,8 +110,6 @@
#define HTTP_MAGIC 0x6428b5c9
struct ws *ws;
- txt rx; /* Received Request */
- txt pl; /* Pipelined bytes */
unsigned char conds; /* If-* headers present */
enum httpwhence logtag;
@@ -126,7 +124,7 @@
unsigned magic;
#define HTTP_CONN_MAGIC 0x3e19edd1
- struct http *http;
+ int fd;
struct ws *ws;
txt rxbuf;
txt pipeline;
@@ -289,6 +287,8 @@
struct http *http;
struct ws ws[1];
+ struct http_conn htc[1];
+
/* Timestamps, all on TIM_real() timescale */
double t_open;
double t_req;
@@ -470,18 +470,17 @@
const char *http_GetReq(const struct http *hp);
const char *http_GetProto(const struct http *hp);
int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
-int http_GetTail(struct http *hp, unsigned len, char **b, char **e);
-int http_Read(struct http *hp, int fd, void *b, unsigned len);
-void http_RecvPrep(struct http *hp);
-int http_RecvPrepAgain(struct http *hp);
-int http_RecvSome(int fd, struct http *hp);
-int http_RecvHead(struct http *hp, int fd);
-int http_DissectRequest(struct worker *w, struct http *sp, int fd);
-int http_DissectResponse(struct worker *w, struct http *sp, int fd);
+int http_DissectRequest(struct sess *sp);
+int http_DissectResponse(struct worker *w, struct http_conn *htc, struct http *sp);
const char *http_DoConnection(struct http *hp);
void http_CopyHome(struct worker *w, int fd, struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
+/* cache_httpconn.c */
+void HTC_Init(struct http_conn *htc, struct ws *ws, int fd);
+int HTC_Reinit(struct http_conn *htc);
+int HTC_Rx(struct http_conn *htc);
+int HTC_Read(struct http_conn *htc, void *d, unsigned len);
#define HTTPH(a, b, c, d, e, f, g) extern char b[];
#include "http_headers.h"
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-09-28 13:13:11 UTC (rev 2054)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-09-28 20:13:48 UTC (rev 2055)
@@ -194,7 +194,7 @@
sp->id = i;
sp->t_open = TIM_real();
- http_RecvPrep(sp->http);
+ HTC_Init(sp->htc, sp->ws, sp->fd);
sp->step = STP_FIRST;
WRK_QueueSession(sp);
}
@@ -224,13 +224,13 @@
{
int i;
- i = http_RecvSome(sp->fd, sp->http);
- if (i < 1)
- return (i);
+ i = HTC_Rx(sp->htc);
+ /* XXX: fix retval */
+ if (i == 0)
+ return (-1);
if (i == 1)
- vca_close_session(sp, "overflow");
- else if (i == 2)
- vca_close_session(sp, "no request");
+ return (0);
+ vca_close_session(sp, "err/poll");
return (1);
}
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-28 13:13:11 UTC (rev 2054)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-28 20:13:48 UTC (rev 2055)
@@ -88,20 +88,15 @@
assert(sp->xid == 0);
- do
- i = http_RecvSome(sp->fd, sp->http);
- while (i == -1);
- if (i == 0) {
+ do
+ i = HTC_Rx(sp->htc);
+ while (i == 0);
+ if (i == 1) {
sp->step = STP_RECV;
- return (0);
- }
- if (i == 1)
+ } else {
vca_close_session(sp, "overflow");
- else if (i == 2)
- vca_close_session(sp, "no request");
- else
- INCOMPL();
- sp->step = STP_DONE;
+ sp->step = STP_DONE;
+ }
return (0);
}
@@ -185,6 +180,7 @@
cnt_done(struct sess *sp)
{
double dh, dp, da;
+ int i;
AZ(sp->obj);
AZ(sp->bereq);
@@ -224,12 +220,13 @@
return (1);
}
- if (http_RecvPrepAgain(sp->http)) {
+ i = HTC_Reinit(sp->htc);
+ if (i == 1) {
VSL_stats->sess_pipeline++;
sp->step = STP_RECV;
return (0);
}
- if (sp->http->pl.b < sp->http->pl.e) {
+ if (Tlen(sp->htc->rxbuf)) {
VSL_stats->sess_readahead++;
sp->step = STP_AGAIN;
return (0);
@@ -388,13 +385,13 @@
sp->wrk->acct.sess++;
SES_RefSrcAddr(sp);
do
- i = http_RecvSome(sp->fd, sp->http);
- while (i == -1);
- if (i == 0) {
+ i = HTC_Rx(sp->htc);
+ while (i == 0);
+ if (i == 1) {
sp->step = STP_RECV;
return (0);
}
- if (i == 1)
+ if (i == -1)
vca_close_session(sp, "blast");
else if (i == 2)
vca_close_session(sp, "silent");
@@ -756,7 +753,7 @@
sp->vcl = sp->wrk->vcl;
sp->wrk->vcl = NULL;
- done = http_DissectRequest(sp->wrk, sp->http, sp->fd);
+ done = http_DissectRequest(sp);
if (done != 0) {
RES_Error(sp, done, NULL); /* XXX: STP_ERROR ? */
sp->step = STP_DONE;
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-28 13:13:11 UTC (rev 2054)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-28 20:13:48 UTC (rev 2055)
@@ -49,7 +49,7 @@
/*--------------------------------------------------------------------*/
static int
-fetch_straight(struct sess *sp, int fd, struct http *hp, const char *b)
+fetch_straight(struct sess *sp, struct http_conn *htc, const char *b)
{
int i;
unsigned char *p;
@@ -70,12 +70,12 @@
sp->obj->len = cl;
p = st->ptr;
- i = fcntl(fd, F_GETFL); /* XXX ? */
+ i = fcntl(htc->fd, F_GETFL); /* XXX ? */
i &= ~O_NONBLOCK;
- i = fcntl(fd, F_SETFL, i);
+ i = fcntl(htc->fd, F_SETFL, i);
while (cl > 0) {
- i = http_Read(hp, fd, p, cl);
+ i = HTC_Read(htc, p, cl);
if (i <= 0)
return (-1);
p += i;
@@ -88,7 +88,7 @@
/* XXX: Cleanup. It must be possible somehow :-( */
static int
-fetch_chunked(struct sess *sp, int fd, struct http *hp)
+fetch_chunked(struct sess *sp, struct http_conn *htc)
{
int i;
char *q;
@@ -132,7 +132,7 @@
* deal more complex than reading a single character
* at a time.
*/
- i = http_Read(hp, fd, bp, 1);
+ i = HTC_Read(htc, bp, 1);
if (i <= 0)
return (-1);
bp += i;
@@ -179,7 +179,7 @@
/* Pick up the rest of this chunk */
while (v > 0) {
- i = http_Read(hp, fd, st->ptr + st->len, v);
+ i = HTC_Read(htc, st->ptr + st->len, v);
if (i <= 0)
return (-1);
st->len += i;
@@ -211,16 +211,16 @@
#include
static int
-fetch_eof(struct sess *sp, int fd, struct http *hp)
+fetch_eof(struct sess *sp, struct http_conn *htc)
{
int i;
unsigned char *p;
struct storage *st;
unsigned v;
- i = fcntl(fd, F_GETFL); /* XXX ? */
+ i = fcntl(htc->fd, F_GETFL); /* XXX ? */
i &= ~O_NONBLOCK;
- i = fcntl(fd, F_SETFL, i);
+ i = fcntl(htc->fd, F_SETFL, i);
p = NULL;
v = 0;
@@ -234,7 +234,7 @@
}
AN(p);
AN(st);
- i = http_Read(hp, fd, p, v);
+ i = HTC_Read(htc, p, v);
if (i < 0)
return (-1);
if (i == 0)
@@ -268,6 +268,8 @@
struct bereq *bereq;
int mklen, is_head;
unsigned len;
+ struct http_conn htc[1];
+ int i;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
@@ -300,15 +302,15 @@
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
- if (http_RecvHead(hp, vc->fd)) {
+ HTC_Init(htc, bereq->ws, vc->fd);
+ do
+ i = HTC_Rx(htc);
+ while (i == 0);
+
+ if (http_DissectResponse(sp->wrk, htc, hp)) {
/* XXX: cleanup */
return (1);
}
- if (http_DissectResponse(sp->wrk, hp, vc->fd)) {
- /* XXX: cleanup */
- return (1);
- }
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -326,8 +328,8 @@
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
/* Filter into object */
hp2 = &sp->obj->http;
- len = Tlen(hp->rx);
- len += 256; /* margin for content-length etc */
+ len = Tlen(htc->rxbuf);
+ len += 256; /* XXX: margin for content-length etc */
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
b = malloc(len);
@@ -349,10 +351,10 @@
if (is_head) {
/* nothing */
} else if (http_GetHdr(hp, H_Content_Length, &b)) {
- cls = fetch_straight(sp, vc->fd, hp, b);
+ cls = fetch_straight(sp, htc, b);
mklen = 1;
} else if (http_HdrIs(hp, H_Transfer_Encoding, "chunked")) {
- cls = fetch_chunked(sp, vc->fd, hp);
+ cls = fetch_chunked(sp, htc);
mklen = 1;
} else if (http_GetHdr(hp, H_Transfer_Encoding, &b)) {
/* XXX: AUGH! */
@@ -362,7 +364,7 @@
} else if (strcmp(http_GetProto(hp), "HTTP/1.1")) {
switch (http_GetStatus(hp)) {
case 200:
- cls = fetch_eof(sp, vc->fd, hp);
+ cls = fetch_eof(sp, htc);
mklen = 1;
break;
default:
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-28 13:13:11 UTC (rev 2054)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-28 20:13:48 UTC (rev 2055)
@@ -347,7 +347,7 @@
*/
static int
-http_dissect_hdrs(struct worker *w, struct http *hp, int fd, char *p)
+http_dissect_hdrs(struct worker *w, struct http *hp, int fd, char *p, txt t)
{
char *q, *r;
@@ -357,8 +357,8 @@
hp->nhd = HTTP_HDR_FIRST;
hp->conds = 0;
r = NULL; /* For FlexeLint */
- assert(p < hp->rx.e); /* http_header_complete() guarantees this */
- for (; p < hp->rx.e; p = r) {
+ assert(p < t.e); /* http_header_complete() guarantees this */
+ for (; p < t.e; p = r) {
/* XXX: handle continuation lines */
q = strchr(p, '\n');
assert(q != NULL);
@@ -391,16 +391,23 @@
/*--------------------------------------------------------------------*/
int
-http_DissectRequest(struct worker *w, struct http *hp, int fd)
+http_DissectRequest(struct sess *sp)
{
char *p;
+ struct http_conn *htc;
+ struct http *hp;
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ htc = sp->htc;
+ CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
+ hp = sp->http;
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
+
/* Assert a NUL at rx.e */
- Tcheck(hp->rx);
+ Tcheck(htc->rxbuf);
hp->logtag = HTTP_Rx;
- for (p = hp->rx.b ; isspace(*p); p++)
+ for (p = htc->rxbuf.b ; isspace(*p); p++)
continue;
/* First, the request type (GET/HEAD etc) */
@@ -408,23 +415,23 @@
for (; isalpha(*p); p++)
;
hp->hd[HTTP_HDR_REQ].e = p;
- WSLH(w, HTTP_T_Request, fd, hp, HTTP_HDR_REQ);
+ WSLH(sp->wrk, HTTP_T_Request, sp->fd, hp, HTTP_HDR_REQ);
*p++ = '\0';
/* Next find the URI */
while (isspace(*p) && *p != '\n')
p++;
if (*p == '\n') {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx);
+ WSLR(sp->wrk, SLT_HttpGarbage, sp->fd, htc->rxbuf);
return (400);
}
hp->hd[HTTP_HDR_URL].b = p;
while (!isspace(*p))
p++;
hp->hd[HTTP_HDR_URL].e = p;
- WSLH(w, HTTP_T_URL, fd, hp, HTTP_HDR_URL);
+ WSLH(sp->wrk, HTTP_T_URL, sp->fd, hp, HTTP_HDR_URL);
if (*p == '\n') {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx);
+ WSLR(sp->wrk, SLT_HttpGarbage, sp->fd, htc->rxbuf);
return (400);
}
*p++ = '\0';
@@ -433,44 +440,45 @@
while (isspace(*p) && *p != '\n')
p++;
if (*p == '\n') {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx);
+ WSLR(sp->wrk, SLT_HttpGarbage, sp->fd, htc->rxbuf);
return (400);
}
hp->hd[HTTP_HDR_PROTO].b = p;
while (!isspace(*p))
p++;
hp->hd[HTTP_HDR_PROTO].e = p;
- WSLH(w, HTTP_T_Protocol, fd, hp, HTTP_HDR_PROTO);
+ WSLH(sp->wrk, HTTP_T_Protocol, sp->fd, hp, HTTP_HDR_PROTO);
if (*p != '\n')
*p++ = '\0';
while (isspace(*p) && *p != '\n')
p++;
if (*p != '\n') {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx);
+ WSLR(sp->wrk, SLT_HttpGarbage, sp->fd, htc->rxbuf);
return (400);
}
*p++ = '\0';
- return (http_dissect_hdrs(w, hp, fd, p));
+ return (http_dissect_hdrs(sp->wrk, hp, sp->fd, p, htc->rxbuf));
}
/*--------------------------------------------------------------------*/
int
-http_DissectResponse(struct worker *w, struct http *hp, int fd)
+http_DissectResponse(struct worker *w, struct http_conn *htc, struct http *hp)
{
char *p, *q;
+ CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- /* Assert a NUL at rx.e */
- Tcheck(hp->rx);
+ /* Assert a NUL at rx.e (?) */
+ Tcheck(htc->rxbuf);
hp->logtag = HTTP_Rx;
- for (p = hp->rx.b ; isspace(*p); p++)
+ for (p = htc->rxbuf.b ; isspace(*p); p++)
continue;
if (memcmp(p, "HTTP/1.", 7)) {
- WSLR(w, SLT_HttpGarbage, fd, hp->rx);
+ WSLR(w, SLT_HttpGarbage, htc->fd, htc->rxbuf);
return (400);
}
/* First, protocol */
@@ -478,7 +486,7 @@
while (!isspace(*p))
p++;
hp->hd[HTTP_HDR_PROTO].e = p;
- WSLH(w, HTTP_T_Protocol, fd, hp, HTTP_HDR_PROTO);
+ WSLH(w, HTTP_T_Protocol, htc->fd, hp, HTTP_HDR_PROTO);
*p++ = '\0';
/* Next find the status */
@@ -488,7 +496,7 @@
while (!isspace(*p))
p++;
hp->hd[HTTP_HDR_STATUS].e = p;
- WSLH(w, HTTP_T_Status, fd, hp, HTTP_HDR_STATUS);
+ WSLH(w, HTTP_T_Status, htc->fd, hp, HTTP_HDR_STATUS);
*p++ = '\0';
/* Next find the response */
@@ -502,11 +510,12 @@
continue;
*q = '\0';
hp->hd[HTTP_HDR_RESPONSE].e = q;
- WSLH(w, HTTP_T_Response, fd, hp, HTTP_HDR_RESPONSE);
+ WSLH(w, HTTP_T_Response, htc->fd, hp, HTTP_HDR_RESPONSE);
p++;
- return (http_dissect_hdrs(w, hp, fd, p));
+ return (http_dissect_hdrs(w, hp, htc->fd, p, htc->rxbuf));
}
+
/*--------------------------------------------------------------------*/
void
Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-09-28 13:13:11 UTC (rev 2054)
+++ trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2007-09-28 20:13:48 UTC (rev 2055)
@@ -31,6 +31,8 @@
* HTTP protocol requests
*/
+#include
+#include
#include
#include
#include
@@ -39,8 +41,7 @@
#include "cache.h"
/*--------------------------------------------------------------------
- * Check if we have a complete HTTP request or response yet between the
- * two pointers given.
+ * Check if we have a complete HTTP request or response yet
*
* Return values:
* -1 No, and you can nuke the (white-space) content.
@@ -49,19 +50,19 @@
*/
static int
-http_header_complete(const char *b, const char *e)
+htc_header_complete(txt *t)
{
const char *p;
- AN(b);
- AN(e);
- assert(b <= e);
- assert(*e == '\0');
+ Tcheck(*t);
+ assert(*t->e == '\0');
/* Skip any leading white space */
- for (p = b ; isspace(*p); p++)
+ for (p = t->b ; isspace(*p); p++)
continue;
- if (*p == '\0')
- return (-1);
+ if (*p == '\0') {
+ t->e = t->b;
+ return (0);
+ }
while (1) {
p = strchr(p, '\n');
if (p == NULL)
@@ -73,169 +74,109 @@
break;
}
p++;
- return (p - b);
+ return (p - t->b);
}
/*--------------------------------------------------------------------*/
void
-http_RecvPrep(struct http *hp)
+HTC_Init(struct http_conn *htc, struct ws *ws, int fd)
{
- unsigned l;
- CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- WS_Assert(hp->ws);
- WS_Reset(hp->ws);
- WS_Reserve(hp->ws, 0);
- hp->rx.b = hp->ws->f;
- hp->rx.e = hp->rx.b;
- if (hp->pl.b != NULL) {
- l = Tlen(hp->pl);
- memmove(hp->rx.b, hp->pl.b, l);
- hp->rx.e = hp->rx.b + l;
- hp->pl.b = hp->pl.e = NULL;
- }
- *hp->rx.e = '\0';
+ htc->magic = HTTP_CONN_MAGIC;
+ htc->ws = ws;
+ htc->fd = fd;
+ WS_Reset(htc->ws);
+ WS_Reserve(htc->ws, (htc->ws->e - htc->ws->s) / 2);
+ htc->rxbuf.b = ws->f;
+ htc->rxbuf.e = ws->f;
+ htc->pipeline.b = NULL;
+ htc->pipeline.e = NULL;
}
+/*--------------------------------------------------------------------
+ * Start over, and recycle any pipelined input.
+ * The WS_Reset is safe, even though the pipelined input is stored in
+ * the ws somewhere, because WS_Reset only fiddles pointers.
+ */
+
int
-http_RecvPrepAgain(struct http *hp)
+HTC_Reinit(struct http_conn *htc)
{
+ unsigned l;
int i;
- http_RecvPrep(hp);
- if (hp->rx.b == hp->rx.e)
- return (0);
- i = http_header_complete(hp->rx.b, hp->rx.e);
- if (i == -1)
- hp->rx.e = hp->rx.b;
- if (i <= 0)
- return (0);
- WS_ReleaseP(hp->ws, hp->rx.e);
- if (hp->rx.e != hp->rx.b + i) {
- hp->pl.b = hp->rx.b + i;
- hp->pl.e = hp->rx.e;
- hp->rx.e = hp->pl.b;
+ CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
+ WS_Reset(htc->ws);
+ WS_Reserve(htc->ws, (htc->ws->e - htc->ws->s) / 2);
+ htc->rxbuf.b = htc->ws->f;
+ htc->rxbuf.e = htc->ws->f;
+ if (htc->pipeline.b != NULL) {
+ l = Tlen(htc->pipeline);
+ memmove(htc->rxbuf.b, htc->pipeline.b, l);
+ htc->rxbuf.e += l;
+ htc->pipeline.b = NULL;
+ htc->pipeline.e = NULL;
}
+ *htc->rxbuf.e = '\0';
+ i = htc_header_complete(&htc->rxbuf);
return (i);
}
/*--------------------------------------------------------------------*/
int
-http_RecvSome(int fd, struct http *hp)
+HTC_Rx(struct http_conn *htc)
{
- unsigned l;
int i;
- l = pdiff(hp->rx.e, hp->ws->e) - 1;
- l /= 2; /* Don't fill all of workspace with read-ahead */
- if (l <= 1) {
- VSL(SLT_HttpError, fd, "Received too much");
- VSLR(SLT_HttpGarbage, fd, hp->rx);
- hp->rx.b = hp->rx.e = NULL;
- WS_Release(hp->ws, 0);
- return (1);
+ CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
+ i = (htc->ws->r - htc->rxbuf.e) - 1; /* space for NUL */
+ assert(i > 0);
+ i = read(htc->fd, htc->rxbuf.e, i);
+ if (i < 0) {
+ WS_ReleaseP(htc->ws, htc->rxbuf.b);
+ return (-1);
}
- errno = 0;
- i = read(fd, hp->rx.e, l - 1);
- if (i > 0) {
- hp->rx.e += i;
- *hp->rx.e = '\0';
- i = http_header_complete(hp->rx.b, hp->rx.e);
- if (i == -1)
- hp->rx.e = hp->rx.b;
- if (i == 0)
- return (-1);
- WS_ReleaseP(hp->ws, hp->rx.e);
- if (hp->rx.e != hp->rx.b + i) {
- hp->pl.b = hp->rx.b + i;
- hp->pl.e = hp->rx.e;
- hp->rx.e = hp->pl.b;
- }
+ htc->rxbuf.e += i;
+ *htc->rxbuf.e = '\0';
+ i = htc_header_complete(&htc->rxbuf);
+ if (i == 0)
return (0);
+ WS_ReleaseP(htc->ws, htc->rxbuf.e);
+ if (htc->rxbuf.b + i < htc->rxbuf.e) {
+ htc->pipeline.b = htc->rxbuf.b + i;
+ htc->pipeline.e = htc->rxbuf.e;
+ htc->rxbuf.e = htc->pipeline.b;
}
-
- if (hp->rx.e != hp->rx.b) {
- VSL(SLT_HttpError, fd,
- "Received (only) %d bytes, errno %d",
- hp->rx.e - hp->rx.b, errno);
- VSLR(SLT_Debug, fd, hp->rx);
- } else if (errno == 0)
- VSL(SLT_HttpError, fd, "Received nothing");
- else
- VSL(SLT_HttpError, fd, "Received errno %d", errno);
- hp->rx.b = hp->rx.e = NULL;
- WS_Release(hp->ws, 0);
- return(2);
-}
-
-/*--------------------------------------------------------------------*/
-
-int
-http_RecvHead(struct http *hp, int fd)
-{
- int i;
-
- CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- http_RecvPrep(hp);
- do
- i = http_RecvSome(fd, hp);
- while (i == -1);
- return (i);
-}
-
-/*--------------------------------------------------------------------*/
-
-int
-http_GetTail(struct http *hp, unsigned len, char **b, char **e)
-{
-
- if (hp->pl.b >= hp->pl.e)
- return (0);
-
- if (len == 0)
- len = Tlen(hp->pl);
-
- if (hp->pl.b + len > hp->pl.e)
- len = Tlen(hp->pl);
- if (len == 0)
- return (0);
- *b = hp->pl.b;
- *e = hp->pl.b + len;
- hp->pl.b += len;
- Tcheck(hp->pl);
return (1);
}
-/*--------------------------------------------------------------------*/
-/* Read from fd, but soak up any tail first */
-
int
-http_Read(struct http *hp, int fd, void *p, unsigned len)
+HTC_Read(struct http_conn *htc, void *d, unsigned len)
{
+ unsigned l;
+ unsigned char *p;
int i;
- unsigned u;
- char *b = p;
- u = 0;
- if (hp->pl.b < hp->pl.e) {
- u = Tlen(hp->pl);
- if (u > len)
- u = len;
- memcpy(b, hp->pl.b, u);
- hp->pl.b += u;
- b += u;
- len -= u;
+ l = 0;
+ p = d;
+ CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
+ if (htc->pipeline.b) {
+ l = Tlen(htc->pipeline);
+ if (l > len)
+ l = len;
+ memcpy(p, htc->pipeline.b, l);
+ p += l;
+ len -= l;
+ htc->pipeline.b += l;
+ if (htc->pipeline.b == htc->pipeline.e)
+ htc->pipeline.b = htc->pipeline.e = NULL;
}
- if (hp->pl.e == hp->pl.b)
- hp->pl.b = hp->pl.e = NULL;
- if (len > 0) {
- i = read(fd, b, len);
- if (i < 0) /* XXX i == 0 ?? */
- return (i);
- u += i;
- }
- return (u);
+ if (len == 0)
+ return (l);
+ i = read(htc->fd, p, len);
+ if (i < 0)
+ return (i);
+ return (i + l);
}
-
Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-09-28 13:13:11 UTC (rev 2054)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-09-28 20:13:48 UTC (rev 2055)
@@ -70,7 +70,6 @@
PipeSession(struct sess *sp)
{
struct vbe_conn *vc;
- char *b, *e;
struct worker *w;
struct bereq *bereq;
struct pollfd fds[2];
@@ -89,8 +88,8 @@
WRK_Reset(w, &vc->fd);
http_Write(w, bereq->http, 0);
- if (http_GetTail(sp->http, 0, &b, &e) && b != e)
- WRK_Write(w, b, e - b);
+ if (sp->htc->pipeline.b != NULL)
+ WRK_Write(w, sp->htc->pipeline.b, Tlen(sp->htc->pipeline));
if (WRK_Flush(w)) {
vca_close_session(sp, "pipe");
From phk at projects.linpro.no Sat Sep 29 20:53:54 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sat, 29 Sep 2007 22:53:54 +0200 (CEST)
Subject: r2056 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070929205354.368541EC1D1@projects.linpro.no>
Author: phk
Date: 2007-09-29 22:53:53 +0200 (Sat, 29 Sep 2007)
New Revision: 2056
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_acceptor.c
trunk/varnish-cache/bin/varnishd/cache_backend_random.c
trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/cache_http.c
trunk/varnish-cache/bin/varnishd/cache_response.c
trunk/varnish-cache/bin/varnishd/cache_vcl.c
trunk/varnish-cache/bin/varnishd/cache_vrt.c
trunk/varnish-cache/bin/varnishd/cache_vrt_acl.c
trunk/varnish-cache/bin/varnishd/flint.lnt
trunk/varnish-cache/bin/varnishd/rfc2616.c
trunk/varnish-cache/bin/varnishd/shmlog.c
Log:
Another cleanup commit:
Get rid of the httptag enum, we can use the HTTP_T values instead.
Introduce WSP macro to wrap log entries which has a session.
Add our own vctyp() character classifier to simplify HTTP protocol
message parsing.
Unify http_DissectRequest() and http_DissectResponse() processing.
Unify writing of the 5 byte SHMLOG header and other minor cleanups
to shmlog code.
Silence some signed/unsigned/int width warnings in FlexeLint
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-29 20:53:53 UTC (rev 2056)
@@ -47,21 +47,22 @@
#include "miniobj.h"
enum {
+ /* Fields from the first line of HTTP proto */
HTTP_HDR_REQ,
HTTP_HDR_URL,
HTTP_HDR_PROTO,
HTTP_HDR_STATUS,
HTTP_HDR_RESPONSE,
- /* add more here */
+ /* HTTP header lines */
HTTP_HDR_FIRST,
- HTTP_HDR_MAX = 32
+ HTTP_HDR_MAX = 32 /* XXX: should be #defined */
};
/* Note: intentionally not IOV_MAX */
#define MAX_IOVS (HTTP_HDR_MAX * 2)
/* Amount of per-worker logspace */
-#define WLOGSPACE 8192
+#define WLOGSPACE 8192 /* XXX: param ? */
struct cli;
struct vsb;
@@ -73,6 +74,13 @@
/*--------------------------------------------------------------------*/
+typedef struct {
+ char *b;
+ char *e;
+} txt;
+
+/*--------------------------------------------------------------------*/
+
enum step {
#define STEP(l, u) STP_##u,
#include "steps.h"
@@ -85,24 +93,19 @@
struct ws {
char *s; /* (S)tart of buffer */
- char *e; /* (E)nd of buffer */
char *f; /* (F)ree pointer */
char *r; /* (R)eserved length */
+ char *e; /* (E)nd of buffer */
};
/*--------------------------------------------------------------------
* HTTP Request/Response/Header handling structure.
*/
-typedef struct {
- char *b;
- char *e;
-} txt;
-
enum httpwhence {
- HTTP_Rx,
- HTTP_Tx,
- HTTP_Obj
+ HTTP_Rx = 1,
+ HTTP_Tx = 2,
+ HTTP_Obj = 3
};
struct http {
@@ -120,6 +123,10 @@
unsigned nhd;
};
+/*--------------------------------------------------------------------
+ * HTTP Protocol connection structure
+ */
+
struct http_conn {
unsigned magic;
#define HTTP_CONN_MAGIC 0x3e19edd1
@@ -471,7 +478,7 @@
const char *http_GetProto(const struct http *hp);
int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
int http_DissectRequest(struct sess *sp);
-int http_DissectResponse(struct worker *w, struct http_conn *htc, struct http *sp);
+int http_DissectResponse(struct worker *w, const struct http_conn *htc, struct http *sp);
const char *http_DoConnection(struct http *hp);
void http_CopyHome(struct worker *w, int fd, struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
@@ -516,6 +523,11 @@
void WSLR(struct worker *w, enum shmlogtag tag, int id, txt t);
void WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...);
void WSL_Flush(struct worker *w);
+#define WSP(sess, tag, fmt, ...) \
+ WSL((sess)->wrk, tag, (sess)->fd, fmt, __VA_ARGS__)
+#define WSPR(sess, tag, txt) \
+ WSLR((sess)->wrk, tag, (sess)->fd, txt)
+
#define INCOMPL() do { \
VSL(SLT_Debug, 0, "INCOMPLETE AT: %s(%d)", __func__, __LINE__); \
fprintf(stderr,"INCOMPLETE AT: %s(%d)\n", (const char *)__func__, __LINE__); \
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -241,7 +241,7 @@
{
int i;
- VSL(SLT_SessionClose, sp->fd, why);
+ WSP(sp, SLT_SessionClose, "%s", why);
if (sp->fd >= 0) {
i = close(sp->fd);
assert(i == 0 || errno != EBADF); /* XXX EINVAL seen */
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -305,8 +305,7 @@
assert(vc->fd >= 0);
assert(vc->backend == sp->backend);
WSL(sp->wrk, SLT_BackendXID, vc->fd, "%u", sp->xid);
- WSL(sp->wrk, SLT_Backend, sp->fd, "%d %s", vc->fd,
- sp->backend->vcl_name);
+ WSP(sp, SLT_Backend, "%d %s", vc->fd, sp->backend->vcl_name);
return (vc);
}
return (NULL);
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_round_robin.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -290,8 +290,7 @@
assert(vc->fd >= 0);
assert(vc->backend == sp->backend);
WSL(sp->wrk, SLT_BackendXID, vc->fd, "%u", sp->xid);
- WSL(sp->wrk, SLT_Backend, sp->fd, "%d %s", vc->fd,
- sp->backend->vcl_name);
+ WSP(sp, SLT_Backend, "%d %s", vc->fd, sp->backend->vcl_name);
return (vc);
}
return (NULL);
Modified: trunk/varnish-cache/bin/varnishd/cache_backend_simple.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_simple.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -263,8 +263,7 @@
assert(vc->fd >= 0);
assert(vc->backend == sp->backend);
WSL(sp->wrk, SLT_BackendXID, vc->fd, "%u", sp->xid);
- WSL(sp->wrk, SLT_Backend, sp->fd, "%d %s", vc->fd,
- sp->backend->vcl_name);
+ WSP(sp, SLT_Backend, "%d %s", vc->fd, sp->backend->vcl_name);
return (vc);
}
return (NULL);
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -526,8 +526,7 @@
* We hit a busy object, disembark worker thread and expect
* hash code to restart us, still in STP_LOOKUP, later.
*/
- WSL(sp->wrk, SLT_Debug, sp->fd,
- "on waiting list on obj %u", sp->obj->xid);
+ WSP(sp, SLT_Debug, "on waiting list on obj %u", sp->obj->xid);
/*
* There is a non-zero risk that we come here more than once
* before we get through, in that case cnt_recv must be set
@@ -549,7 +548,7 @@
if (sp->obj->pass) {
VSL_stats->cache_hitpass++;
- WSL(sp->wrk, SLT_HitPass, sp->fd, "%u", sp->obj->xid);
+ WSP(sp, SLT_HitPass, "%u", sp->obj->xid);
HSH_Deref(sp->obj);
sp->obj = NULL;
sp->step = STP_PASS;
@@ -557,7 +556,7 @@
}
VSL_stats->cache_hit++;
- WSL(sp->wrk, SLT_Hit, sp->fd, "%u", sp->obj->xid);
+ WSP(sp, SLT_Hit, "%u", sp->obj->xid);
sp->step = STP_HIT;
return (0);
}
@@ -745,8 +744,7 @@
/* Assign XID and log */
sp->xid = ++xids; /* XXX not locked */
- WSL(sp->wrk, SLT_ReqStart, sp->fd,
- "%s %s %u", sp->addr, sp->port, sp->xid);
+ WSP(sp, SLT_ReqStart, "%s %s %u", sp->addr, sp->port, sp->xid);
/* Borrow VCL reference from worker thread */
VCL_Refresh(&sp->wrk->vcl);
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -358,7 +358,7 @@
mklen = 1;
} else if (http_GetHdr(hp, H_Transfer_Encoding, &b)) {
/* XXX: AUGH! */
- VSL(SLT_Debug, vc->fd, "Invalid Transfer-Encoding");
+ WSL(sp->wrk, SLT_Debug, vc->fd, "Invalid Transfer-Encoding");
VBE_ClosedFd(sp->wrk, vc);
return (-1);
} else if (strcmp(http_GetProto(hp), "HTTP/1.1")) {
Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -133,7 +133,7 @@
assert(*b == '\0');
b++;
assert(b == obj->hash + obj->hashlen);
- VSL(SLT_Debug, sp->fd, "Hash Match: %s", obj->hash);
+ WSP(sp, SLT_Debug, "Hash Match: %s", obj->hash);
return (0);
}
@@ -152,7 +152,7 @@
*b++ = '#';
}
*b++ = '\0';
- VSL(SLT_Debug, sp->fd, "Hash: %s", obj->hash);
+ WSP(sp, SLT_Debug, "Hash: %s", obj->hash);
assert(b <= obj->hash + obj->hashlen);
}
@@ -204,7 +204,7 @@
} else if (BAN_CheckObject(o,
h->hd[HTTP_HDR_URL].b, oh->hash)) {
o->ttl = 0;
- VSL(SLT_ExpBan, 0, "%u was banned", o->xid);
+ WSP(sp, SLT_ExpBan, "%u was banned", o->xid);
if (o->heap_idx != 0)
EXP_TTLchange(o);
} else if (o->vary == NULL || VRY_Match(sp, o->vary))
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -51,48 +51,54 @@
#include "http_headers.h"
#undef HTTPH
-enum httptag {
- HTTP_T_Request,
- HTTP_T_Response,
- HTTP_T_Status,
- HTTP_T_URL,
- HTTP_T_Protocol,
- HTTP_T_Header,
+#define C_SP (1<<0)
+#define C_CRLF (1<<1)
+#define C_LWS (C_CRLF | C_SP)
+#define C_CTL (1<<2)
+
+static unsigned char vctyptab[256] = {
+ ['\t'] = C_SP,
+ ['\n'] = C_CRLF,
+ ['\r'] = C_CRLF,
+ [' '] = C_SP,
};
-#define LOGMTX2(ax, bx) \
- [HTTP_T_##bx] = SLT_##ax##bx
+#define vctyp(x, y) (vctyptab[(int)(x)] & (y))
+#define LOGMTX2(ax, bx, cx) [bx] = SLT_##ax##cx
+
#define LOGMTX1(ax) { \
- LOGMTX2(ax, Request), \
- LOGMTX2(ax, Response), \
- LOGMTX2(ax, Status), \
- LOGMTX2(ax, URL), \
- LOGMTX2(ax, Protocol), \
- LOGMTX2(ax, Header), \
+ LOGMTX2(ax, HTTP_HDR_REQ, Request), \
+ LOGMTX2(ax, HTTP_HDR_RESPONSE, Response), \
+ LOGMTX2(ax, HTTP_HDR_STATUS, Status), \
+ LOGMTX2(ax, HTTP_HDR_URL, URL), \
+ LOGMTX2(ax, HTTP_HDR_PROTO, Protocol), \
+ LOGMTX2(ax, HTTP_HDR_FIRST, Header), \
}
-static enum shmlogtag logmtx[3][7] = {
+static enum shmlogtag logmtx[][HTTP_HDR_FIRST + 1] = {
[HTTP_Rx] = LOGMTX1(Rx),
[HTTP_Tx] = LOGMTX1(Tx),
[HTTP_Obj] = LOGMTX1(Obj)
};
static enum shmlogtag
-http2shmlog(const struct http *hp, enum httptag t)
+http2shmlog(const struct http *hp, int t)
{
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- assert(/* hp->logtag >= HTTP_Rx && */hp->logtag <= HTTP_Obj);
- assert(/* t >= HTTP_T_Request && */t <= HTTP_T_Header);
+ if (t > HTTP_HDR_FIRST)
+ t = HTTP_HDR_FIRST;
+ assert(hp->logtag >= HTTP_Rx && hp->logtag <= HTTP_Obj);
+ assert(t >= HTTP_HDR_REQ && t <= HTTP_HDR_FIRST);
return (logmtx[hp->logtag][t]);
}
static void
-WSLH(struct worker *w, enum httptag t, int fd, const struct http *hp, unsigned hdr)
+WSLH(struct worker *w, int fd, const struct http *hp, unsigned hdr)
{
- WSLR(w, http2shmlog(hp, t), fd, hp->hd[hdr]);
+ WSLR(w, http2shmlog(hp, hdr), fd, hp->hd[hdr]);
}
/*--------------------------------------------------------------------*/
@@ -378,7 +384,7 @@
hp->hdf[hp->nhd] = 0;
hp->hd[hp->nhd].b = p;
hp->hd[hp->nhd].e = q;
- WSLH(w, HTTP_T_Header, fd, hp, hp->nhd);
+ WSLH(w, fd, hp, hp->nhd);
hp->nhd++;
} else {
VSL_stats->losthdr++;
@@ -388,132 +394,117 @@
return (0);
}
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Deal with first line of HTTP protocol message.
+ */
-int
-http_DissectRequest(struct sess *sp)
+static int
+http_splitline(struct worker *w, int fd, struct http *hp, const struct http_conn *htc, int h1, int h2, int h3)
{
char *p;
- struct http_conn *htc;
- struct http *hp;
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- htc = sp->htc;
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
- hp = sp->http;
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- /* Assert a NUL at rx.e */
+ /* XXX: Assert a NUL at rx.e ? */
Tcheck(htc->rxbuf);
- hp->logtag = HTTP_Rx;
- for (p = htc->rxbuf.b ; isspace(*p); p++)
+ /* Skip leading LWS */
+ for (p = htc->rxbuf.b ; vctyp(*p, C_LWS); p++)
continue;
- /* First, the request type (GET/HEAD etc) */
- hp->hd[HTTP_HDR_REQ].b = p;
- for (; isalpha(*p); p++)
+ /* First field cannot contain SP, CRLF or CTL */
+ hp->hd[h1].b = p;
+ for (; !vctyp(*p, C_SP); p++)
+ if (vctyp(*p, C_CRLF | C_CTL))
+ return (400);
+ hp->hd[h1].e = p;
+
+ /* Skip SP */
+ for (; vctyp(*p, C_SP); p++)
;
- hp->hd[HTTP_HDR_REQ].e = p;
- WSLH(sp->wrk, HTTP_T_Request, sp->fd, hp, HTTP_HDR_REQ);
- *p++ = '\0';
- /* Next find the URI */
- while (isspace(*p) && *p != '\n')
- p++;
- if (*p == '\n') {
- WSLR(sp->wrk, SLT_HttpGarbage, sp->fd, htc->rxbuf);
- return (400);
+ /* Second field cannot contain SP, CRLF or CTL */
+ hp->hd[h2].b = p;
+ for (; !vctyp(*p, C_SP); p++)
+ if (vctyp(*p, C_CRLF | C_CTL))
+ return (400);
+ hp->hd[h2].e = p;
+
+ /* Skip SP */
+ for (; vctyp(*p, C_SP); p++)
+ ;
+
+ /* Third field is optional and cannot contain CTL */
+ if (!vctyp(*p, C_CRLF)) {
+ hp->hd[h3].b = p;
+ for (; !vctyp(*p, C_CRLF); p++)
+ if (vctyp(*p, C_CTL))
+ return (400);
+ hp->hd[h3].e = p;
}
- hp->hd[HTTP_HDR_URL].b = p;
- while (!isspace(*p))
- p++;
- hp->hd[HTTP_HDR_URL].e = p;
- WSLH(sp->wrk, HTTP_T_URL, sp->fd, hp, HTTP_HDR_URL);
- if (*p == '\n') {
- WSLR(sp->wrk, SLT_HttpGarbage, sp->fd, htc->rxbuf);
- return (400);
- }
- *p++ = '\0';
- /* Finally, look for protocol */
- while (isspace(*p) && *p != '\n')
- p++;
- if (*p == '\n') {
- WSLR(sp->wrk, SLT_HttpGarbage, sp->fd, htc->rxbuf);
- return (400);
+ /* Skip CRLF */
+ for (; vctyp(*p, C_CRLF); p++)
+ if (vctyp(*p, C_CTL))
+ return (400);
+
+ *hp->hd[h1].e = '\0';
+ WSLH(w, fd, hp, h1);
+
+ *hp->hd[h2].e = '\0';
+ WSLH(w, fd, hp, h2);
+
+ if (hp->hd[h3].e != NULL) {
+ *hp->hd[h3].e = '\0';
+ WSLH(w, fd, hp, h3);
}
- hp->hd[HTTP_HDR_PROTO].b = p;
- while (!isspace(*p))
- p++;
- hp->hd[HTTP_HDR_PROTO].e = p;
- WSLH(sp->wrk, HTTP_T_Protocol, sp->fd, hp, HTTP_HDR_PROTO);
- if (*p != '\n')
- *p++ = '\0';
- while (isspace(*p) && *p != '\n')
- p++;
- if (*p != '\n') {
- WSLR(sp->wrk, SLT_HttpGarbage, sp->fd, htc->rxbuf);
- return (400);
- }
- *p++ = '\0';
- return (http_dissect_hdrs(sp->wrk, hp, sp->fd, p, htc->rxbuf));
+ return (http_dissect_hdrs(w, hp, fd, p, htc->rxbuf));
}
/*--------------------------------------------------------------------*/
int
-http_DissectResponse(struct worker *w, struct http_conn *htc, struct http *hp)
+http_DissectRequest(struct sess *sp)
{
- char *p, *q;
+ struct http_conn *htc;
+ struct http *hp;
+ int i;
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ htc = sp->htc;
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
+ hp = sp->http;
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- /* Assert a NUL at rx.e (?) */
- Tcheck(htc->rxbuf);
+
hp->logtag = HTTP_Rx;
- for (p = htc->rxbuf.b ; isspace(*p); p++)
- continue;
+ i = http_splitline(sp->wrk, sp->fd, hp, htc,
+ HTTP_HDR_REQ, HTTP_HDR_URL, HTTP_HDR_PROTO);
- if (memcmp(p, "HTTP/1.", 7)) {
- WSLR(w, SLT_HttpGarbage, htc->fd, htc->rxbuf);
- return (400);
- }
- /* First, protocol */
- hp->hd[HTTP_HDR_PROTO].b = p;
- while (!isspace(*p))
- p++;
- hp->hd[HTTP_HDR_PROTO].e = p;
- WSLH(w, HTTP_T_Protocol, htc->fd, hp, HTTP_HDR_PROTO);
- *p++ = '\0';
+ if (i != 0)
+ WSPR(sp, SLT_HttpGarbage, htc->rxbuf);
+ return (i);
+}
- /* Next find the status */
- while (isspace(*p))
- p++;
- hp->hd[HTTP_HDR_STATUS].b = p;
- while (!isspace(*p))
- p++;
- hp->hd[HTTP_HDR_STATUS].e = p;
- WSLH(w, HTTP_T_Status, htc->fd, hp, HTTP_HDR_STATUS);
- *p++ = '\0';
+/*--------------------------------------------------------------------*/
- /* Next find the response */
- while (isspace(*p))
- p++;
- hp->hd[HTTP_HDR_RESPONSE].b = p;
- while (*p != '\n')
- p++;
- for (q = p; q > hp->hd[HTTP_HDR_RESPONSE].b &&
- isspace(q[-1]); q--)
- continue;
- *q = '\0';
- hp->hd[HTTP_HDR_RESPONSE].e = q;
- WSLH(w, HTTP_T_Response, htc->fd, hp, HTTP_HDR_RESPONSE);
- p++;
+int
+http_DissectResponse(struct worker *w, const struct http_conn *htc, struct http *hp)
+{
+ int i;
- return (http_dissect_hdrs(w, hp, htc->fd, p, htc->rxbuf));
+ CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
+ CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
+ hp->logtag = HTTP_Rx;
+
+ i = http_splitline(w, htc->fd, hp, htc,
+ HTTP_HDR_PROTO, HTTP_HDR_STATUS, HTTP_HDR_RESPONSE);
+
+ if (i != 0 || memcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.", 7))
+ WSLR(w, SLT_HttpGarbage, htc->fd, htc->rxbuf);
+ return (i);
}
/*--------------------------------------------------------------------*/
@@ -657,34 +648,19 @@
http_CopyHome(struct worker *w, int fd, struct http *hp)
{
unsigned u, l;
- enum httptag htt;
char *p;
for (u = 0; u < hp->nhd; u++) {
if (hp->hd[u].b == NULL)
continue;
- switch (u) {
- case HTTP_HDR_PROTO:
- htt = HTTP_T_Protocol;
- break;
- case HTTP_HDR_STATUS:
- htt = HTTP_T_Status;
- break;
- case HTTP_HDR_RESPONSE:
- htt = HTTP_T_Response;
- break;
- default:
- htt = HTTP_T_Header;
- break;
- }
if (hp->hd[u].b >= hp->ws->s && hp->hd[u].e <= hp->ws->e) {
- WSLH(w, htt, fd, hp, u);
+ WSLH(w, fd, hp, u);
continue;
}
l = Tlen(hp->hd[u]);
p = WS_Alloc(hp->ws, l + 1);
if (p != NULL) {
- WSLH(w, htt, fd, hp, u);
+ WSLH(w, fd, hp, u);
memcpy(p, hp->hd[u].b, l + 1);
hp->hd[u].b = p;
hp->hd[u].e = p + l;
@@ -818,25 +794,25 @@
if (resp) {
AN(hp->hd[HTTP_HDR_STATUS].b);
l = WRK_WriteH(w, &hp->hd[HTTP_HDR_PROTO], " ");
- WSLH(w, HTTP_T_Protocol, *w->wfd, hp, HTTP_HDR_PROTO);
+ WSLH(w, *w->wfd, hp, HTTP_HDR_PROTO);
l += WRK_WriteH(w, &hp->hd[HTTP_HDR_STATUS], " ");
- WSLH(w, HTTP_T_Status, *w->wfd, hp, HTTP_HDR_STATUS);
+ WSLH(w, *w->wfd, hp, HTTP_HDR_STATUS);
l += WRK_WriteH(w, &hp->hd[HTTP_HDR_RESPONSE], "\r\n");
- WSLH(w, HTTP_T_Response, *w->wfd, hp, HTTP_HDR_RESPONSE);
+ WSLH(w, *w->wfd, hp, HTTP_HDR_RESPONSE);
} else {
AN(hp->hd[HTTP_HDR_URL].b);
l = WRK_WriteH(w, &hp->hd[HTTP_HDR_REQ], " ");
- WSLH(w, HTTP_T_Request, *w->wfd, hp, HTTP_HDR_REQ);
+ WSLH(w, *w->wfd, hp, HTTP_HDR_REQ);
l += WRK_WriteH(w, &hp->hd[HTTP_HDR_URL], " ");
- WSLH(w, HTTP_T_URL, *w->wfd, hp, HTTP_HDR_URL);
+ WSLH(w, *w->wfd, hp, HTTP_HDR_URL);
l += WRK_WriteH(w, &hp->hd[HTTP_HDR_PROTO], "\r\n");
- WSLH(w, HTTP_T_Protocol, *w->wfd, hp, HTTP_HDR_PROTO);
+ WSLH(w, *w->wfd, hp, HTTP_HDR_PROTO);
}
for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) {
AN(hp->hd[u].b);
AN(hp->hd[u].e);
l += WRK_WriteH(w, &hp->hd[u], "\r\n");
- WSLH(w, HTTP_T_Header, *w->wfd, hp, u);
+ WSLH(w, *w->wfd, hp, u);
}
l += WRK_Write(w, "\r\n", -1);
return (l);
@@ -847,7 +823,13 @@
void
HTTP_Init(void)
{
+ int i;
#define HTTPH(a, b, c, d, e, f, g) b[0] = (char)strlen(b + 1);
#include "http_headers.h"
#undef HTTPH
+
+ for (i = 1; i < 32; i++)
+ if (vctyptab[i] == 0)
+ vctyptab[i] = C_CTL;
+ vctyptab[127] = C_CTL;
}
Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -69,7 +69,7 @@
{
char lm[64];
- WSL(sp->wrk, SLT_Length, sp->fd, "%u", 0);
+ WSP(sp, SLT_Length, "%u", 0);
http_ClrHeader(sp->http);
sp->http->logtag = HTTP_Tx;
@@ -119,7 +119,7 @@
if (sp->obj->response == 200 && sp->http->conds && res_do_conds(sp))
return;
- WSL(sp->wrk, SLT_Length, sp->fd, "%u", sp->obj->len);
+ WSP(sp, SLT_Length, "%u", sp->obj->len);
http_ClrHeader(sp->http);
sp->http->logtag = HTTP_Tx;
Modified: trunk/varnish-cache/bin/varnishd/cache_vcl.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vcl.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/cache_vcl.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -304,10 +304,9 @@
{ \
\
sp->handling = 0; \
- WSL(sp->wrk, SLT_VCL_call, sp->fd, "%s", #func); \
+ WSP(sp, SLT_VCL_call, "%s", #func); \
sp->vcl->func##_func(sp); \
- WSL(sp->wrk, SLT_VCL_return, sp->fd, "%s", \
- vcl_handlingname(sp->handling)); \
+ WSP(sp, SLT_VCL_return, "%s", vcl_handlingname(sp->handling)); \
assert(sp->handling & bitmap); \
assert(!(sp->handling & ~bitmap)); \
}
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -68,7 +68,7 @@
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (params->vcl_trace)
- WSL(sp->wrk, SLT_VCL_trace, sp->fd, "%u %d.%d", u,
+ WSP(sp, SLT_VCL_trace, "%u %d.%d", u,
sp->vcl->ref[u].line, sp->vcl->ref[u].pos);
}
@@ -169,7 +169,7 @@
} else {
b = vrt_assemble_string(hp, hdr + 1, p, ap);
if (b == NULL) {
- VSL(SLT_LostHeader, sp->fd, hdr + 1);
+ WSP(sp, SLT_LostHeader, "%s", hdr + 1);
} else {
http_Unset(hp, hdr);
http_SetHeader(sp->wrk, sp->fd, hp, b);
@@ -228,7 +228,7 @@
assert(num >= 100 && num <= 999);
p = WS_Alloc(sp->obj->http.ws, 4);
if (p == NULL)
- WSL(sp->wrk, SLT_LostHeader, sp->fd, "obj.status");
+ WSP(sp, SLT_LostHeader, "%s", "obj.status");
else
sprintf(p, "%d", num);
http_SetH(&sp->obj->http, HTTP_HDR_STATUS, p);
@@ -250,7 +250,7 @@
assert(num >= 100 && num <= 999);
p = WS_Alloc(sp->http->ws, 4);
if (p == NULL)
- WSL(sp->wrk, SLT_LostHeader, sp->fd, "resp.status");
+ WSP(sp, SLT_LostHeader, "%s", "resp.status");
else
sprintf(p, "%d", num);
http_SetH(sp->http, HTTP_HDR_STATUS, p);
@@ -284,7 +284,7 @@
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
- WSL(sp->wrk, SLT_TTL, sp->fd, "%u VCL %.0f %.0f",
+ WSP(sp, SLT_TTL, "%u VCL %.0f %.0f",
sp->obj->xid, a, sp->t_req);
if (a < 0)
a = 0;
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_acl.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_acl.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_acl.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -67,17 +67,17 @@
if (acln != NULL) {
if (ap->name == NULL) {
assert(r == 0);
- VSL(SLT_VCL_acl, sp->fd, "NO_MATCH %s", acln);
+ WSP(sp, SLT_VCL_acl, "NO_MATCH %s", acln);
return (r);
}
if (ap->priv == NULL) {
assert(r == 0);
- VSL(SLT_VCL_acl, sp->fd, "FAIL %s %s", acln, ap->desc);
+ WSP(sp, SLT_VCL_acl, "FAIL %s %s", acln, ap->desc);
return (r);
}
- VSL(SLT_VCL_acl, sp->fd, "%s %s %s",
- r ? "MATCH" : "NEG_MATCH", acln, ap->desc);
+ WSP(sp, SLT_VCL_acl, "%s %s %s",
+ r ? "MATCH" : "NEG_MATCH", acln, ap->desc);
}
return (r);
}
Modified: trunk/varnish-cache/bin/varnishd/flint.lnt
===================================================================
--- trunk/varnish-cache/bin/varnishd/flint.lnt 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/flint.lnt 2007-09-29 20:53:53 UTC (rev 2056)
@@ -70,20 +70,21 @@
// Review all below this line ///////////////////////////////////////////////
+-e732 // Loss of sign (arg. no. 2) (int to unsigned
+-e737 // [45] Loss of sign in promotion from int to unsigned
+-e713 // Loss of precision (assignment) (unsigned long long to long long)
+-e574 // Signed-unsigned mix with relational
+-e712 // Loss of precision (assignment) (long long to
+-e747 // Significant prototype coercion (arg. no. 2) long
+
/*
-e767 // Macro redef (system queue.h vs ours )
--e574 // Signed-unsigned mix with relational
--e712 // Loss of precision (assignment) (long long to
--e747 // Significant prototype coercion (arg. no. 2) long
--e713 // Loss of precision (assignment) (unsigned long long to long long)
-e506 // Constant value boolean
-e818 // Pointer parameter '...' could be declared as pointing to const
-e774 // Boolean within 'if' always evaluates to False
-e534 // Ignoring return value of function
-e557 // unrecog format
--e732 // Loss of sign (arg. no. 2) (int to unsigned
--e737 // [45] Loss of sign in promotion from int to unsigned
*/
Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/rfc2616.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/rfc2616.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -155,7 +155,7 @@
}
/* calculated TTL, Our time, Date, Expires, max-age, age */
- WSL(sp->wrk, SLT_TTL, sp->fd, "%u RFC %d %d %d %d %d %d", sp->xid,
+ WSP(sp, SLT_TTL, "%u RFC %d %d %d %d %d %d", sp->xid,
(int)(ttd - obj->entered), (int)obj->entered, (int)h_date,
(int)h_expires, (int)u1, (int)u2);
Modified: trunk/varnish-cache/bin/varnishd/shmlog.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/shmlog.c 2007-09-28 20:13:48 UTC (rev 2055)
+++ trunk/varnish-cache/bin/varnishd/shmlog.c 2007-09-29 20:53:53 UTC (rev 2056)
@@ -66,10 +66,6 @@
static unsigned char *logstart;
static MTX vsl_mtx;
-/*
- * This variant copies a byte-range directly to the log, without
- * taking the detour over sprintf()
- */
static void
vsl_wrap(void)
@@ -80,8 +76,24 @@
loghead->ptr = 0;
}
-/*--------------------------------------------------------------------*/
+static void
+vsl_hdr(enum shmlogtag tag, unsigned char *p, unsigned len, int id)
+{
+ p[1] = len & 0xff;
+ p[2] = (id >> 8) & 0xff;
+ p[3] = id & 0xff;
+ p[4 + len] = '\0';
+ p[5 + len] = SLT_ENDMARKER;
+ /* XXX: Write barrier here */
+ p[0] = tag;
+}
+
+/*--------------------------------------------------------------------
+ * This variant copies a byte-range directly to the log, without
+ * taking the detour over sprintf()
+ */
+
void
VSLR(enum shmlogtag tag, int id, txt t)
{
@@ -108,17 +120,11 @@
vsl_wrap();
p = logstart + loghead->ptr;
loghead->ptr += 5 + l;
- p[5 + l] = SLT_ENDMARKER;
assert(loghead->ptr < loghead->size);
UNLOCKSHM(&vsl_mtx);
- p[1] = l & 0xff;
- p[2] = (id >> 8) & 0xff;
- p[3] = id & 0xff;
memcpy(p + 4, t.b, l);
- p[4 + l] = '\0';
- /* XXX: memory barrier */
- p[0] = tag;
+ vsl_hdr(tag, p, l, id);
}
/*--------------------------------------------------------------------*/
@@ -138,35 +144,25 @@
t.b = (void*)(uintptr_t)fmt;
t.e = strchr(fmt, '\0');
VSLR(tag, id, t);
- return;
- }
+ } else {
+ LOCKSHM(&vsl_mtx);
+ VSL_stats->shm_writes++;
+ VSL_stats->shm_records++;
+ assert(loghead->ptr < loghead->size);
- LOCKSHM(&vsl_mtx);
- VSL_stats->shm_writes++;
- VSL_stats->shm_records++;
- assert(loghead->ptr < loghead->size);
+ /* Wrap if we cannot fit a full size record */
+ if (loghead->ptr + 5 + 255 + 1 >= loghead->size)
+ vsl_wrap();
- /* Wrap if we cannot fit a full size record */
- if (loghead->ptr + 5 + 255 + 1 >= loghead->size)
- vsl_wrap();
-
- p = logstart + loghead->ptr;
- n = 0;
- n = vsnprintf((char *)(p + 4), 256, fmt, ap);
- if (n > 255)
- n = 255; /* we truncate long fields */
- p[1] = n & 0xff;
- p[2] = (id >> 8) & 0xff;
- p[3] = id & 0xff;
- p[4 + n] = '\0';;
- p[5 + n] = SLT_ENDMARKER;
- p[0] = tag;
-
- loghead->ptr += 5 + n;
- assert(loghead->ptr < loghead->size);
-
- UNLOCKSHM(&vsl_mtx);
-
+ p = logstart + loghead->ptr;
+ n = vsnprintf((char *)(p + 4), 256, fmt, ap);
+ if (n > 255)
+ n = 255; /* we truncate long fields */
+ vsl_hdr(tag, p, n, id);
+ loghead->ptr += 5 + n;
+ assert(loghead->ptr < loghead->size);
+ UNLOCKSHM(&vsl_mtx);
+ }
va_end(ap);
}
@@ -192,6 +188,7 @@
p[l] = SLT_ENDMARKER;
loghead->ptr += l;
assert(loghead->ptr < loghead->size);
+ /* XXX: memory barrier here */
p[0] = w->wlog[0];
UNLOCKSHM(&vsl_mtx);
w->wlp = w->wlog;
@@ -223,14 +220,8 @@
p = w->wlp;
w->wlp += 5 + l;
assert(w->wlp < w->wle);
- p[5 + l] = SLT_ENDMARKER;
-
- p[1] = l & 0xff;
- p[2] = (id >> 8) & 0xff;
- p[3] = id & 0xff;
memcpy(p + 4, t.b, l);
- p[4 + l] = '\0';
- p[0] = tag;
+ vsl_hdr(tag, p, l, id);
w->wlr++;
}
@@ -251,30 +242,22 @@
t.b = (void*)(uintptr_t)fmt;
t.e = strchr(fmt, '\0');
WSLR(w, tag, id, t);
- return;
- }
+ } else {
+ assert(w->wlp < w->wle);
- assert(w->wlp < w->wle);
+ /* Wrap if we cannot fit a full size record */
+ if (w->wlp + 5 + 255 + 1 >= w->wle)
+ WSL_Flush(w);
- /* Wrap if we cannot fit a full size record */
- if (w->wlp + 5 + 255 + 1 >= w->wle)
- WSL_Flush(w);
-
- p = w->wlp;
- n = 0;
- n = vsnprintf((char *)(p + 4), 256, fmt, ap);
- if (n > 255)
- n = 255; /* we truncate long fields */
- p[1] = n & 0xff;
- p[2] = (id >> 8) & 0xff;
- p[3] = id & 0xff;
- p[4 + n] = '\0';;
- p[5 + n] = SLT_ENDMARKER;
- p[0] = tag;
-
- w->wlp += 5 + n;
- assert(w->wlp < w->wle);
- w->wlr++;
+ p = w->wlp;
+ n = vsnprintf((char *)(p + 4), 256, fmt, ap);
+ if (n > 255)
+ n = 255; /* we truncate long fields */
+ vsl_hdr(tag, p, n, id);
+ w->wlp += 5 + n;
+ assert(w->wlp < w->wle);
+ w->wlr++;
+ }
va_end(ap);
}
From phk at projects.linpro.no Sun Sep 30 19:42:08 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 30 Sep 2007 21:42:08 +0200 (CEST)
Subject: r2057 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070930194208.6A2C81EC21C@projects.linpro.no>
Author: phk
Date: 2007-09-30 21:42:08 +0200 (Sun, 30 Sep 2007)
New Revision: 2057
Modified:
trunk/varnish-cache/bin/varnishd/cache_pipe.c
Log:
Set the poll'ed fd to -1 when we halfclose the fd to avoid
an infinite loop on certain OS's.
Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-09-29 20:53:53 UTC (rev 2056)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2007-09-30 19:42:08 UTC (rev 2057)
@@ -52,6 +52,7 @@
if (i <= 0 || fds[1-idx].events == 0) {
AZ(shutdown(fds[idx].fd, SHUT_RD));
AZ(shutdown(fds[1-idx].fd, SHUT_WR));
+ fds[idx].fd = -1;
fds[idx].events = 0;
return;
}
@@ -60,6 +61,7 @@
if (j != i) {
AZ(shutdown(fds[idx].fd, SHUT_WR));
AZ(shutdown(fds[1-idx].fd, SHUT_RD));
+ fds[1-idx].fd = -1;
fds[1-idx].events = 0;
return;
}
From phk at projects.linpro.no Sun Sep 30 19:42:16 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 30 Sep 2007 21:42:16 +0200 (CEST)
Subject: r2058 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070930194216.5626C1EC42F@projects.linpro.no>
Author: phk
Date: 2007-09-30 21:42:16 +0200 (Sun, 30 Sep 2007)
New Revision: 2058
Modified:
trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
nitpicking
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-30 19:42:08 UTC (rev 2057)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2007-09-30 19:42:16 UTC (rev 2058)
@@ -199,12 +199,11 @@
static void *
wrk_thread(void *priv)
{
- struct worker *w, ww;
+ struct worker w[1];
struct wq *qp;
char c;
qp = priv;
- w = &ww;
memset(w, 0, sizeof *w);
w->magic = WORKER_MAGIC;
w->used = TIM_real();
From phk at projects.linpro.no Sun Sep 30 19:44:06 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 30 Sep 2007 21:44:06 +0200 (CEST)
Subject: r2059 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070930194406.5F1601EC21C@projects.linpro.no>
Author: phk
Date: 2007-09-30 21:44:06 +0200 (Sun, 30 Sep 2007)
New Revision: 2059
Modified:
trunk/varnish-cache/bin/varnishd/cache_fetch.c
Log:
Remove unused #includes
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-30 19:42:16 UTC (rev 2058)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-30 19:44:06 UTC (rev 2059)
@@ -30,16 +30,10 @@
*/
#include
-#include
#include
-#include
#include
#include
#include
-#include
-#include
-#include
-#include
#include "shmlog.h"
#include "cache.h"
From phk at projects.linpro.no Sun Sep 30 19:54:06 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 30 Sep 2007 21:54:06 +0200 (CEST)
Subject: r2060 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070930195406.475121EC290@projects.linpro.no>
Author: phk
Date: 2007-09-30 21:54:06 +0200 (Sun, 30 Sep 2007)
New Revision: 2060
Modified:
trunk/varnish-cache/bin/varnishd/cache_acceptor.c
Log:
We may not have a worker thread here, we could be called from the
acceptor code on a timeout.
Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-09-30 19:44:06 UTC (rev 2059)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2007-09-30 19:54:06 UTC (rev 2060)
@@ -241,7 +241,7 @@
{
int i;
- WSP(sp, SLT_SessionClose, "%s", why);
+ VSL(SLT_SessionClose, sp->id, "%s", why);
if (sp->fd >= 0) {
i = close(sp->fd);
assert(i == 0 || errno != EBADF); /* XXX EINVAL seen */
From phk at projects.linpro.no Sun Sep 30 19:54:28 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 30 Sep 2007 21:54:28 +0200 (CEST)
Subject: r2061 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070930195428.D382C1EC21C@projects.linpro.no>
Author: phk
Date: 2007-09-30 21:54:28 +0200 (Sun, 30 Sep 2007)
New Revision: 2061
Modified:
trunk/varnish-cache/bin/varnishd/cache_fetch.c
Log:
Significantly reduce level of paranoia.
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-30 19:54:06 UTC (rev 2060)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-30 19:54:28 UTC (rev 2061)
@@ -202,8 +202,6 @@
/*--------------------------------------------------------------------*/
-#include
-
static int
fetch_eof(struct sess *sp, struct http_conn *htc)
{
@@ -268,6 +266,8 @@
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->bereq, BEREQ_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
assert(sp->obj->busy != 0);
w = sp->wrk;
bereq = sp->bereq;
@@ -276,69 +276,51 @@
sp->obj->xid = sp->xid;
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
vc = VBE_GetFd(sp);
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
if (vc == NULL)
return (1);
WRK_Reset(w, &vc->fd);
http_Write(w, hp, 0);
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
if (WRK_Flush(w)) {
- /* XXX: cleanup */
+ VBE_ClosedFd(sp->wrk, vc);
+ /* XXX: other cleanup ? */
return (1);
}
/* XXX is this the right place? */
VSL_stats->backend_req++;
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
- CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
-
HTC_Init(htc, bereq->ws, vc->fd);
do
i = HTC_Rx(htc);
while (i == 0);
if (http_DissectResponse(sp->wrk, htc, hp)) {
- /* XXX: cleanup */
+ VBE_ClosedFd(sp->wrk, vc);
+ /* XXX: other cleanup ? */
return (1);
}
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
- CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
-
sp->obj->entered = TIM_real();
- assert(sp->obj->busy != 0);
-
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
if (http_GetHdr(hp, H_Last_Modified, &b))
sp->obj->last_modified = TIM_parse(b);
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
/* Filter into object */
hp2 = &sp->obj->http;
len = Tlen(htc->rxbuf);
len += 256; /* XXX: margin for content-length etc */
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
b = malloc(len);
AN(b);
WS_Init(sp->obj->ws_o, b, len);
http_Setup(hp2, sp->obj->ws_o);
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
hp2->logtag = HTTP_Obj;
http_CopyResp(hp2, hp);
http_FilterFields(sp->wrk, sp->fd, hp2, hp, HTTPH_A_INS);
http_CopyHome(sp->wrk, sp->fd, hp2);
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
-
/* Determine if we have a body or not */
cls = 0;
mklen = 0;
@@ -366,12 +348,8 @@
}
}
- if (mklen > 0)
- http_PrintfHeader(sp->wrk, sp->fd, hp2,
- "Content-Length: %u", sp->obj->len);
-
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
if (cls < 0) {
+ /* XXX: Wouldn't this store automatically be released ? */
while (!VTAILQ_EMPTY(&sp->obj->store)) {
st = VTAILQ_FIRST(&sp->obj->store);
VTAILQ_REMOVE(&sp->obj->store, st, list);
@@ -381,7 +359,6 @@
return (-1);
}
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
{
/* Sanity check fetch methods accounting */
unsigned uu;
@@ -392,12 +369,13 @@
assert(uu == sp->obj->len);
}
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
+ if (mklen > 0)
+ http_PrintfHeader(sp->wrk, sp->fd, hp2,
+ "Content-Length: %u", sp->obj->len);
+
if (http_GetHdr(hp, H_Connection, &b) && !strcasecmp(b, "close"))
cls = 1;
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
-
if (http_GetStatus(sp->bereq->http) == 200)
VBE_UpdateHealth(sp, vc, 1);
else if(http_GetStatus(sp->bereq->http) == 504)
@@ -408,6 +386,5 @@
else
VBE_RecycleFd(sp->wrk, vc);
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
return (0);
}
From phk at projects.linpro.no Sun Sep 30 20:08:26 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 30 Sep 2007 22:08:26 +0200 (CEST)
Subject: r2062 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070930200826.7AB841EC290@projects.linpro.no>
Author: phk
Date: 2007-09-30 22:08:26 +0200 (Sun, 30 Sep 2007)
New Revision: 2062
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Cache the numeric status code.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-30 19:54:28 UTC (rev 2061)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-30 20:08:26 UTC (rev 2062)
@@ -116,6 +116,7 @@
unsigned char conds; /* If-* headers present */
enum httpwhence logtag;
+ int status;
txt hd[HTTP_HDR_MAX];
unsigned char hdf[HTTP_HDR_MAX];
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-30 19:54:28 UTC (rev 2061)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-30 20:08:26 UTC (rev 2062)
@@ -327,8 +327,10 @@
{
Tcheck(hp->hd[HTTP_HDR_STATUS]);
- return (strtoul(hp->hd[HTTP_HDR_STATUS].b,
- NULL /* XXX */, 10));
+ if (hp->status == 0)
+ hp->status = strtoul(hp->hd[HTTP_HDR_STATUS].b,
+ NULL /* XXX */, 10));
+ return (hp->status);
}
const char *
From phk at projects.linpro.no Sun Sep 30 20:16:28 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 30 Sep 2007 22:16:28 +0200 (CEST)
Subject: r2063 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070930201628.9B0D31EC21C@projects.linpro.no>
Author: phk
Date: 2007-09-30 22:16:28 +0200 (Sun, 30 Sep 2007)
New Revision: 2063
Modified:
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
More caching of HTTP status
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-30 20:08:26 UTC (rev 2062)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-30 20:16:28 UTC (rev 2063)
@@ -300,24 +300,6 @@
i = Fetch(sp);
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
- /* Experimental. Set time for last check of backend health.
- * If the backend replied with 200, it is obviously up and running,
- * increase health parameter. If we got a 504 back, it would imply
- * that the backend is not reachable. Decrease health parameter.
- */
- sp->backend->last_check = TIM_mono();
- sp->backend->minute_limit = 1;
- if (!i){
- if (http_GetStatus(sp->bereq->http) == 200) {
- if (sp->backend->health < 10000)
- sp->backend->health++;
- } else if(http_GetStatus(sp->bereq->http) == 504) {
- if (sp->backend->health > -10000)
- sp->backend->health--;
- }
- }
-
-
VBE_free_bereq(sp->bereq);
sp->bereq = NULL;
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-30 20:08:26 UTC (rev 2062)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-09-30 20:16:28 UTC (rev 2063)
@@ -282,6 +282,7 @@
WRK_Reset(w, &vc->fd);
http_Write(w, hp, 0);
if (WRK_Flush(w)) {
+ VBE_UpdateHealth(sp, vc, -1);
VBE_ClosedFd(sp->wrk, vc);
/* XXX: other cleanup ? */
return (1);
@@ -296,6 +297,7 @@
while (i == 0);
if (http_DissectResponse(sp->wrk, htc, hp)) {
+ VBE_UpdateHealth(sp, vc, -2);
VBE_ClosedFd(sp->wrk, vc);
/* XXX: other cleanup ? */
return (1);
@@ -335,6 +337,7 @@
} else if (http_GetHdr(hp, H_Transfer_Encoding, &b)) {
/* XXX: AUGH! */
WSL(sp->wrk, SLT_Debug, vc->fd, "Invalid Transfer-Encoding");
+ VBE_UpdateHealth(sp, vc, -3);
VBE_ClosedFd(sp->wrk, vc);
return (-1);
} else if (strcmp(http_GetProto(hp), "HTTP/1.1")) {
@@ -355,6 +358,7 @@
VTAILQ_REMOVE(&sp->obj->store, st, list);
STV_free(st);
}
+ VBE_UpdateHealth(sp, vc, -4);
VBE_ClosedFd(sp->wrk, vc);
return (-1);
}
@@ -376,10 +380,7 @@
if (http_GetHdr(hp, H_Connection, &b) && !strcasecmp(b, "close"))
cls = 1;
- if (http_GetStatus(sp->bereq->http) == 200)
- VBE_UpdateHealth(sp, vc, 1);
- else if(http_GetStatus(sp->bereq->http) == 504)
- VBE_UpdateHealth(sp, vc, -1);
+ VBE_UpdateHealth(sp, vc, http_GetStatus(sp->bereq->http));
if (cls)
VBE_ClosedFd(sp->wrk, vc);
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-30 20:08:26 UTC (rev 2062)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2007-09-30 20:16:28 UTC (rev 2063)
@@ -327,9 +327,6 @@
{
Tcheck(hp->hd[HTTP_HDR_STATUS]);
- if (hp->status == 0)
- hp->status = strtoul(hp->hd[HTTP_HDR_STATUS].b,
- NULL /* XXX */, 10));
return (hp->status);
}
@@ -506,6 +503,7 @@
if (i != 0 || memcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.", 7))
WSLR(w, SLT_HttpGarbage, htc->fd, htc->rxbuf);
+ hp->status = strtoul(hp->hd[HTTP_HDR_STATUS].b, NULL /* XXX */, 10);
return (i);
}
@@ -738,6 +736,7 @@
assert(status >= 0 && status <= 999);
sprintf(stat, "%d", status);
http_PutField(w, fd, to, HTTP_HDR_STATUS, stat);
+ to->status = status;
}
void
From phk at projects.linpro.no Sun Sep 30 20:19:50 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 30 Sep 2007 22:19:50 +0200 (CEST)
Subject: r2064 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070930201950.EC67A1EC290@projects.linpro.no>
Author: phk
Date: 2007-09-30 22:19:50 +0200 (Sun, 30 Sep 2007)
New Revision: 2064
Modified:
trunk/varnish-cache/bin/varnishd/cache_center.c
Log:
Evict backend-health code which had strayed fra from it's proper place.
cache_fetch.c now reports the response code or a indicative negative
status for failed requests to the backend code.
Any timeouts, keepalives or other overhead processing of health codes
should happen in a thread in the backend handling.
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-30 20:16:28 UTC (rev 2063)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-30 20:19:50 UTC (rev 2064)
@@ -304,12 +304,6 @@
sp->bereq = NULL;
if (i) {
- /* Experimental. If the fetch failed, it would also seem
- * to be a backend problem, so decrease the health parameter.
- */
- if (sp->backend->health > -10000)
- sp->backend->health--;
-
SYN_ErrorPage(sp, 503, "Error talking to backend", 30);
} else {
RFC2616_cache_policy(sp, &sp->obj->http); /* XXX -> VCL */
@@ -402,22 +396,9 @@
static int
cnt_hit(struct sess *sp)
{
- double time_diff;
- double minutes;
assert(!sp->obj->pass);
- /* Experimental. Reduce health parameter of backend towards zero
- * if it has been more than a minute since it was checked. */
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
- time_diff = TIM_mono() - sp->backend->last_check;
- minutes = time_diff / 60;
- if (minutes > sp->backend->minute_limit) {
- sp->backend->minute_limit++;
- sp->backend->health = (int)((double)sp->backend->health / 2);
- VBE_UpdateHealth(sp, NULL, 0);
- }
-
VCL_hit_method(sp);
if (sp->handling == VCL_RET_DELIVER) {
From phk at phk.freebsd.dk Sun Sep 30 20:27:17 2007
From: phk at phk.freebsd.dk (Poul-Henning Kamp)
Date: Sun, 30 Sep 2007 20:27:17 +0000
Subject: I've kicked some of the health code out of cache_center.c
Message-ID: <14973.1191184037@critter.freebsd.dk>
Hi Cecilie,
I have kicked some of the backend health code out of cache_center.c,
you cannot implement a backend timeout function by monitoring cache-hits.
You must either start a thread in the backend policy to do these timeouts,
or calculate them on demand when requests come into the policy methods.
I will also argue that having backend->health as an integer variable
deprives you of a good chance to calculate the number on the fly
when the VCL code asks for it, so I would suggest we eliminate the
fields:
int health;
double last_check;
int minute_limit;
and push them into the private part of the backend policy, and add
another function
VBE_GetHealth()
which
VRT_r_backend_health()
uses to get the health metric.
I centralized all the UpdateHealth calls in cache_fetch.c and changed
the reporting to be the response code or a negative failure code, then
each backend policy can interpret these as it likes.
We should probably also monitor the backend responsetime, but I would
sugges we don't start to play with that, until we have the simple
stuff working.
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
From phk at projects.linpro.no Sun Sep 30 20:36:17 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 30 Sep 2007 22:36:17 +0200 (CEST)
Subject: r2065 - in trunk/varnish-cache: include lib/libvcl
Message-ID: <20070930203617.0BCC01EC21C@projects.linpro.no>
Author: phk
Date: 2007-09-30 22:36:16 +0200 (Sun, 30 Sep 2007)
New Revision: 2065
Modified:
trunk/varnish-cache/include/vcl_returns.h
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
Log:
Add "restart" action for most VCL methods.
Modified: trunk/varnish-cache/include/vcl_returns.h
===================================================================
--- trunk/varnish-cache/include/vcl_returns.h 2007-09-30 20:19:50 UTC (rev 2064)
+++ trunk/varnish-cache/include/vcl_returns.h 2007-09-30 20:36:16 UTC (rev 2065)
@@ -19,6 +19,7 @@
VCL_RET_MAC(deliver, DELIVER, (1 << 7), 7)
VCL_RET_MAC(discard, DISCARD, (1 << 8), 8)
VCL_RET_MAC(keep, KEEP, (1 << 9), 9)
+VCL_RET_MAC(restart, RESTART, (1 << 10), 10)
#else
#define VCL_RET_ERROR (1 << 0)
#define VCL_RET_LOOKUP (1 << 1)
@@ -30,18 +31,19 @@
#define VCL_RET_DELIVER (1 << 7)
#define VCL_RET_DISCARD (1 << 8)
#define VCL_RET_KEEP (1 << 9)
-#define VCL_RET_MAX 10
+#define VCL_RET_RESTART (1 << 10)
+#define VCL_RET_MAX 11
#endif
#ifdef VCL_MET_MAC
-VCL_MET_MAC(recv,RECV,(VCL_RET_ERROR|VCL_RET_PASS|VCL_RET_PIPE|VCL_RET_LOOKUP))
-VCL_MET_MAC(pipe,PIPE,(VCL_RET_ERROR|VCL_RET_PIPE))
-VCL_MET_MAC(pass,PASS,(VCL_RET_ERROR|VCL_RET_PASS))
+VCL_MET_MAC(recv,RECV,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_PIPE|VCL_RET_LOOKUP))
+VCL_MET_MAC(pipe,PIPE,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PIPE))
+VCL_MET_MAC(pass,PASS,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS))
VCL_MET_MAC(hash,HASH,(VCL_RET_HASH))
-VCL_MET_MAC(miss,MISS,(VCL_RET_ERROR|VCL_RET_PASS|VCL_RET_FETCH))
-VCL_MET_MAC(hit,HIT,(VCL_RET_ERROR|VCL_RET_PASS|VCL_RET_DELIVER))
-VCL_MET_MAC(fetch,FETCH,(VCL_RET_ERROR|VCL_RET_PASS|VCL_RET_INSERT))
-VCL_MET_MAC(deliver,DELIVER,(VCL_RET_ERROR|VCL_RET_DELIVER))
+VCL_MET_MAC(miss,MISS,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_FETCH))
+VCL_MET_MAC(hit,HIT,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER))
+VCL_MET_MAC(fetch,FETCH,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_INSERT))
+VCL_MET_MAC(deliver,DELIVER,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_DELIVER))
VCL_MET_MAC(timeout,TIMEOUT,(VCL_RET_FETCH|VCL_RET_DISCARD))
VCL_MET_MAC(discard,DISCARD,(VCL_RET_DISCARD|VCL_RET_KEEP))
#else
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-30 20:19:50 UTC (rev 2064)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-30 20:36:16 UTC (rev 2065)
@@ -330,6 +330,7 @@
vsb_cat(sb, "#define VCL_RET_DELIVER (1 << 7)\n");
vsb_cat(sb, "#define VCL_RET_DISCARD (1 << 8)\n");
vsb_cat(sb, "#define VCL_RET_KEEP (1 << 9)\n");
+ vsb_cat(sb, "#define VCL_RET_RESTART (1 << 10)\n");
vsb_cat(sb, "/*\n");
vsb_cat(sb, " * $Id$\n");
vsb_cat(sb, " *\n");
Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl 2007-09-30 20:19:50 UTC (rev 2064)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl 2007-09-30 20:36:16 UTC (rev 2065)
@@ -34,14 +34,14 @@
# Second element is list of valid return actions.
#
set methods {
- {recv {error pass pipe lookup}}
- {pipe {error pipe}}
- {pass {error pass}}
+ {recv {error restart pass pipe lookup}}
+ {pipe {error restart pipe}}
+ {pass {error restart pass}}
{hash {hash}}
- {miss {error pass fetch}}
- {hit {error pass deliver}}
- {fetch {error pass insert}}
- {deliver {error deliver}}
+ {miss {error restart pass fetch}}
+ {hit {error restart pass deliver}}
+ {fetch {error restart pass insert}}
+ {deliver {error restart deliver}}
{timeout {fetch discard}}
{discard {discard keep}}
}
@@ -59,6 +59,7 @@
deliver
discard
keep
+ restart
}
# Language keywords
From phk at projects.linpro.no Sun Sep 30 20:38:16 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 30 Sep 2007 22:38:16 +0200 (CEST)
Subject: r2066 - in trunk/varnish-cache: include lib/libvcl
Message-ID: <20070930203816.26DAB1EC290@projects.linpro.no>
Author: phk
Date: 2007-09-30 22:38:15 +0200 (Sun, 30 Sep 2007)
New Revision: 2066
Modified:
trunk/varnish-cache/include/vrt_obj.h
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
trunk/varnish-cache/lib/libvcl/vcc_obj.c
Log:
Add req.restarts variable.
Modified: trunk/varnish-cache/include/vrt_obj.h
===================================================================
--- trunk/varnish-cache/include/vrt_obj.h 2007-09-30 20:36:16 UTC (rev 2065)
+++ trunk/varnish-cache/include/vrt_obj.h 2007-09-30 20:38:15 UTC (rev 2066)
@@ -21,6 +21,7 @@
void VRT_l_req_hash(struct sess *, const char *);
struct backend * VRT_r_req_backend(struct sess *);
void VRT_l_req_backend(struct sess *, struct backend *);
+int VRT_r_req_restarts(const struct sess *);
const char * VRT_r_bereq_request(const struct sess *);
void VRT_l_bereq_request(const struct sess *, const char *, ...);
const char * VRT_r_bereq_url(const struct sess *);
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-30 20:36:16 UTC (rev 2065)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-30 20:38:15 UTC (rev 2066)
@@ -530,6 +530,7 @@
vsb_cat(sb, "void VRT_l_req_hash(struct sess *, const char *);\n");
vsb_cat(sb, "struct backend * VRT_r_req_backend(struct sess *);\n");
vsb_cat(sb, "void VRT_l_req_backend(struct sess *, struct backend *);\n");
+ vsb_cat(sb, "int VRT_r_req_restarts(const struct sess *);\n");
vsb_cat(sb, "const char * VRT_r_bereq_request(const struct sess *);\n");
vsb_cat(sb, "void VRT_l_bereq_request(const struct sess *, const char *, ...);\n");
vsb_cat(sb, "const char * VRT_r_bereq_url(const struct sess *);\n");
Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2007-09-30 20:36:16 UTC (rev 2065)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2007-09-30 20:38:15 UTC (rev 2066)
@@ -92,6 +92,11 @@
{recv pipe pass hash miss hit fetch }
"struct sess *"
}
+ { req.restarts
+ RO INT
+ {recv pipe pass hash miss hit fetch deliver }
+ "const struct sess *"
+ }
# Request sent to backend
{ bereq.request
Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_obj.c 2007-09-30 20:36:16 UTC (rev 2065)
+++ trunk/varnish-cache/lib/libvcl/vcc_obj.c 2007-09-30 20:38:15 UTC (rev 2066)
@@ -98,6 +98,13 @@
0,
VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH
},
+ { "req.restarts", INT, 12,
+ "VRT_r_req_restarts(sp)",
+ NULL,
+ V_RO,
+ 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+ },
{ "bereq.request", STRING, 13,
"VRT_r_bereq_request(sp)",
"VRT_l_bereq_request(sp, ",
From phk at projects.linpro.no Sun Sep 30 20:57:30 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 30 Sep 2007 22:57:30 +0200 (CEST)
Subject: r2067 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070930205730.F0C751EC21C@projects.linpro.no>
Author: phk
Date: 2007-09-30 22:57:30 +0200 (Sun, 30 Sep 2007)
New Revision: 2067
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
Add the first stab at a "restart" mechanism.
The intent is to be able to do things like:
backend b1 {
set backend.host = "fs.freebsd.dk";
set backend.port = "82";
}
backend b2 {
set backend.host = "fs.freebsd.dk";
set backend.port = "81";
}
backend b3 {
set backend.host = "fs.freebsd.dk";
set backend.port = "80";
}
sub vcl_recv {
remove req.http.cookie;
if (req.restarts == 0) {
set req.backend = b1;
} else if (req.restarts == 1) {
set req.backend = b2;
} else {
set req.backend = b3;
}
}
sub vcl_fetch {
if (obj.status != 200) {
restart;
}
}
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-09-30 20:38:15 UTC (rev 2066)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-09-30 20:57:30 UTC (rev 2067)
@@ -278,6 +278,8 @@
int id;
unsigned xid;
+ int restarts;
+
struct worker *wrk;
socklen_t sockaddrlen;
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-30 20:38:15 UTC (rev 2066)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-30 20:57:30 UTC (rev 2067)
@@ -303,21 +303,30 @@
VBE_free_bereq(sp->bereq);
sp->bereq = NULL;
- if (i) {
+ if (0 && i) {
SYN_ErrorPage(sp, 503, "Error talking to backend", 30);
} else {
- RFC2616_cache_policy(sp, &sp->obj->http); /* XXX -> VCL */
+ if (!i)
+ RFC2616_cache_policy(sp, &sp->obj->http); /* XXX -> VCL */
+ else
+ sp->obj->http.status = 503;
VCL_fetch_method(sp);
switch (sp->handling) {
case VCL_RET_ERROR:
+ case VCL_RET_RESTART:
sp->obj->ttl = 0;
sp->obj->cacheable = 0;
HSH_Unbusy(sp->obj);
HSH_Deref(sp->obj);
sp->obj = NULL;
- sp->step = STP_ERROR;
+ if (sp->handling == VCL_RET_ERROR)
+ sp->step = STP_ERROR;
+ else {
+ sp->restarts++;
+ sp->step = STP_RECV;
+ }
return (0);
case VCL_RET_PASS:
sp->obj->pass = 1;
@@ -696,39 +705,41 @@
{
int done;
- AZ(sp->vcl);
AZ(sp->obj);
- /* Update stats of various sorts */
- VSL_stats->client_req++; /* XXX not locked */
- sp->t_req = TIM_real();
- sp->wrk->used = sp->t_req;
- sp->wrk->acct.req++;
+ if (sp->restarts == 0) {
+ AZ(sp->vcl);
+ /* Update stats of various sorts */
+ VSL_stats->client_req++; /* XXX not locked */
+ sp->t_req = TIM_real();
+ sp->wrk->used = sp->t_req;
+ sp->wrk->acct.req++;
- /* Assign XID and log */
- sp->xid = ++xids; /* XXX not locked */
- WSP(sp, SLT_ReqStart, "%s %s %u", sp->addr, sp->port, sp->xid);
+ /* Assign XID and log */
+ sp->xid = ++xids; /* XXX not locked */
+ WSP(sp, SLT_ReqStart, "%s %s %u", sp->addr, sp->port, sp->xid);
- /* Borrow VCL reference from worker thread */
- VCL_Refresh(&sp->wrk->vcl);
- sp->vcl = sp->wrk->vcl;
- sp->wrk->vcl = NULL;
+ /* Borrow VCL reference from worker thread */
+ VCL_Refresh(&sp->wrk->vcl);
+ sp->vcl = sp->wrk->vcl;
+ sp->wrk->vcl = NULL;
- done = http_DissectRequest(sp);
- if (done != 0) {
- RES_Error(sp, done, NULL); /* XXX: STP_ERROR ? */
- sp->step = STP_DONE;
- return (0);
- }
+ done = http_DissectRequest(sp);
+ if (done != 0) {
+ RES_Error(sp, done, NULL); /* XXX: STP_ERROR ? */
+ sp->step = STP_DONE;
+ return (0);
+ }
- sp->doclose = http_DoConnection(sp->http);
+ sp->doclose = http_DoConnection(sp->http);
- /* By default we use the first backend */
- AZ(sp->backend);
- sp->backend = sp->vcl->backend[0];
- CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
+ /* By default we use the first backend */
+ AZ(sp->backend);
+ sp->backend = sp->vcl->backend[0];
+ CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
- /* XXX: Handle TRACE & OPTIONS of Max-Forwards = 0 */
+ /* XXX: Handle TRACE & OPTIONS of Max-Forwards = 0 */
+ }
VCL_recv_method(sp);
Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-30 20:38:15 UTC (rev 2066)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2007-09-30 20:57:30 UTC (rev 2067)
@@ -304,7 +304,7 @@
if (r != 0)
return;
- if (o->http.ws->s != NULL)
+ if (o->http.ws != NULL && o->http.ws->s != NULL)
free(o->http.ws->s);
if (o->vary != NULL)
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-30 20:38:15 UTC (rev 2066)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-09-30 20:57:30 UTC (rev 2067)
@@ -239,6 +239,9 @@
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
+ /* XXX: use http_GetStatus() */
+ if (sp->obj->http.status)
+ return (sp->obj->http.status);
return (atoi(sp->obj->http.hd[HTTP_HDR_STATUS].b));
}
@@ -356,6 +359,16 @@
/*--------------------------------------------------------------------*/
+int
+VRT_r_req_restarts(const struct sess *sp)
+{
+
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ return (sp->restarts);
+}
+
+/*--------------------------------------------------------------------*/
+
const char *
VRT_r_resp_proto(const struct sess *sp)
{
From phk at projects.linpro.no Sun Sep 30 21:11:21 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 30 Sep 2007 23:11:21 +0200 (CEST)
Subject: r2068 - trunk/varnish-cache/bin/varnishd
Message-ID: <20070930211121.C6DA71EC468@projects.linpro.no>
Author: phk
Date: 2007-09-30 23:11:21 +0200 (Sun, 30 Sep 2007)
New Revision: 2068
Modified:
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/heritage.h
trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
Make the number of restarts a parameter.
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-30 20:57:30 UTC (rev 2067)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-09-30 21:11:21 UTC (rev 2068)
@@ -69,6 +69,7 @@
#include "shmlog.h"
#include "vcl.h"
+#include "heritage.h"
#include "cache.h"
static unsigned xids;
@@ -707,6 +708,10 @@
AZ(sp->obj);
+ if (sp->restarts > params->max_restarts) {
+ sp->step = STP_ERROR;
+ return (0);
+ }
if (sp->restarts == 0) {
AZ(sp->vcl);
/* Update stats of various sorts */
Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h 2007-09-30 20:57:30 UTC (rev 2067)
+++ trunk/varnish-cache/bin/varnishd/heritage.h 2007-09-30 21:11:21 UTC (rev 2068)
@@ -125,6 +125,9 @@
/* LRU list ordering interval */
unsigned lru_timeout;
+ /* Maximum restarts allowed */
+ unsigned max_restarts;
+
};
extern volatile struct params *params;
Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-09-30 20:57:30 UTC (rev 2067)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2007-09-30 21:11:21 UTC (rev 2068)
@@ -555,6 +555,14 @@
}
}
+static void
+tweak_max_restarts(struct cli *cli, struct parspec *par, const char *arg)
+{
+
+ (void)par;
+ tweak_generic_uint(cli, &master.max_restarts, arg, 0, UINT_MAX);
+}
+
/*--------------------------------------------------------------------*/
/*
@@ -760,6 +768,14 @@
"exec cc -nostdinc -fpic -shared -Wl,-x -o %s -x c - < %s"
#endif
, NULL },
+ { "max_restarts", tweak_max_restarts,
+ "Upper limit on how many times a request can restart."
+#ifdef NOT_YET
+ " ESI:include counts as a restart in this context."
+#endif
+ "\nBe aware that restarts are likely to cause a hit against "
+ "the backend, so don't increase thoughtlessly.\n",
+ "4", "restarts" },
{ NULL, NULL, NULL }
};
From phk at projects.linpro.no Sun Sep 30 21:27:17 2007
From: phk at projects.linpro.no (phk at projects.linpro.no)
Date: Sun, 30 Sep 2007 23:27:17 +0200 (CEST)
Subject: r2069 - in trunk/varnish-cache: bin/varnishd include lib/libvcl
Message-ID: <20070930212717.2B0481EC42F@projects.linpro.no>
Author: phk
Date: 2007-09-30 23:27:16 +0200 (Sun, 30 Sep 2007)
New Revision: 2069
Added:
trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
Modified:
trunk/varnish-cache/bin/varnishd/Makefile.am
trunk/varnish-cache/include/vrt.h
trunk/varnish-cache/lib/libvcl/vcc_action.c
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Add VCL action "esi" and a vrt file to contain it.
Modified: trunk/varnish-cache/bin/varnishd/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishd/Makefile.am 2007-09-30 21:11:21 UTC (rev 2068)
+++ trunk/varnish-cache/bin/varnishd/Makefile.am 2007-09-30 21:27:16 UTC (rev 2069)
@@ -34,6 +34,7 @@
cache_vrt.c \
cache_vrt_acl.c \
cache_vrt_re.c \
+ cache_vrt_esi.c \
cache_ws.c \
hash_simple_list.c \
hash_classic.c \
Added: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c (rev 0)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c 2007-09-30 21:27:16 UTC (rev 2069)
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006-2007 Linpro AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp
+ *
+ * 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: cache_vrt.c 2067 2007-09-30 20:57:30Z phk $
+ *
+ * Runtime support for compiled VCL programs
+ */
+
+#include
+#include
+#include
+#include
+
+#include "shmlog.h"
+#include "vrt.h"
+#include "vcl.h"
+#include "cache.h"
+
+/*--------------------------------------------------------------------*/
+
+void
+VRT_ESI(struct sess *sp)
+{
+
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ INCOMPL();
+}
Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2007-09-30 21:11:21 UTC (rev 2068)
+++ trunk/varnish-cache/include/vrt.h 2007-09-30 21:27:16 UTC (rev 2069)
@@ -113,7 +113,9 @@
/* Simple stuff */
int VRT_strcmp(const char *s1, const char *s2);
+void VRT_ESI(struct sess *sp);
+
/* Backend related */
void VRT_init_simple_backend(struct backend **, const struct vrt_simple_backend *);
void VRT_init_round_robin_backend(struct backend **, const struct vrt_round_robin_backend *);
Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c 2007-09-30 21:11:21 UTC (rev 2068)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2007-09-30 21:27:16 UTC (rev 2069)
@@ -317,7 +317,16 @@
Fb(tl, 0, ", 1);\n");
}
+static void
+parse_esi(struct tokenlist *tl)
+{
+ vcc_NextToken(tl);
+ Fb(tl, 1, "VRT_ESI(sp);\n");
+ Expect(tl, ';');
+ vcc_NextToken(tl);
+}
+
/*--------------------------------------------------------------------*/
typedef void action_f(struct tokenlist *tl);
@@ -336,6 +345,7 @@
{ "remove", parse_remove },
{ "purge_url", parse_purge_url },
{ "purge_hash", parse_purge_hash },
+ { "esi", parse_esi },
{ NULL, NULL }
};
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-30 21:11:21 UTC (rev 2068)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2007-09-30 21:27:16 UTC (rev 2069)
@@ -492,7 +492,9 @@
vsb_cat(sb, "/* Simple stuff */\n");
vsb_cat(sb, "int VRT_strcmp(const char *s1, const char *s2);\n");
vsb_cat(sb, "\n");
+ vsb_cat(sb, "void VRT_ESI(struct sess *sp);\n");
vsb_cat(sb, "\n");
+ vsb_cat(sb, "\n");
vsb_cat(sb, "/* Backend related */\n");
vsb_cat(sb, "void VRT_init_simple_backend(struct backend **, const struct vrt_simple_backend *);\n");
vsb_cat(sb, "void VRT_init_round_robin_backend(struct backend **, const struct vrt_round_robin_backend *);\n");