[master] 58db1e6 Isolate VTCP in its own include file

Poul-Henning Kamp phk at varnish-cache.org
Sun Oct 9 20:02:38 CEST 2011


commit 58db1e659a6b6055e27246047ec28218f991d2b2
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sun Oct 9 18:02:15 2011 +0000

    Isolate VTCP in its own include file

diff --git a/bin/varnishd/cache_acceptor.c b/bin/varnishd/cache_acceptor.c
index af5edec..87a9180 100644
--- a/bin/varnishd/cache_acceptor.c
+++ b/bin/varnishd/cache_acceptor.c
@@ -33,6 +33,7 @@
 #include "cache.h"
 
 #include "vcli.h"
+#include "vtcp.h"
 #include "cli_priv.h"
 
 static pthread_t	VCA_thread;
diff --git a/bin/varnishd/cache_backend.c b/bin/varnishd/cache_backend.c
index a724923..3ed7fcd 100644
--- a/bin/varnishd/cache_backend.c
+++ b/bin/varnishd/cache_backend.c
@@ -39,6 +39,7 @@
 
 #include "cache_backend.h"
 #include "vrt.h"
+#include "vtcp.h"
 
 /*--------------------------------------------------------------------
  * The "simple" director really isn't, since thats where all the actual
diff --git a/bin/varnishd/cache_backend_poll.c b/bin/varnishd/cache_backend_poll.c
index be8ee6a..c90cda9 100644
--- a/bin/varnishd/cache_backend_poll.c
+++ b/bin/varnishd/cache_backend_poll.c
@@ -45,6 +45,7 @@
 #include "cli_priv.h"
 #include "cache.h"
 #include "vrt.h"
+#include "vtcp.h"
 #include "cache_backend.h"
 
 /* Default averaging rate, we want something pretty responsive */
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 0b7f8bf..1415170 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -70,6 +70,7 @@ DOT acceptor -> start [style=bold,color=green]
 #include "cache.h"
 
 #include "vcl.h"
+#include "vtcp.h"
 #include "cli_priv.h"
 #include "hash_slinger.h"
 #include "stevedore.h"
diff --git a/bin/varnishd/cache_dir.c b/bin/varnishd/cache_dir.c
index 03fdf26..ef882bf 100644
--- a/bin/varnishd/cache_dir.c
+++ b/bin/varnishd/cache_dir.c
@@ -34,6 +34,7 @@
 
 #include "cache.h"
 #include "cache_backend.h"
+#include "vtcp.h"
 
 /* Close a connection ------------------------------------------------*/
 
diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c
index df56c7a..d18e726 100644
--- a/bin/varnishd/cache_fetch.c
+++ b/bin/varnishd/cache_fetch.c
@@ -38,6 +38,7 @@
 #include "stevedore.h"
 #include "cli_priv.h"
 #include "vct.h"
+#include "vtcp.h"
 
 static unsigned fetchfrag;
 
diff --git a/bin/varnishd/cache_pipe.c b/bin/varnishd/cache_pipe.c
index e02da80..74343ba 100644
--- a/bin/varnishd/cache_pipe.c
+++ b/bin/varnishd/cache_pipe.c
@@ -35,6 +35,7 @@
 #include <poll.h>
 
 #include "cache.h"
+#include "vtcp.h"
 
 static int
 rdf(int fd0, int fd1)
diff --git a/bin/varnishd/cache_pool.c b/bin/varnishd/cache_pool.c
index 0380b55..e146043 100644
--- a/bin/varnishd/cache_pool.c
+++ b/bin/varnishd/cache_pool.c
@@ -50,6 +50,7 @@
 
 #include "cache_waiter.h"
 #include "hash_slinger.h"
