diff options
author | Jérôme Loyet <fat@php.net> | 2010-01-11 17:57:22 +0000 |
---|---|---|
committer | Jérôme Loyet <fat@php.net> | 2010-01-11 17:57:22 +0000 |
commit | dd9c6a30fe23dd03b0206cfe7d4dd35cb14d3a02 (patch) | |
tree | 3a7753673fbde7e9e900494aa22d30056cf34fb3 | |
parent | c077c39f09e59a9b4f5a2d46efe5c2507f021c95 (diff) | |
download | php-git-dd9c6a30fe23dd03b0206cfe7d4dd35cb14d3a02.tar.gz |
INSTALL_ROOT was not set correctly for fpm binary
-rw-r--r-- | sapi/fpm/Makefile.frag | 2 | ||||
-rw-r--r-- | sapi/fpm/fpm/fpm_conf.c | 63 | ||||
-rw-r--r-- | sapi/fpm/fpm/fpm_conf.h | 4 |
3 files changed, 68 insertions, 1 deletions
diff --git a/sapi/fpm/Makefile.frag b/sapi/fpm/Makefile.frag index a2fdae3864..d9b5e86796 100644 --- a/sapi/fpm/Makefile.frag +++ b/sapi/fpm/Makefile.frag @@ -12,7 +12,7 @@ install-fpm: install-sapi @$(mkinstalldirs) $(INSTALL_ROOT)$(sbindir) @$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/log @$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/run - @$(INSTALL) -m 0755 $(SAPI_FPM_PATH) $(INSTALL_ROO)$(sbindir)/$(program_prefix)php-fpm$(program_suffix)$(EXEEXT) + @$(INSTALL) -m 0755 $(SAPI_FPM_PATH) $(INSTALL_ROOT)$(sbindir)/$(program_prefix)php-fpm$(program_suffix)$(EXEEXT) @echo "Installing PHP FPM config: $(INSTALL_ROOT)$(sysconfdir)/" && \ $(mkinstalldirs) $(INSTALL_ROOT)$(sysconfdir) || : diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index 0d0832904a..cb5b817c30 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -297,6 +297,8 @@ int fpm_worker_pool_config_free(struct fpm_worker_pool_config_s *wpc) /* {{{ */ free(wpc->pm->status); free(wpc->pm->ping); free(wpc->pm->pong); + free(wpc->sticky_cookie); + free(wpc->sticky_route); if (wpc->listen_options) { free(wpc->listen_options->owner); free(wpc->listen_options->group); @@ -347,6 +349,9 @@ static struct xml_conf_section xml_section_fpm_worker_pool_config = { { XML_CONF_SCALAR, "rlimit_files", &xml_conf_set_slot_integer, offsetof(struct fpm_worker_pool_config_s, rlimit_files) }, { XML_CONF_SCALAR, "rlimit_core", &fpm_conf_set_rlimit_core, 0 }, { XML_CONF_SCALAR, "max_requests", &xml_conf_set_slot_integer, offsetof(struct fpm_worker_pool_config_s, max_requests) }, + { XML_CONF_SCALAR, "sticky", &xml_conf_set_slot_boolean, offsetof(struct fpm_worker_pool_config_s, sticky) }, + { XML_CONF_SCALAR, "sticky_cookie", &xml_conf_set_slot_string, offsetof(struct fpm_worker_pool_config_s, sticky_cookie) }, + { XML_CONF_SCALAR, "sticky_route", &xml_conf_set_slot_string, offsetof(struct fpm_worker_pool_config_s, sticky_route) }, { XML_CONF_SCALAR, "catch_workers_output", &fpm_conf_set_catch_workers_output, 0 }, { XML_CONF_SUBSECTION, "pm", &fpm_conf_set_pm_subsection, offsetof(struct fpm_worker_pool_config_s, pm) }, { 0, 0, 0, 0 } @@ -475,6 +480,64 @@ static int fpm_conf_process_all_pools() /* {{{ */ close(fd); } } + if (wp->config->sticky) { + char *cookie = wp->config->sticky_cookie; + char *route = wp->config->sticky_route; + int i; + + if (!cookie) { + wp->config->sticky_cookie = strdup("FPMCOOKIE"); + } else { + if (strlen(cookie) < 2) { + zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the sticky cookie '%s' is not long enough", wp->config->name, cookie); + return(-1); + } + + for (i=0; i<strlen(cookie); i++) { + if (!isalnum(cookie[i])) { + zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the sticky cookie '%s' must containt only the alphanum characters", wp->config->name, cookie); + return(-1); + } + } + } + + if (!route) { + char *hostname; + hostname = malloc(sizeof(char) * (FPM_CONF_MAX_HOSTNAME_LENGTH + 1)); + if (!hostname) { + zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] sticky: unable to malloc memory for hostname", wp->config->name); + return(-1); + } + if (gethostname(hostname, FPM_CONF_MAX_HOSTNAME_LENGTH) != 0) { + zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] sticky: unable to retrieve hostname", wp->config->name); + return(-1); + } + hostname[FPM_CONF_MAX_HOSTNAME_LENGTH] = '\0'; + wp->config->sticky_route = strdup(hostname); + 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); + free(hostname); + } else { + if (strlen(route) < 2) { + zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the sticky route '%s' is not long enough", wp->config->name, route); + return(-1); + } + + for (i=0; i<strlen(route); i++) { + if (!isalnum(route[i])) { + zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the sticky route '%s' must containt only the alphanum characters", wp->config->name, route); + return(-1); + } + } + } +zlog(ZLOG_STUFF, ZLOG_NOTICE, "[pool %s] sticky is set to %s=%s", wp->config->name, wp->config->sticky_cookie, wp->config->sticky_route); + } else { + if (wp->config->sticky_route) { + free(wp->config->sticky_route); + } + if (wp->config->sticky_cookie) { + free(wp->config->sticky_cookie); + } + } if (wp->config->pm->ping && *wp->config->pm->ping) { char *ping = wp->config->pm->ping; diff --git a/sapi/fpm/fpm/fpm_conf.h b/sapi/fpm/fpm/fpm_conf.h index 486319a737..48bee846f7 100644 --- a/sapi/fpm/fpm/fpm_conf.h +++ b/sapi/fpm/fpm/fpm_conf.h @@ -6,6 +6,7 @@ #define FPM_CONF_H 1 #define FPM_CONF_MAX_PONG_LENGTH 64 +#define FPM_CONF_MAX_HOSTNAME_LENGTH 255 struct key_value_s; @@ -64,6 +65,9 @@ struct fpm_worker_pool_config_s { int max_requests; int rlimit_files; int rlimit_core; + int sticky; + char *sticky_cookie; + char *sticky_route; unsigned catch_workers_output:1; }; |