From ef966747682f17c307e228903ea2a54594494ce7 Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 3 Jul 2006 18:35:39 +0000 Subject: [PATCH] Handle IPv6 address -> string conversion too git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@287 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 2 +- varnish-cache/bin/varnishd/cache_acceptor.c | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 93969aca..b8b1669c 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -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; diff --git a/varnish-cache/bin/varnishd/cache_acceptor.c b/varnish-cache/bin/varnishd/cache_acceptor.c index 92d9ccfc..004ee5fc 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor.c +++ b/varnish-cache/bin/varnishd/cache_acceptor.c @@ -122,9 +122,9 @@ accept_f(int fd, short event, void *arg) { 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 @@ accept_f(int fd, short event, void *arg) 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(); -- 2.39.5