+#include "vtcp.h"
 
 /*--------------------------------------------------------------------
  * MAC OS/X is incredibly moronic when it comes to time and such...
diff --git a/bin/varnishd/cache_vrt_var.c b/bin/varnishd/cache_vrt_var.c
index ae65058..1343ae4 100644
--- a/bin/varnishd/cache_vrt_var.c
+++ b/bin/varnishd/cache_vrt_var.c
@@ -36,6 +36,7 @@
 #include "cache.h"
 
 #include "vrt.h"
+#include "vtcp.h"
 #include "vrt_obj.h"
 #include "cache_backend.h"
 #include "hash_slinger.h"
diff --git a/bin/varnishd/mgt_child.c b/bin/varnishd/mgt_child.c
index ba2effe..6c1cf71 100644
--- a/bin/varnishd/mgt_child.c
+++ b/bin/varnishd/mgt_child.c
@@ -52,6 +52,7 @@
 #include "vlu.h"
 #include "vss.h"
 #include "vbm.h"
+#include "vtcp.h"
 
 pid_t		child_pid = -1;
 
diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c
index eccf268..4488d51 100644
--- a/bin/varnishd/mgt_cli.c
+++ b/bin/varnishd/mgt_cli.c
@@ -51,6 +51,7 @@
 #include "vev.h"
 #include "vlu.h"
 #include "vss.h"
+#include "vtcp.h"
 
 
 #include "mgt.h"
diff --git a/bin/varnishtest/vtc_client.c b/bin/varnishtest/vtc_client.c
index 2c75622..55e25fa 100644
--- a/bin/varnishtest/vtc_client.c
+++ b/bin/varnishtest/vtc_client.c
@@ -38,6 +38,7 @@
 #include "vtc.h"
 
 #include "vss.h"
+#include "vtcp.h"
 #include "libvarnish.h"
 
 struct client {
diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c
index 4582d4c..50816bc 100644
--- a/bin/varnishtest/vtc_http.c
+++ b/bin/varnishtest/vtc_http.c
@@ -41,6 +41,7 @@
 #include "libvarnish.h"
 
 #include "vtc.h"
+#include "vtcp.h"
 
 #include "vgz.h"
 
diff --git a/bin/varnishtest/vtc_server.c b/bin/varnishtest/vtc_server.c
index d541d67..afe62af 100644
--- a/bin/varnishtest/vtc_server.c
+++ b/bin/varnishtest/vtc_server.c
@@ -37,6 +37,7 @@
 #include <sys/socket.h>
 
 #include "vtc.h"
+#include "vtcp.h"
 
 #include "libvarnish.h"
 #include "vss.h"
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 7362f1f..8b310f6 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -46,6 +46,7 @@
 #include <sys/socket.h>
 
 #include "vtc.h"
+#include "vtcp.h"
 
 #include "libvarnish.h"
 
diff --git a/include/Makefile.am b/include/Makefile.am
index 0f1782f..66c2ddd 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -55,7 +55,8 @@ nobase_noinst_HEADERS = \
 	vrt_obj.h \
 	vsb.h \
 	vsha256.h \
-	vss.h
+	vss.h \
+	vtcp.h
 
 tbl/vrt_stv_var.h tbl/vcl_returns.h vcl.h vrt_obj.h: $(top_srcdir)/lib/libvcl/generate.py $(top_srcdir)/include/vrt.h
 	mkdir -p tbl
diff --git a/include/libvarnish.h b/include/libvarnish.h
index b016848..6008781 100644
--- a/include/libvarnish.h
+++ b/include/libvarnish.h
@@ -48,40 +48,6 @@ typedef void sub_func_f(void*);
 int SUB_run(struct vsb *sb, sub_func_f *func, void *priv, const char *name,
     int maxlines);
 
-/* from libvarnish/tcp.c */
-/* NI_MAXHOST and NI_MAXSERV are ridiculously long for numeric format */
-#define VTCP_ADDRBUFSIZE		64
-#define VTCP_PORTBUFSIZE		16
-
-#if (defined (__SVR4) && defined (__sun)) || defined (__NetBSD__)
-/*
- * Solaris returns EINVAL if the other end unexepectedly reset the
- * connection.  This is a bug in Solaris and documented behaviour on NetBSD.
- */
-#define VTCP_Check(a) ((a) == 0 || errno == ECONNRESET || errno == ENOTCONN \
-    || errno == EINVAL)
-#else
-#define VTCP_Check(a) ((a) == 0 || errno == ECONNRESET || errno == ENOTCONN)
-#endif
-
-#define VTCP_Assert(a) assert(VTCP_Check(a))
-
-void VTCP_myname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen);
-void VTCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen);
-int VTCP_filter_http(int sock);
-int VTCP_blocking(int sock);
-int VTCP_nonblocking(int sock);
-int VTCP_linger(int sock, int linger);
-#ifdef SOL_SOCKET
-int VTCP_port(const struct sockaddr_storage *addr);
-void VTCP_name(const struct sockaddr_storage *addr, unsigned l, char *abuf,
-    unsigned alen, char *pbuf, unsigned plen);
-int VTCP_connect(int s, const struct sockaddr_storage *name, socklen_t namelen,
-    int msec);
-void VTCP_close(int *s);
-void VTCP_set_read_timeout(int s, double seconds);
-#endif
-
 /* from libvarnish/time.c */
 #define TIM_FORMAT_SIZE 30
 void TIM_format(double t, char *p);
