com php-src: Raise a warning when listen = hostname used and is resolved as multiple addresses: sapi/fp m/fpm/fpm_sockets.c

From: Date: Thu, 20 Nov 2014 09:15:15 +0000
Subject: com php-src: Raise a warning when listen = hostname used and is resolved as multiple addresses: sapi/fp m/fpm/fpm_sockets.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-83169@lists.php.net to get a copy of this message
Commit: 9fd54bd9d8f20f4d56c3d8e0209c6c34fb3bfc98 Author: Remi Collet <remi@php.net> Thu, 20 Nov 2014 10:15:15 +0100 Parents: 914787491d78cded722318d0796b13f11cb197f8 Branches: PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9fd54bd9d8f20f4d56c3d8e0209c6c34fb3bfc98 Log: Raise a warning when listen = hostname used and is resolved as multiple addresses Using getaddrinfo is perhaps not a good idea... if we are not able to listen on multiple addresses... At least this message should help to diagnose problem, ex .. Found address for localhost, socket opened on ::1 .. Found multiple addresses for localhost, 127.0.0.1 ignored Changed paths: M sapi/fpm/fpm/fpm_sockets.c Diff: diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c index 9d9def3..0286f0e 100644 --- a/sapi/fpm/fpm/fpm_sockets.c +++ b/sapi/fpm/fpm/fpm_sockets.c @@ -255,6 +255,7 @@ static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /* char *dup_address = strdup(wp->config->listen_address); char *port_str = strrchr(dup_address, ':'); char *addr = NULL; + char tmpbuf[INET6_ADDRSTRLEN]; int addr_len; int port = 0; int sock = -1; @@ -302,14 +303,18 @@ static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /* return -1; } - free(dup_address); - for (p = servinfo; p != NULL; p = p->ai_next) { - if ((sock = fpm_sockets_get_listening_socket(wp, p->ai_addr, p->ai_addrlen)) != -1) { - break; + inet_ntop(p->ai_family, fpm_get_in_addr(p->ai_addr), tmpbuf, INET6_ADDRSTRLEN); + if (sock < 0) { + if ((sock = fpm_sockets_get_listening_socket(wp, p->ai_addr, p->ai_addrlen)) != -1) { + zlog(ZLOG_DEBUG, "Found address for %s, socket opened on %s", dup_address, tmpbuf); + } + } else { + zlog(ZLOG_WARNING, "Found multiple addresses for %s, %s ignored", dup_address, tmpbuf); } } + free(dup_address); freeaddrinfo(servinfo); return sock;

« previous php.cvs (#83169) next »