Skip to content

Commit dd9c6a3

Browse files
author
Jérôme Loyet
committed
INSTALL_ROOT was not set correctly for fpm binary
1 parent c077c39 commit dd9c6a3

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

sapi/fpm/Makefile.frag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ install-fpm: install-sapi
1212
@$(mkinstalldirs) $(INSTALL_ROOT)$(sbindir)
1313
@$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/log
1414
@$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/run
15-
@$(INSTALL) -m 0755 $(SAPI_FPM_PATH) $(INSTALL_ROO)$(sbindir)/$(program_prefix)php-fpm$(program_suffix)$(EXEEXT)
15+
@$(INSTALL) -m 0755 $(SAPI_FPM_PATH) $(INSTALL_ROOT)$(sbindir)/$(program_prefix)php-fpm$(program_suffix)$(EXEEXT)
1616

1717
@echo "Installing PHP FPM config: $(INSTALL_ROOT)$(sysconfdir)/" && \
1818
$(mkinstalldirs) $(INSTALL_ROOT)$(sysconfdir) || :

sapi/fpm/fpm/fpm_conf.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ int fpm_worker_pool_config_free(struct fpm_worker_pool_config_s *wpc) /* {{{ */
297297
free(wpc->pm->status);
298298
free(wpc->pm->ping);
299299
free(wpc->pm->pong);
300+
free(wpc->sticky_cookie);
301+
free(wpc->sticky_route);
300302
if (wpc->listen_options) {
301303
free(wpc->listen_options->owner);
302304
free(wpc->listen_options->group);
@@ -347,6 +349,9 @@ static struct xml_conf_section xml_section_fpm_worker_pool_config = {
347349
{ XML_CONF_SCALAR, "rlimit_files", &xml_conf_set_slot_integer, offsetof(struct fpm_worker_pool_config_s, rlimit_files) },
348350
{ XML_CONF_SCALAR, "rlimit_core", &fpm_conf_set_rlimit_core, 0 },
349351
{ XML_CONF_SCALAR, "max_requests", &xml_conf_set_slot_integer, offsetof(struct fpm_worker_pool_config_s, max_requests) },
352+
{ XML_CONF_SCALAR, "sticky", &xml_conf_set_slot_boolean, offsetof(struct fpm_worker_pool_config_s, sticky) },
353+
{ XML_CONF_SCALAR, "sticky_cookie", &xml_conf_set_slot_string, offsetof(struct fpm_worker_pool_config_s, sticky_cookie) },
354+
{ XML_CONF_SCALAR, "sticky_route", &xml_conf_set_slot_string, offsetof(struct fpm_worker_pool_config_s, sticky_route) },
350355
{ XML_CONF_SCALAR, "catch_workers_output", &fpm_conf_set_catch_workers_output, 0 },
351356
{ XML_CONF_SUBSECTION, "pm", &fpm_conf_set_pm_subsection, offsetof(struct fpm_worker_pool_config_s, pm) },
352357
{ 0, 0, 0, 0 }
@@ -475,6 +480,64 @@ static int fpm_conf_process_all_pools() /* {{{ */
475480
close(fd);
476481
}
477482
}
483+
if (wp->config->sticky) {
484+
char *cookie = wp->config->sticky_cookie;
485+
char *route = wp->config->sticky_route;
486+
int i;
487+
488+
if (!cookie) {
489+
wp->config->sticky_cookie = strdup("FPMCOOKIE");
490+
} else {
491+
if (strlen(cookie) < 2) {
492+
zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the sticky cookie '%s' is not long enough", wp->config->name, cookie);
493+
return(-1);
494+
}
495+
496+
for (i=0; i<strlen(cookie); i++) {
497+
if (!isalnum(cookie[i])) {
498+
zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the sticky cookie '%s' must containt only the alphanum characters", wp->config->name, cookie);
499+
return(-1);
500+
}
501+
}
502+
}
503+
504+
if (!route) {
505+
char *hostname;
506+
hostname = malloc(sizeof(char) * (FPM_CONF_MAX_HOSTNAME_LENGTH + 1));
507+
if (!hostname) {
508+
zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] sticky: unable to malloc memory for hostname", wp->config->name);
509+
return(-1);
510+
}
511+
if (gethostname(hostname, FPM_CONF_MAX_HOSTNAME_LENGTH) != 0) {
512+
zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] sticky: unable to retrieve hostname", wp->config->name);
513+
return(-1);
514+
}
515+
hostname[FPM_CONF_MAX_HOSTNAME_LENGTH] = '\0';
516+
wp->config->sticky_route = strdup(hostname);
517+
zlog(ZLOG_STUFF, ZLOG_NOTICE, "[pool %s] the sticky route has been set to the local hostname '%s'", wp->config->name, wp->config->sticky_route);
518+
free(hostname);
519+
} else {
520+
if (strlen(route) < 2) {
521+
zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the sticky route '%s' is not long enough", wp->config->name, route);
522+
return(-1);
523+
}
524+
525+
for (i=0; i<strlen(route); i++) {
526+
if (!isalnum(route[i])) {
527+
zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the sticky route '%s' must containt only the alphanum characters", wp->config->name, route);
528+
return(-1);
529+
}
530+
}
531+
}
532+
zlog(ZLOG_STUFF, ZLOG_NOTICE, "[pool %s] sticky is set to %s=%s", wp->config->name, wp->config->sticky_cookie, wp->config->sticky_route);
533+
} else {
534+
if (wp->config->sticky_route) {
535+
free(wp->config->sticky_route);
536+
}
537+
if (wp->config->sticky_cookie) {
538+
free(wp->config->sticky_cookie);
539+
}
540+
}
478541

479542
if (wp->config->pm->ping && *wp->config->pm->ping) {
480543
char *ping = wp->config->pm->ping;

sapi/fpm/fpm/fpm_conf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define FPM_CONF_H 1
77

88
#define FPM_CONF_MAX_PONG_LENGTH 64
9+
#define FPM_CONF_MAX_HOSTNAME_LENGTH 255
910

1011
struct key_value_s;
1112

@@ -64,6 +65,9 @@ struct fpm_worker_pool_config_s {
6465
int max_requests;
6566
int rlimit_files;
6667
int rlimit_core;
68+
int sticky;
69+
char *sticky_cookie;
70+
char *sticky_route;
6771
unsigned catch_workers_output:1;
6872
};
6973

0 commit comments

Comments
 (0)