diff --git a/include/vtcp.h b/include/vtcp.h
new file mode 100644
index 0000000..022f101
--- /dev/null
+++ b/include/vtcp.h
@@ -0,0 +1,64 @@
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006-2011 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
+ *
+ * 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.
+ *
+ */
+
+/* from libvarnish/tcp.c */
+/* NI_MAXHOST and NI_MAXSERV are ridiculously long for numeric format */
+#define VTCP_ADDRBUFSIZE		64
+#define VTCP_PORTBUFSIZE		16
+
+#if (defined (__SVR4) && defined (__sun)) || defined (__NetBSD__)
+/*
+ * Solaris returns EINVAL if the other end unexepectedly reset the
+ * connection.  This is a bug in Solaris and documented behaviour on NetBSD.
+ */
+#define VTCP_Check(a) ((a) == 0 || errno == ECONNRESET || errno == ENOTCONN \
+    || errno == EINVAL)
+#else
+#define VTCP_Check(a) ((a) == 0 || errno == ECONNRESET || errno == ENOTCONN)
+#endif
+
+#define VTCP_Assert(a) assert(VTCP_Check(a))
+
+void VTCP_myname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen);
+void VTCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen);
+int VTCP_filter_http(int sock);
+int VTCP_blocking(int sock);
+int VTCP_nonblocking(int sock);
+int VTCP_linger(int sock, int linger);
+
+#ifdef SOL_SOCKET
+int VTCP_port(const struct sockaddr_storage *addr);
+void VTCP_name(const struct sockaddr_storage *addr, unsigned l, char *abuf,
+    unsigned alen, char *pbuf, unsigned plen);
+int VTCP_connect(int s, const struct sockaddr_storage *name, socklen_t namelen,
+    int msec);
+void VTCP_close(int *s);
+void VTCP_set_read_timeout(int s, double seconds);
+#endif
diff --git a/lib/libvarnish/tcp.c b/lib/libvarnish/tcp.c
index c612e97..e8932e8 100644
--- a/lib/libvarnish/tcp.c
+++ b/lib/libvarnish/tcp.c
@@ -51,8 +51,7 @@
 #include <unistd.h>
 #include <math.h>
 
-#include "config.h"
-
+#include "vtcp.h"
 #include "libvarnish.h"
 
 /*--------------------------------------------------------------------*/
diff --git a/lib/libvarnish/vss.c b/lib/libvarnish/vss.c
index 42b4db7..ff19ac7 100644
--- a/lib/libvarnish/vss.c
+++ b/lib/libvarnish/vss.c
@@ -44,6 +44,7 @@
 #include <unistd.h>
 
 #include "libvarnish.h"
+#include "vtcp.h"
 #include "vss.h"
 
 /* lightweight addrinfo */
diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index 544e2dc..847c705 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -32,6 +32,7 @@
 #include <syslog.h>
 #include <netinet/in.h>
 #include "vrt.h"
+#include "vtcp.h"
 #include "../../bin/varnishd/cache.h"
 
 #include "vcc_if.h"



More information about the varnish-commit mailing list