mirror of
https://github.com/php/php-src.git
synced 2024-09-23 10:57:26 +00:00
- enhanced log messages
- code cosmetic
This commit is contained in:
parent
02581a0052
commit
3d10c57cd6
@ -29,8 +29,9 @@
|
||||
#include <limits.h>
|
||||
|
||||
#include <php_config.h>
|
||||
#include <fpm/fpm.h>
|
||||
#include <fpm/fpm_request.h>
|
||||
#include "fpm.h"
|
||||
#include "fpm_request.h"
|
||||
#include "zlog.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@ -267,7 +268,7 @@ void fcgi_set_allowed_clients(char *ip)
|
||||
}
|
||||
allowed_clients[n] = inet_addr(cur);
|
||||
if (allowed_clients[n] == INADDR_NONE) {
|
||||
fprintf(stderr, "Wrong IP address '%s' in FCGI_WEB_SERVER_ADDRS or listen.allowed_clients\n", cur);
|
||||
zlog(ZLOG_ERROR, "Wrong IP address '%s' in listen.allowed_clients", cur);
|
||||
}
|
||||
n++;
|
||||
cur = end;
|
||||
@ -815,7 +816,7 @@ int fcgi_accept_request(fcgi_request *req)
|
||||
n++;
|
||||
}
|
||||
if (!allowed) {
|
||||
fprintf(stderr, "Connection from disallowed IP address '%s' is dropped.\n", inet_ntoa(sa.sa_inet.sin_addr));
|
||||
zlog(ZLOG_ERROR, "Connection disallowed: IP address '%s' has been dropped.", inet_ntoa(sa.sa_inet.sin_addr));
|
||||
closesocket(req->fd);
|
||||
req->fd = -1;
|
||||
continue;
|
||||
@ -871,7 +872,7 @@ int fcgi_accept_request(fcgi_request *req)
|
||||
}
|
||||
fcgi_close(req, 1, 0);
|
||||
} else {
|
||||
fprintf(stderr, "Too many open file descriptors. FD_SETSIZE limit exceeded.");
|
||||
zlog(ZLOG_ERROR, "Too many open file descriptors. FD_SETSIZE limit exceeded.");
|
||||
fcgi_close(req, 1, 0);
|
||||
}
|
||||
#endif
|
||||
|
@ -65,11 +65,13 @@ int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int t
|
||||
if (fpm_globals.test_successful) {
|
||||
exit(0);
|
||||
} else {
|
||||
zlog(ZLOG_ERROR, "FPM initialization failed");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 > fpm_conf_write_pid()) {
|
||||
zlog(ZLOG_ERROR, "FPM initialization failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -147,13 +147,13 @@ static void fpm_child_init(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
{
|
||||
fpm_globals.max_requests = wp->config->pm_max_requests;
|
||||
|
||||
if (0 > fpm_stdio_init_child(wp) ||
|
||||
0 > fpm_log_init_child(wp) ||
|
||||
0 > fpm_status_init_child(wp) ||
|
||||
0 > fpm_unix_init_child(wp) ||
|
||||
0 > fpm_signals_init_child() ||
|
||||
0 > fpm_env_init_child(wp) ||
|
||||
0 > fpm_php_init_child(wp)) {
|
||||
if (0 > fpm_stdio_init_child(wp) ||
|
||||
0 > fpm_log_init_child(wp) ||
|
||||
0 > fpm_status_init_child(wp) ||
|
||||
0 > fpm_unix_init_child(wp) ||
|
||||
0 > fpm_signals_init_child() ||
|
||||
0 > fpm_env_init_child(wp) ||
|
||||
0 > fpm_php_init_child(wp)) {
|
||||
|
||||
zlog(ZLOG_ERROR, "[pool %s] child failed to initialize", wp->config->name);
|
||||
exit(255);
|
||||
@ -292,7 +292,7 @@ void fpm_children_bury() /* {{{ */
|
||||
}
|
||||
}
|
||||
} else {
|
||||
zlog(ZLOG_ALERT, "oops, unknown child (%d) exited %s", pid, buf);
|
||||
zlog(ZLOG_ALERT, "oops, unknown child (%d) exited %s. Please open a bug report (https://bugs.php.net).", pid, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -305,7 +305,7 @@ static struct fpm_child_s *fpm_resources_prepare(struct fpm_worker_pool_s *wp) /
|
||||
c = fpm_child_alloc();
|
||||
|
||||
if (!c) {
|
||||
zlog(ZLOG_ERROR, "[pool %s] malloc failed", wp->config->name);
|
||||
zlog(ZLOG_ERROR, "[pool %s] unable to malloc new child", wp->config->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "fpm_arrays.h"
|
||||
#include "fpm_cleanup.h"
|
||||
#include "zlog.h"
|
||||
|
||||
struct cleanup_s {
|
||||
int type;
|
||||
|
@ -47,7 +47,6 @@
|
||||
|
||||
#define STR2STR(a) (a ? a : "undefined")
|
||||
#define BOOL2STR(a) (a ? "yes" : "no")
|
||||
#define PM2STR(a) (a == PM_STYLE_STATIC ? "static" : "dynamic")
|
||||
#define GO(field) offsetof(struct fpm_global_config_s, field)
|
||||
#define WPO(field) offsetof(struct fpm_worker_pool_config_s, field)
|
||||
|
||||
@ -680,7 +679,7 @@ static int fpm_conf_process_all_pools() /* {{{ */
|
||||
struct fpm_worker_pool_s *wp;
|
||||
|
||||
if (!fpm_worker_all_pools) {
|
||||
zlog(ZLOG_ERROR, "at least one pool section must be specified in config file");
|
||||
zlog(ZLOG_ERROR, "No pool defined. at least one pool section must be specified in config file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -742,8 +741,7 @@ static int fpm_conf_process_all_pools() /* {{{ */
|
||||
|
||||
if (config->pm_min_spare_servers > config->pm_max_children ||
|
||||
config->pm_max_spare_servers > config->pm_max_children) {
|
||||
zlog(ZLOG_ALERT, "[pool %s] pm.min_spare_servers(%d) and pm.max_spare_servers(%d) cannot be greater than pm.max_children(%d)",
|
||||
wp->config->name, config->pm_min_spare_servers, config->pm_max_spare_servers, config->pm_max_children);
|
||||
zlog(ZLOG_ALERT, "[pool %s] pm.min_spare_servers(%d) and pm.max_spare_servers(%d) cannot be greater than pm.max_children(%d)", wp->config->name, config->pm_min_spare_servers, config->pm_max_spare_servers, config->pm_max_children);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -755,6 +753,7 @@ static int fpm_conf_process_all_pools() /* {{{ */
|
||||
if (config->pm_start_servers <= 0) {
|
||||
config->pm_start_servers = config->pm_min_spare_servers + ((config->pm_max_spare_servers - config->pm_min_spare_servers) / 2);
|
||||
zlog(ZLOG_WARNING, "[pool %s] pm.start_servers is not set. It's been set to %d.", wp->config->name, config->pm_start_servers);
|
||||
|
||||
} else if (config->pm_start_servers < config->pm_min_spare_servers || config->pm_start_servers > config->pm_max_spare_servers) {
|
||||
zlog(ZLOG_ALERT, "[pool %s] pm.start_servers(%d) must not be less than pm.min_spare_servers(%d) and not greater than pm.max_spare_servers(%d)", wp->config->name, config->pm_start_servers, config->pm_min_spare_servers, config->pm_max_spare_servers);
|
||||
return -1;
|
||||
@ -766,7 +765,6 @@ static int fpm_conf_process_all_pools() /* {{{ */
|
||||
if (wp->config->pm_status_path && *wp->config->pm_status_path) {
|
||||
int i;
|
||||
char *status = wp->config->pm_status_path;
|
||||
/* struct fpm_status_s fpm_status; */
|
||||
|
||||
if (*status != '/') {
|
||||
zlog(ZLOG_ERROR, "[pool %s] the status path '%s' must start with a '/'", wp->config->name, status);
|
||||
@ -860,7 +858,7 @@ static int fpm_conf_process_all_pools() /* {{{ */
|
||||
fd = open(wp->config->slowlog, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
|
||||
if (0 > fd) {
|
||||
zlog(ZLOG_SYSERROR, "open(%s) failed", wp->config->slowlog);
|
||||
zlog(ZLOG_SYSERROR, "Unable to create or open slowlog(%s)", wp->config->slowlog);
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
@ -876,6 +874,7 @@ static int fpm_conf_process_all_pools() /* {{{ */
|
||||
zlog(ZLOG_ERROR, "[pool %s] the chroot path '%s' must start with a '/'", wp->config->name, wp->config->chroot);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!fpm_conf_is_dir(wp->config->chroot)) {
|
||||
zlog(ZLOG_ERROR, "[pool %s] the chroot path '%s' does not exist or is not a directory", wp->config->name, wp->config->chroot);
|
||||
return -1;
|
||||
@ -993,7 +992,7 @@ int fpm_conf_unlink_pid() /* {{{ */
|
||||
{
|
||||
if (fpm_global_config.pid_file) {
|
||||
if (0 > unlink(fpm_global_config.pid_file)) {
|
||||
zlog(ZLOG_SYSERROR, "unlink(\"%s\") failed", fpm_global_config.pid_file);
|
||||
zlog(ZLOG_SYSERROR, "Unable to remove the PID file (%s).", fpm_global_config.pid_file);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1013,14 +1012,14 @@ int fpm_conf_write_pid() /* {{{ */
|
||||
fd = creat(fpm_global_config.pid_file, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
if (fd < 0) {
|
||||
zlog(ZLOG_SYSERROR, "creat(\"%s\") failed", fpm_global_config.pid_file);
|
||||
zlog(ZLOG_SYSERROR, "Unable to create the PID file (%s).", fpm_global_config.pid_file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = sprintf(buf, "%d", (int) fpm_globals.parent_pid);
|
||||
|
||||
if (len != write(fd, buf, len)) {
|
||||
zlog(ZLOG_SYSERROR, "write() failed");
|
||||
zlog(ZLOG_SYSERROR, "Unable to write to the PID file.");
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
@ -1355,18 +1354,18 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
|
||||
int ret = 1;
|
||||
|
||||
if (!filename || !filename[0]) {
|
||||
zlog(ZLOG_ERROR, "Configuration file is empty");
|
||||
zlog(ZLOG_ERROR, "configuration filename is empty");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = open(filename, O_RDONLY, 0);
|
||||
if (fd < 0) {
|
||||
zlog(ZLOG_ERROR, "Unable to open file '%s', errno=%d", filename, errno);
|
||||
zlog(ZLOG_SYSERROR, "failed to open configuration file '%s'", filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ini_recursion++ > 4) {
|
||||
zlog(ZLOG_ERROR, "You can include more than 5 files recusively");
|
||||
zlog(ZLOG_ERROR, "failed to include more than 5 files recusively");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <stdint.h>
|
||||
#include "php.h"
|
||||
|
||||
#define PM2STR(a) (a == PM_STYLE_STATIC ? "static" : "dynamic")
|
||||
|
||||
#define FPM_CONF_MAX_PONG_LENGTH 64
|
||||
|
||||
struct key_value_s;
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include "fpm_env.h"
|
||||
#include "fpm.h"
|
||||
#include "zlog.h"
|
||||
|
||||
#ifndef HAVE_SETPROCTITLE
|
||||
#ifdef __linux__
|
||||
|
@ -66,7 +66,7 @@ static void fpm_got_signal(struct fpm_event_s *ev, short which, void *arg) /* {{
|
||||
|
||||
if (res <= 0) {
|
||||
if (res < 0 && errno != EAGAIN && errno != EWOULDBLOCK) {
|
||||
zlog(ZLOG_SYSERROR, "read() failed");
|
||||
zlog(ZLOG_SYSERROR, "unable to read from the signal pipe");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -153,7 +153,7 @@ static int fpm_event_queue_add(struct fpm_event_queue_s **queue, struct fpm_even
|
||||
}
|
||||
|
||||
if (!(elt = malloc(sizeof(struct fpm_event_queue_s)))) {
|
||||
zlog(ZLOG_SYSERROR, "malloc() failed");
|
||||
zlog(ZLOG_SYSERROR, "Unable to add the event to queue: malloc() failed");
|
||||
return -1;
|
||||
}
|
||||
elt->prev = NULL;
|
||||
@ -232,7 +232,7 @@ int fpm_event_init_main() /* {{{ */
|
||||
/* malloc the max number of necessary fds for polling */
|
||||
fpm_event_ufds = malloc(sizeof(php_pollfd) * fpm_event_nfds_max);
|
||||
if (!fpm_event_ufds) {
|
||||
zlog(ZLOG_SYSERROR, "malloc() failed");
|
||||
zlog(ZLOG_SYSERROR, "Error while initializing events: malloc() failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ void fpm_event_loop(int err) /* {{{ */
|
||||
/* wait for inconming event or timeout */
|
||||
if ((ret = php_poll2(fpm_event_ufds, i, timeout)) == -1) {
|
||||
if (errno != EINTR) {
|
||||
zlog(ZLOG_WARNING, "php_poll2() returns %d", errno);
|
||||
zlog(ZLOG_SYSERROR, "failed to wait for events: php_poll2()");
|
||||
}
|
||||
} else if (ret > 0) {
|
||||
|
||||
|
@ -44,7 +44,7 @@ int fpm_log_open(int reopen) /* {{{ */
|
||||
|
||||
fd = open(wp->config->access_log, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
if (0 > fd) {
|
||||
zlog(ZLOG_SYSERROR, "open(\"%s\") failed", wp->config->access_log);
|
||||
zlog(ZLOG_SYSERROR, "failed to open access log (%s)", wp->config->access_log);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -124,12 +124,12 @@ int fpm_log_write(char *log_format TSRMLS_DC) /* {{{ */
|
||||
if (!test) {
|
||||
scoreboard = fpm_scoreboard_get();
|
||||
if (!scoreboard) {
|
||||
zlog(ZLOG_WARNING, "unable to get scoreboard");
|
||||
zlog(ZLOG_WARNING, "unable to get scoreboard while preparing the access log");
|
||||
return -1;
|
||||
}
|
||||
proc_p = fpm_scoreboard_proc_acquire(NULL, -1, 0);
|
||||
if (!proc_p) {
|
||||
zlog(ZLOG_WARNING, "[pool %s] Unable to acquire shm slot", scoreboard->pool);
|
||||
zlog(ZLOG_WARNING, "[pool %s] Unable to acquire shm slot while preparing the access log", scoreboard->pool);
|
||||
return -1;
|
||||
}
|
||||
proc = *proc_p;
|
||||
@ -147,7 +147,7 @@ int fpm_log_write(char *log_format TSRMLS_DC) /* {{{ */
|
||||
|
||||
while (*s != '\0') {
|
||||
if (len > FPM_LOG_BUFFER) {
|
||||
zlog(ZLOG_NOTICE, "the log buffer is full (%d). The log request has been truncated.", FPM_LOG_BUFFER);
|
||||
zlog(ZLOG_NOTICE, "the log buffer is full (%d). The access log request has been truncated.", FPM_LOG_BUFFER);
|
||||
len = FPM_LOG_BUFFER - 1;
|
||||
break;
|
||||
}
|
||||
|
@ -100,13 +100,13 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS;
|
||||
#include "fastcgi.h"
|
||||
|
||||
#include <php_config.h>
|
||||
#include <fpm/fpm.h>
|
||||
#include <fpm/fpm_request.h>
|
||||
#include <fpm/fpm_status.h>
|
||||
#include <fpm/fpm_conf.h>
|
||||
#include <fpm/fpm_php.h>
|
||||
#include <fpm/fpm_log.h>
|
||||
#include <fpm/zlog.h>
|
||||
#include "fpm.h"
|
||||
#include "fpm_request.h"
|
||||
#include "fpm_status.h"
|
||||
#include "fpm_conf.h"
|
||||
#include "fpm_php.h"
|
||||
#include "fpm_log.h"
|
||||
#include "zlog.h"
|
||||
|
||||
#ifndef PHP_WIN32
|
||||
/* XXX this will need to change later when threaded fastcgi is implemented. shane */
|
||||
|
@ -253,7 +253,7 @@ int fpm_php_limit_extensions(char *path) /* {{{ */
|
||||
}
|
||||
|
||||
|
||||
zlog(ZLOG_NOTICE, "Access to the file '%s' has been denied (see security.limit_extensions)", path);
|
||||
zlog(ZLOG_NOTICE, "Access to the script '%s' has been denied (see security.limit_extensions)", path);
|
||||
return 1; /* extension not found: not allowed */
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -144,7 +144,7 @@ void fpm_php_trace(struct fpm_child_s *child) /* {{{ */
|
||||
slowlog = fopen(child->wp->config->slowlog, "a+");
|
||||
|
||||
if (!slowlog) {
|
||||
zlog(ZLOG_SYSERROR, "fopen(%s) failed", child->wp->config->slowlog);
|
||||
zlog(ZLOG_SYSERROR, "unable to open slowlog (%s)", child->wp->config->slowlog);
|
||||
goto done0;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ static void fpm_pctl_exec() /* {{{ */
|
||||
|
||||
fpm_cleanups_run(FPM_CLEANUP_PARENT_EXEC);
|
||||
execvp(saved_argv[0], saved_argv);
|
||||
zlog(ZLOG_SYSERROR, "execvp() failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to reload: execvp() failed");
|
||||
exit(1);
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -45,7 +45,7 @@ void fpm_request_accepting() /* {{{ */
|
||||
|
||||
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
|
||||
if (proc == NULL) {
|
||||
zlog(ZLOG_WARNING, "unable to acquire proc scoreboard");
|
||||
zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ void fpm_request_reading_headers() /* {{{ */
|
||||
|
||||
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
|
||||
if (proc == NULL) {
|
||||
zlog(ZLOG_WARNING, "unable to acquire proc scoreboard");
|
||||
zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ void fpm_request_info() /* {{{ */
|
||||
|
||||
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
|
||||
if (proc == NULL) {
|
||||
zlog(ZLOG_WARNING, "unable to acquire proc scoreboard");
|
||||
zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ void fpm_request_executing() /* {{{ */
|
||||
|
||||
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
|
||||
if (proc == NULL) {
|
||||
zlog(ZLOG_WARNING, "unable to acquire proc scoreboard");
|
||||
zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ void fpm_request_end(TSRMLS_D) /* {{{ */
|
||||
|
||||
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
|
||||
if (proc == NULL) {
|
||||
zlog(ZLOG_WARNING, "unable to acquire proc scoreboard");
|
||||
zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
|
||||
return;
|
||||
}
|
||||
proc->request_stage = FPM_REQUEST_FINISHED;
|
||||
@ -213,7 +213,7 @@ void fpm_request_finished() /* {{{ */
|
||||
|
||||
proc = fpm_scoreboard_proc_acquire(NULL, -1, 0);
|
||||
if (proc == NULL) {
|
||||
zlog(ZLOG_WARNING, "unable to acquire proc scoreboard");
|
||||
zlog(ZLOG_WARNING, "failed to acquire proc scoreboard");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *now,
|
||||
|
||||
proc_p = fpm_scoreboard_proc_acquire(child->wp->scoreboard, child->scoreboard_i, 1);
|
||||
if (!proc_p) {
|
||||
zlog(ZLOG_WARNING, "unable to acquire scoreboard");
|
||||
zlog(ZLOG_WARNING, "failed to acquire scoreboard");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ int fpm_shm_free(void *mem, size_t size) /* {{{ */
|
||||
}
|
||||
|
||||
if (munmap(mem, size) == -1) {
|
||||
zlog(ZLOG_SYSERROR, "Unable to free shm: %s", strerror(errno));
|
||||
zlog(ZLOG_SYSERROR, "Unable to free shm");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -182,17 +182,17 @@ int fpm_signals_init_main() /* {{{ */
|
||||
struct sigaction act;
|
||||
|
||||
if (0 > socketpair(AF_UNIX, SOCK_STREAM, 0, sp)) {
|
||||
zlog(ZLOG_SYSERROR, "socketpair() failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to init signals: socketpair()");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 > fd_set_blocked(sp[0], 0) || 0 > fd_set_blocked(sp[1], 0)) {
|
||||
zlog(ZLOG_SYSERROR, "fd_set_blocked() failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to init signals: fd_set_blocked()");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 > fcntl(sp[0], F_SETFD, FD_CLOEXEC) || 0 > fcntl(sp[1], F_SETFD, FD_CLOEXEC)) {
|
||||
zlog(ZLOG_SYSERROR, "fcntl(F_SETFD, FD_CLOEXEC) failed");
|
||||
zlog(ZLOG_SYSERROR, "falied to init signals: fcntl(F_SETFD, FD_CLOEXEC)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ int fpm_signals_init_main() /* {{{ */
|
||||
0 > sigaction(SIGCHLD, &act, 0) ||
|
||||
0 > sigaction(SIGQUIT, &act, 0)) {
|
||||
|
||||
zlog(ZLOG_SYSERROR, "sigaction() failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to init signals: sigaction()");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -236,7 +236,7 @@ int fpm_signals_init_child() /* {{{ */
|
||||
0 > sigaction(SIGCHLD, &act_dfl, 0) ||
|
||||
0 > sigaction(SIGQUIT, &act, 0)) {
|
||||
|
||||
zlog(ZLOG_SYSERROR, "sigaction() failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to init child signals: sigaction()");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -172,7 +172,7 @@ static int fpm_sockets_new_listening_socket(struct fpm_worker_pool_s *wp, struct
|
||||
sock = socket(sa->sa_family, SOCK_STREAM, 0);
|
||||
|
||||
if (0 > sock) {
|
||||
zlog(ZLOG_SYSERROR, "socket() failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to create new listening socket: socket()");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ static int fpm_sockets_new_listening_socket(struct fpm_worker_pool_s *wp, struct
|
||||
}
|
||||
|
||||
if (0 > bind(sock, sa, socklen)) {
|
||||
zlog(ZLOG_SYSERROR, "bind() for address '%s' failed", wp->config->listen_address);
|
||||
zlog(ZLOG_SYSERROR, "unable to bind listening socket for address '%s'", wp->config->listen_address);
|
||||
if (wp->listen_address_domain == FPM_AF_UNIX) {
|
||||
umask(saved_umask);
|
||||
}
|
||||
@ -198,14 +198,14 @@ static int fpm_sockets_new_listening_socket(struct fpm_worker_pool_s *wp, struct
|
||||
|
||||
if (wp->socket_uid != -1 || wp->socket_gid != -1) {
|
||||
if (0 > chown(path, wp->socket_uid, wp->socket_gid)) {
|
||||
zlog(ZLOG_SYSERROR, "chown() for address '%s' failed", wp->config->listen_address);
|
||||
zlog(ZLOG_SYSERROR, "failed to chown() the socket '%s'", wp->config->listen_address);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 > listen(sock, wp->config->listen_backlog)) {
|
||||
zlog(ZLOG_SYSERROR, "listen() for address '%s' failed", wp->config->listen_address);
|
||||
zlog(ZLOG_SYSERROR, "failed to listen to address '%s'", wp->config->listen_address);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -392,7 +392,7 @@ int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq)
|
||||
socklen_t len = sizeof(info);
|
||||
|
||||
if (0 > getsockopt(sock, IPPROTO_TCP, TCP_INFO, &info, &len)) {
|
||||
zlog(ZLOG_SYSERROR, "unable to retrieve TCP_INFO for socket");
|
||||
zlog(ZLOG_SYSERROR, "failed to retrieve TCP_INFO for socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "fpm_scoreboard.h"
|
||||
#include "zlog.h"
|
||||
#include "fpm_atomic.h"
|
||||
#include "fpm_conf.h"
|
||||
#include <ext/standard/html.h>
|
||||
|
||||
static char *fpm_status_uri = NULL;
|
||||
@ -33,7 +34,7 @@ int fpm_status_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
|
||||
if (wp->config->ping_path) {
|
||||
if (!wp->config->ping_response) {
|
||||
zlog(ZLOG_ERROR, "[pool %s] ping is set (%s) but pong is not set.", wp->config->name, wp->config->ping_path);
|
||||
zlog(ZLOG_ERROR, "[pool %s] ping is set (%s) but ping.response is not set.", wp->config->name, wp->config->ping_path);
|
||||
return -1;
|
||||
}
|
||||
fpm_status_ping_uri = strdup(wp->config->ping_path);
|
||||
@ -352,7 +353,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */
|
||||
now_epoch = time(NULL);
|
||||
spprintf(&buffer, 0, short_syntax,
|
||||
scoreboard.pool,
|
||||
scoreboard.pm == PM_STYLE_STATIC ? "static" : "dynamic",
|
||||
PM2STR(scoreboard.pm),
|
||||
time_buffer,
|
||||
now_epoch - scoreboard.start_epoch,
|
||||
scoreboard.requests,
|
||||
|
@ -28,12 +28,12 @@ int fpm_stdio_init_main() /* {{{ */
|
||||
int fd = open("/dev/null", O_RDWR);
|
||||
|
||||
if (0 > fd) {
|
||||
zlog(ZLOG_SYSERROR, "open(\"/dev/null\") failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to init stdio: open(\"/dev/null\")");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 > dup2(fd, STDIN_FILENO) || 0 > dup2(fd, STDOUT_FILENO)) {
|
||||
zlog(ZLOG_SYSERROR, "dup2() failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to init stdio: dup2()");
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
@ -49,7 +49,7 @@ int fpm_stdio_init_final() /* {{{ */
|
||||
|
||||
/* there might be messages to stderr from other parts of the code, we need to log them all */
|
||||
if (0 > dup2(fpm_globals.error_log_fd, STDERR_FILENO)) {
|
||||
zlog(ZLOG_SYSERROR, "dup2() failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to init stdio: dup2()");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -74,7 +74,7 @@ int fpm_stdio_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
|
||||
if (wp->listening_socket != STDIN_FILENO) {
|
||||
if (0 > dup2(wp->listening_socket, STDIN_FILENO)) {
|
||||
zlog(ZLOG_SYSERROR, "dup2() failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to init child stdio: dup2()");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -116,7 +116,7 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg)
|
||||
} else { /* error or pipe is closed */
|
||||
|
||||
if (res < 0) { /* error */
|
||||
zlog(ZLOG_SYSERROR, "read() failed");
|
||||
zlog(ZLOG_SYSERROR, "unable to read what child say");
|
||||
}
|
||||
|
||||
fpm_event_del(event);
|
||||
@ -186,20 +186,23 @@ int fpm_stdio_prepare_pipes(struct fpm_child_s *child) /* {{{ */
|
||||
}
|
||||
|
||||
if (0 > pipe(fd_stdout)) {
|
||||
zlog(ZLOG_SYSERROR, "pipe() failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to prepare the stdout pipe");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 > pipe(fd_stderr)) {
|
||||
zlog(ZLOG_SYSERROR, "pipe() failed");
|
||||
close(fd_stdout[0]); close(fd_stdout[1]);
|
||||
zlog(ZLOG_SYSERROR, "failed to prepare the stderr pipe");
|
||||
close(fd_stdout[0]);
|
||||
close(fd_stdout[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 > fd_set_blocked(fd_stdout[0], 0) || 0 > fd_set_blocked(fd_stderr[0], 0)) {
|
||||
zlog(ZLOG_SYSERROR, "fd_set_blocked() failed");
|
||||
close(fd_stdout[0]); close(fd_stdout[1]);
|
||||
close(fd_stderr[0]); close(fd_stderr[1]);
|
||||
zlog(ZLOG_SYSERROR, "failed to unblock pipes");
|
||||
close(fd_stdout[0]);
|
||||
close(fd_stdout[1]);
|
||||
close(fd_stderr[0]);
|
||||
close(fd_stderr[1]);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -273,7 +276,7 @@ int fpm_stdio_open_error_log(int reopen) /* {{{ */
|
||||
|
||||
fd = open(fpm_global_config.error_log, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
if (0 > fd) {
|
||||
zlog(ZLOG_SYSERROR, "open(\"%s\") failed", fpm_global_config.error_log);
|
||||
zlog(ZLOG_SYSERROR, "failed to open error_log (%s)", fpm_global_config.error_log);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ static int fpm_mach_vm_read_page(vm_offset_t page) /* {{{ */
|
||||
|
||||
kr = mach_vm_read(target, page, fpm_pagesize, &local_page, &local_size);
|
||||
if (kr != KERN_SUCCESS) {
|
||||
zlog(ZLOG_ERROR, "mach_vm_read() failed: %s (%d)", mach_error_string(kr), kr);
|
||||
zlog(ZLOG_ERROR, "failed to read vm page: mach_vm_read(): %s (%d)", mach_error_string(kr), kr);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -47,7 +47,7 @@ static int fpm_mach_vm_read_page(vm_offset_t page) /* {{{ */
|
||||
int fpm_trace_signal(pid_t pid) /* {{{ */
|
||||
{
|
||||
if (0 > fpm_pctl_kill(pid, FPM_PCTL_STOP)) {
|
||||
zlog(ZLOG_SYSERROR, "kill(SIGSTOP) failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to send SIGSTOP to %d", pid);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -26,7 +26,7 @@ static int mem_file = -1;
|
||||
int fpm_trace_signal(pid_t pid) /* {{{ */
|
||||
{
|
||||
if (0 > fpm_pctl_kill(pid, FPM_PCTL_STOP)) {
|
||||
zlog(ZLOG_SYSERROR, "kill(SIGSTOP) failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to send SIGSTOP to %d", pid);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -40,7 +40,7 @@ int fpm_trace_ready(pid_t pid) /* {{{ */
|
||||
sprintf(buf, "/proc/%d/" PROC_MEM_FILE, (int) pid);
|
||||
mem_file = open(buf, O_RDONLY);
|
||||
if (0 > mem_file) {
|
||||
zlog(ZLOG_SYSERROR, "open(%s) failed", buf);
|
||||
zlog(ZLOG_SYSERROR, "failed to open %s", buf);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -29,7 +29,7 @@ static pid_t traced_pid;
|
||||
int fpm_trace_signal(pid_t pid) /* {{{ */
|
||||
{
|
||||
if (0 > ptrace(PTRACE_ATTACH, pid, 0, 0)) {
|
||||
zlog(ZLOG_SYSERROR, "ptrace(ATTACH) failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to ptrace(ATTACH) child %d", pid);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -46,7 +46,7 @@ int fpm_trace_ready(pid_t pid) /* {{{ */
|
||||
int fpm_trace_close(pid_t pid) /* {{{ */
|
||||
{
|
||||
if (0 > ptrace(PTRACE_DETACH, pid, (void *) 1, 0)) {
|
||||
zlog(ZLOG_SYSERROR, "ptrace(DETACH) failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to ptrace(DETACH) child %d", pid);
|
||||
return -1;
|
||||
}
|
||||
traced_pid = 0;
|
||||
@ -65,14 +65,14 @@ int fpm_trace_get_long(long addr, long *data) /* {{{ */
|
||||
};
|
||||
|
||||
if (0 > ptrace(PT_IO, traced_pid, (void *) &ptio, 0)) {
|
||||
zlog(ZLOG_SYSERROR, "ptrace(PT_IO) failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to ptrace(PT_IO) pid %d", traced_pid);
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
errno = 0;
|
||||
*data = ptrace(PTRACE_PEEKDATA, traced_pid, (void *) addr, 0);
|
||||
if (errno) {
|
||||
zlog(ZLOG_SYSERROR, "ptrace(PEEKDATA) failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to ptrace(PEEKDATA) pid %d", traced_pid);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
@ -73,6 +73,7 @@ int fpm_unix_resolve_socket_premissions(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
|
||||
static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
{
|
||||
struct passwd *pwd;
|
||||
int is_root = !geteuid();
|
||||
|
||||
if (is_root) {
|
||||
@ -119,23 +120,20 @@ static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
#endif
|
||||
} else { /* not root */
|
||||
if (wp->config->user && *wp->config->user) {
|
||||
zlog(ZLOG_WARNING, "[pool %s] 'user' directive is ignored", wp->config->name);
|
||||
zlog(ZLOG_WARNING, "[pool %s] 'user' directive is ignored when FPM is not running as root", wp->config->name);
|
||||
}
|
||||
if (wp->config->group && *wp->config->group) {
|
||||
zlog(ZLOG_WARNING, "[pool %s] 'group' directive is ignored", wp->config->name);
|
||||
zlog(ZLOG_WARNING, "[pool %s] 'group' directive is ignored when FPM is not running as root", wp->config->name);
|
||||
}
|
||||
if (wp->config->chroot && *wp->config->chroot) {
|
||||
zlog(ZLOG_WARNING, "[pool %s] 'chroot' directive is ignored", wp->config->name);
|
||||
zlog(ZLOG_WARNING, "[pool %s] 'chroot' directive is ignored when FPM is not running as root", wp->config->name);
|
||||
}
|
||||
|
||||
{ /* set up HOME and USER anyway */
|
||||
struct passwd *pwd;
|
||||
|
||||
pwd = getpwuid(getuid());
|
||||
if (pwd) {
|
||||
wp->user = strdup(pwd->pw_name);
|
||||
wp->home = strdup(pwd->pw_dir);
|
||||
}
|
||||
/* set up HOME and USER anyway */
|
||||
pwd = getpwuid(getuid());
|
||||
if (pwd) {
|
||||
wp->user = strdup(pwd->pw_name);
|
||||
wp->home = strdup(pwd->pw_dir);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -153,7 +151,7 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
r.rlim_max = r.rlim_cur = (rlim_t) wp->config->rlimit_files;
|
||||
|
||||
if (0 > setrlimit(RLIMIT_NOFILE, &r)) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] unable to set rlimit_files for this pool. Please check your system limits or decrease rlimit_files. setrlimit(RLIMIT_NOFILE, %d) failed (%d)", wp->config->name, wp->config->rlimit_files, errno);
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] failed to set rlimit_files for this pool. Please check your system limits or decrease rlimit_files. setrlimit(RLIMIT_NOFILE, %d)", wp->config->name, wp->config->rlimit_files);
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,13 +161,13 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
r.rlim_max = r.rlim_cur = wp->config->rlimit_core == -1 ? (rlim_t) RLIM_INFINITY : (rlim_t) wp->config->rlimit_core;
|
||||
|
||||
if (0 > setrlimit(RLIMIT_CORE, &r)) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] unable to set rlimit_core for this pool. Please check your system limits or decrease rlimit_core. setrlimit(RLIMIT_CORE, %d) failed (%d)", wp->config->name, wp->config->rlimit_core, errno);
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] failed to set rlimit_core for this pool. Please check your system limits or decrease rlimit_core. setrlimit(RLIMIT_CORE, %d)", wp->config->name, wp->config->rlimit_core);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_root && wp->config->chroot && *wp->config->chroot) {
|
||||
if (0 > chroot(wp->config->chroot)) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] chroot(%s) failed", wp->config->name, wp->config->chroot);
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] failed to chroot(%s)", wp->config->name, wp->config->chroot);
|
||||
return -1;
|
||||
}
|
||||
made_chroot = 1;
|
||||
@ -177,7 +175,7 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
|
||||
if (wp->config->chdir && *wp->config->chdir) {
|
||||
if (0 > chdir(wp->config->chdir)) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] chdir(%s) failed", wp->config->name, wp->config->chdir);
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] failed to chdir(%s)", wp->config->name, wp->config->chdir);
|
||||
return -1;
|
||||
}
|
||||
} else if (made_chroot) {
|
||||
@ -187,17 +185,17 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
if (is_root) {
|
||||
if (wp->set_gid) {
|
||||
if (0 > setgid(wp->set_gid)) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] setgid(%d) failed", wp->config->name, wp->set_gid);
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] failed to setgid(%d)", wp->config->name, wp->set_gid);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (wp->set_uid) {
|
||||
if (0 > initgroups(wp->config->user, wp->set_gid)) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] initgroups(%s, %d) failed", wp->config->name, wp->config->user, wp->set_gid);
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] failed to initgroups(%s, %d)", wp->config->name, wp->config->user, wp->set_gid);
|
||||
return -1;
|
||||
}
|
||||
if (0 > setuid(wp->set_uid)) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] setuid(%d) failed", wp->config->name, wp->set_uid);
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] failed to setuid(%d)", wp->config->name, wp->set_uid);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -205,7 +203,7 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
|
||||
#ifdef HAVE_PRCTL
|
||||
if (0 > prctl(PR_SET_DUMPABLE, 1, 0, 0, 0)) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] prctl(PR_SET_DUMPABLE) failed", wp->config->name);
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] failed to prctl(PR_SET_DUMPABLE)", wp->config->name);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -226,7 +224,7 @@ int fpm_unix_init_main() /* {{{ */
|
||||
r.rlim_max = r.rlim_cur = (rlim_t) fpm_global_config.rlimit_files;
|
||||
|
||||
if (0 > setrlimit(RLIMIT_NOFILE, &r)) {
|
||||
zlog(ZLOG_SYSERROR, "unable to set rlimit_core for this pool. Please check your system limits or decrease rlimit_files. setrlimit(RLIMIT_NOFILE, %d) failed (%d)", fpm_global_config.rlimit_files, errno);
|
||||
zlog(ZLOG_SYSERROR, "failed to set rlimit_core for this pool. Please check your system limits or decrease rlimit_files. setrlimit(RLIMIT_NOFILE, %d)", fpm_global_config.rlimit_files);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -237,7 +235,7 @@ int fpm_unix_init_main() /* {{{ */
|
||||
r.rlim_max = r.rlim_cur = fpm_global_config.rlimit_core == -1 ? (rlim_t) RLIM_INFINITY : (rlim_t) fpm_global_config.rlimit_core;
|
||||
|
||||
if (0 > setrlimit(RLIMIT_CORE, &r)) {
|
||||
zlog(ZLOG_SYSERROR, "unable to set rlimit_core for this pool. Please check your system limits or decrease rlimit_core. setrlimit(RLIMIT_CORE, %d) failed (%d)", fpm_global_config.rlimit_core, errno);
|
||||
zlog(ZLOG_SYSERROR, "failed to set rlimit_core for this pool. Please check your system limits or decrease rlimit_core. setrlimit(RLIMIT_CORE, %d)", fpm_global_config.rlimit_core);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -246,7 +244,7 @@ int fpm_unix_init_main() /* {{{ */
|
||||
if (fpm_global_config.daemonize) {
|
||||
switch (fork()) {
|
||||
case -1 :
|
||||
zlog(ZLOG_SYSERROR, "daemonized fork() failed");
|
||||
zlog(ZLOG_SYSERROR, "failed to daemonize");
|
||||
return -1;
|
||||
case 0 :
|
||||
break;
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "fpm_shm.h"
|
||||
#include "fpm_scoreboard.h"
|
||||
#include "fpm_conf.h"
|
||||
#include "zlog.h"
|
||||
|
||||
struct fpm_worker_pool_s *fpm_worker_all_pools;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user