summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Zelenka <bukka@php.net>2018-03-30 17:58:29 +0100
committerJakub Zelenka <bukka@php.net>2018-03-30 17:58:29 +0100
commit8b642af484fba85c4e1a1a0a71d7f0c998740002 (patch)
tree590912b5a8c52e7604772950a11ce192ed1444a0
parent35e3d597f529eedf76711630d0f3b31426ba9b83 (diff)
parent2688023c7fdc1b1e319cb81c28a862f65a2109fb (diff)
downloadphp-git-8b642af484fba85c4e1a1a0a71d7f0c998740002.tar.gz
Merge branch 'PHP-7.1' into PHP-7.2
-rw-r--r--NEWS5
-rw-r--r--sapi/fpm/fpm/fpm_sockets.c89
-rw-r--r--sapi/fpm/fpm/fpm_sockets.h5
3 files changed, 75 insertions, 24 deletions
diff --git a/NEWS b/NEWS
index ed7d417f21..e13417c1aa 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,11 @@ PHP NEWS
- Date:
. Fixed bug #76131 (mismatch arginfo for date_create). (carusogabriel)
+- FPM:
+ . Fixed bug #68440 (ERROR: failed to reload: execvp() failed: Argument list
+ too long). (Jacob Hipps)
+ . Fixed incorrect write to getenv result in FPM reload. (Jakub Zelenka)
+
- mbstring:
. Fixed bug #75944 (Wrong cp1251 detection). (dmk001)
. Fixed bug #76113 (mbstring does not build with Oniguruma 6.8.1).
diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c
index d58a8f82b6..36a66544d7 100644
--- a/sapi/fpm/fpm/fpm_sockets.c
+++ b/sapi/fpm/fpm/fpm_sockets.c
@@ -44,6 +44,10 @@ enum { FPM_GET_USE_SOCKET = 1, FPM_STORE_SOCKET = 2, FPM_STORE_USE_SOCKET = 3 };
static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */
{
unsigned i;
+ unsigned socket_set_count = 0;
+ unsigned socket_set[FPM_ENV_SOCKET_SET_MAX];
+ unsigned socket_set_buf = 0;
+ char envname[32];
char *env_value = 0;
int p = 0;
struct listening_socket_s *ls = sockets_list.data;
@@ -54,8 +58,20 @@ static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */
} else { /* on PARENT EXEC we want socket fds to be inherited through environment variable */
char fd[32];
sprintf(fd, "%d", ls->sock);
- env_value = realloc(env_value, p + (p ? 1 : 0) + strlen(ls->key) + 1 + strlen(fd) + 1);
- p += sprintf(env_value + p, "%s%s=%s", p ? "," : "", ls->key, fd);
+
+ socket_set_buf = (i % FPM_ENV_SOCKET_SET_SIZE == 0 && i) ? 1 : 0;
+ env_value = realloc(env_value, p + (p ? 1 : 0) + strlen(ls->key) + 1 + strlen(fd) + socket_set_buf + 1);
+
+ if (i % FPM_ENV_SOCKET_SET_SIZE == 0) {
+ socket_set[socket_set_count] = p + socket_set_buf;
+ socket_set_count++;
+ if (i) {
+ *(env_value + p + 1) = 0;
+ }
+ }
+
+ p += sprintf(env_value + p + socket_set_buf, "%s%s=%s", (p && !socket_set_buf) ? "," : "", ls->key, fd);
+ p += socket_set_buf;
}
if (which == FPM_CLEANUP_PARENT_EXIT_MAIN) {
@@ -67,7 +83,14 @@ static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */
}
if (env_value) {
- setenv("FPM_SOCKETS", env_value, 1);
+ for (i = 0; i < socket_set_count; i++) {
+ if (!i) {
+ strcpy(envname, "FPM_SOCKETS");
+ } else {
+ sprintf(envname, "FPM_SOCKETS_%d", i);
+ }
+ setenv(envname, env_value + socket_set[i], 1);
+ }
free(env_value);
}
@@ -352,7 +375,9 @@ int fpm_sockets_init_main() /* {{{ */
{
unsigned i, lq_len;
struct fpm_worker_pool_s *wp;
- char *inherited = getenv("FPM_SOCKETS");
+ char sockname[32];
+ char sockpath[256];
+ char *inherited;
struct listening_socket_s *ls;
if (0 == fpm_array_init(&sockets_list, sizeof(struct listening_socket_s), 10)) {
@@ -360,28 +385,46 @@ int fpm_sockets_init_main() /* {{{ */
}
/* import inherited sockets */
- while (inherited && *inherited) {
- char *comma = strchr(inherited, ',');
- int type, fd_no;
- char *eq;
-
- if (comma) {
- *comma = '\0';
+ for (i = 0; i < FPM_ENV_SOCKET_SET_MAX; i++) {
+ if (!i) {
+ strcpy(sockname, "FPM_SOCKETS");
+ } else {
+ sprintf(sockname, "FPM_SOCKETS_%d", i);
}
-
- eq = strchr(inherited, '=');
- if (eq) {
- *eq = '\0';
- fd_no = atoi(eq + 1);
- type = fpm_sockets_domain_from_address(inherited);
- zlog(ZLOG_NOTICE, "using inherited socket fd=%d, \"%s\"", fd_no, inherited);
- fpm_sockets_hash_op(fd_no, 0, inherited, type, FPM_STORE_SOCKET);
+ inherited = getenv(sockname);
+ if (!inherited) {
+ break;
}
- if (comma) {
- inherited = comma + 1;
- } else {
- inherited = 0;
+ while (inherited && *inherited) {
+ char *comma = strchr(inherited, ',');
+ int type, fd_no;
+ char *eq;
+
+ if (comma) {
+ *comma = '\0';
+ }
+
+ eq = strchr(inherited, '=');
+ if (eq) {
+ int sockpath_len = eq - inherited;
+ if (sockpath_len > 255) {
+ /* this should never happen as UDS limit is lower */
+ sockpath_len = 255;
+ }
+ memcpy(sockpath, inherited, sockpath_len);
+ sockpath[sockpath_len] = '\0';
+ fd_no = atoi(eq + 1);
+ type = fpm_sockets_domain_from_address(sockpath);
+ zlog(ZLOG_NOTICE, "using inherited socket fd=%d, \"%s\"", fd_no, sockpath);
+ fpm_sockets_hash_op(fd_no, 0, sockpath, type, FPM_STORE_SOCKET);
+ }
+
+ if (comma) {
+ inherited = comma + 1;
+ } else {
+ inherited = 0;
+ }
}
}
diff --git a/sapi/fpm/fpm/fpm_sockets.h b/sapi/fpm/fpm/fpm_sockets.h
index 2bd3d58249..98b40ff206 100644
--- a/sapi/fpm/fpm/fpm_sockets.h
+++ b/sapi/fpm/fpm/fpm_sockets.h
@@ -19,9 +19,12 @@
#if (__FreeBSD__) || (__OpenBSD__)
#define FPM_BACKLOG_DEFAULT -1
#else
-#define FPM_BACKLOG_DEFAULT 511
+#define FPM_BACKLOG_DEFAULT 511
#endif
+#define FPM_ENV_SOCKET_SET_MAX 256
+#define FPM_ENV_SOCKET_SET_SIZE 128
+
enum fpm_address_domain fpm_sockets_domain_from_address(char *addr);
int fpm_sockets_init_main();
int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq);