r2657 - in trunk/varnish-cache: include lib/libvarnish

phk at projects.linpro.no phk at projects.linpro.no
Mon Jun 9 15:01:28 CEST 2008


Author: phk
Date: 2008-06-09 15:01:27 +0200 (Mon, 09 Jun 2008)
New Revision: 2657

Modified:
   trunk/varnish-cache/include/vss.h
   trunk/varnish-cache/lib/libvarnish/vss.c
Log:
Add a VSS_bind() function, using the meat of VSS_listen()


Modified: trunk/varnish-cache/include/vss.h
===================================================================
--- trunk/varnish-cache/include/vss.h	2008-06-09 08:35:38 UTC (rev 2656)
+++ trunk/varnish-cache/include/vss.h	2008-06-09 13:01:27 UTC (rev 2657)
@@ -32,5 +32,6 @@
 
 int VSS_parse(const char *str, char **addr, char **port);
 int VSS_resolve(const char *addr, const char *port, struct vss_addr ***ta);
+int VSS_bind(const struct vss_addr *addr);
 int VSS_listen(const struct vss_addr *addr, int depth);
 int VSS_connect(const struct vss_addr *addr);

Modified: trunk/varnish-cache/lib/libvarnish/vss.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/vss.c	2008-06-09 08:35:38 UTC (rev 2656)
+++ trunk/varnish-cache/lib/libvarnish/vss.c	2008-06-09 13:01:27 UTC (rev 2657)
@@ -165,14 +165,15 @@
 }
 
 /*
- * Given a struct vss_addr, open a socket of the appropriate type, bind it
- * to the requested address, and start listening.
+ * Given a struct vss_addr, open a socket of the appropriate type, and bind
+ * it to the requested address.
  *
  * If the address is an IPv6 address, the IPV6_V6ONLY option is set to
  * avoid conflicts between INADDR_ANY and IN6ADDR_ANY.
  */
+
 int
-VSS_listen(const struct vss_addr *va, int depth)
+VSS_bind(const struct vss_addr *va)
 {
 	int sd, val;
 
@@ -202,10 +203,28 @@
 		(void)close(sd);
 		return (-1);
 	}
-	if (listen(sd, depth) != 0) {
-		perror("listen()");
-		(void)close(sd);
-		return (-1);
+	return (sd);
+}
+
+/*
+ * Given a struct vss_addr, open a socket of the appropriate type, bind it
+ * to the requested address, and start listening.
+ *
+ * If the address is an IPv6 address, the IPV6_V6ONLY option is set to
+ * avoid conflicts between INADDR_ANY and IN6ADDR_ANY.
+ */
+int
+VSS_listen(const struct vss_addr *va, int depth)
+{
+	int sd;
+
+	sd = VSS_bind(va);
+	if (sd >= 0)  {
+		if (listen(sd, depth) != 0) {
+			perror("listen()");
+			(void)close(sd);
+			return (-1);
+		}
 	}
 	return (sd);
 }




More information about the varnish-commit mailing list