r287 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Jul 3 20:35:39 CEST 2006


Author: phk
Date: 2006-07-03 20:35:39 +0200 (Mon, 03 Jul 2006)
New Revision: 287

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_acceptor.c
Log:
Handle IPv6 address -> string conversion too


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2006-07-03 18:03:44 UTC (rev 286)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2006-07-03 18:35:39 UTC (rev 287)
@@ -6,7 +6,7 @@
 
 #include "vcl_returns.h"
 
-#define VCA_ADDRBUFSIZE		32	/* Sizeof ascii network address */
+#define VCA_ADDRBUFSIZE		64	/* Sizeof ascii network address */
 
 struct event_base;
 struct cli;

Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2006-07-03 18:03:44 UTC (rev 286)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2006-07-03 18:35:39 UTC (rev 287)
@@ -122,9 +122,9 @@
 {
 	socklen_t l;
 	struct sessmem *sm;
-	struct sockaddr addr;
+	struct sockaddr addr[2];
 	struct sess *sp;
-	char port[10];
+	char port[NI_MAXSERV];
 	int i;
 
 	VSL_stats->client_conn++;
@@ -141,17 +141,21 @@
 	sp->mem = sm;
 
 	l = sizeof addr;
-	sp->fd = accept(fd, &addr, &l);
+	sp->fd = accept(fd, addr, &l);
 	if (sp->fd < 0) {
 		free(sp);
 		return;
 	}
 	i = 1;
 	AZ(setsockopt(sp->fd, SOL_SOCKET, SO_NOSIGPIPE, &i, sizeof i));
-	AZ(getnameinfo(&addr, l,
+	i = getnameinfo(addr, l,
 	    sp->addr, VCA_ADDRBUFSIZE,
-	    port, sizeof port, NI_NUMERICHOST | NI_NUMERICSERV));
-	strlcat(sp->addr, ":", VCA_ADDRBUFSIZE);
+	    port, sizeof port, NI_NUMERICHOST | NI_NUMERICSERV);
+	if (i) {
+		printf("getnameinfo = %d %s\n", i,
+		    gai_strerror(i));
+	}
+	strlcat(sp->addr, " ", VCA_ADDRBUFSIZE);
 	strlcat(sp->addr, port, VCA_ADDRBUFSIZE);
 	VSL(SLT_SessionOpen, sp->fd, "%s", sp->addr);
 	sp->http = http_New();




More information about the varnish-commit mailing list