php/php-bug68423.patch

56 lines
1.7 KiB
Diff
Raw Normal View History

From 23db11976889c3600cf7853fe0fd687a1c9435e6 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@php.net>
Date: Fri, 14 Nov 2014 17:29:31 +0100
Subject: [PATCH] Fix bug #68423i PHP-FPM will no longer load all pools
The hash need to be unique per IP + Port
Previous version have (IPv4 only)
sprintf(key, "%u.%u.%u.%u:%u", IPQUAD(&sa_in->sin_addr), (unsigned int) ntohs(sa_in->sin_port));
---
sapi/fpm/fpm/fpm_sockets.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c
index da14d63..3e4f09c 100644
--- a/sapi/fpm/fpm/fpm_sockets.c
+++ b/sapi/fpm/fpm/fpm_sockets.c
@@ -85,13 +85,24 @@ static void *fpm_get_in_addr(struct sockaddr *sa) /* {{{ */
}
/* }}} */
+static int fpm_get_in_port(struct sockaddr *sa) /* {{{ */
+{
+ if (sa->sa_family == AF_INET) {
+ return ntohs(((struct sockaddr_in*)sa)->sin_port);
+ }
+
+ return ntohs(((struct sockaddr_in6*)sa)->sin6_port);
+}
+/* }}} */
+
static int fpm_sockets_hash_op(int sock, struct sockaddr *sa, char *key, int type, int op) /* {{{ */
{
if (key == NULL) {
switch (type) {
case FPM_AF_INET : {
- key = alloca(INET6_ADDRSTRLEN);
- inet_ntop(sa->sa_family, fpm_get_in_addr(sa), key, sizeof key);
+ key = alloca(INET6_ADDRSTRLEN+10);
+ inet_ntop(sa->sa_family, fpm_get_in_addr(sa), key, INET6_ADDRSTRLEN);
+ sprintf(key+strlen(key), ":%d", fpm_get_in_port(sa));
break;
}
@@ -246,7 +257,7 @@ static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /*
char *addr = NULL;
int addr_len;
int port = 0;
- int sock;
+ int sock = -1;
int status;
if (port_str) { /* this is host:port pair */
--
2.1.0