Advertisement
Guest User

php53-fpm-config-defaults.patch

a guest
Jul 3rd, 2011
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 52.91 KB | None | 0 0
  1. Index: sapi/fpm/php-fpm.conf.in
  2. ===================================================================
  3. --- sapi/fpm/php-fpm.conf.in    (revision 312829)
  4. +++ sapi/fpm/php-fpm.conf.in    (working copy)
  5. @@ -14,6 +14,7 @@
  6.  ;  - @prefix@ otherwise
  7.  ;include=etc/fpm.d/*.conf
  8.  
  9. +
  10.  ;;;;;;;;;;;;;;;;;;
  11.  ; Global Options ;
  12.  ;;;;;;;;;;;;;;;;;;
  13. @@ -67,15 +68,35 @@
  14.  ; Default Value: system defined value
  15.  ;rlimit_core = 0
  16.  
  17. -;;;;;;;;;;;;;;;;;;;;
  18. -; Pool Definitions ;
  19. -;;;;;;;;;;;;;;;;;;;;
  20.  
  21. +;;;;;;;;;;;;;;;;;;
  22. +; Default values ;
  23. +;;;;;;;;;;;;;;;;;;
  24. +
  25.  ; Multiple pools of child processes may be started with different listening
  26.  ; ports and different management options.  The name of the pool will be
  27.  ; used in logs and stats. There is no limitation on the number of pools which
  28. -; FPM can handle. Your system will tell you anyway :)
  29. +; FPM can handle, your system will limit that for you :)
  30.  
  31. +; You can put in the defaults section all the same values you would put in a
  32. +; pool (see below for more details). The defaults are used in case you don't
  33. +; specify another value in the pool.
  34. +; If a parameter is not specified either in the defaults section nor in the
  35. +; pool specific section, a buil-in global default will be used, as explained
  36. +; in a option by option basis.
  37. +
  38. +[defaults]
  39. +
  40. +; reasonable values for a small sized server (see below for details)
  41. +pm.start_servers = 10
  42. +pm.min_spare_servers = 5
  43. +pm.max_spare_servers = 35
  44. +
  45. +
  46. +;;;;;;;;;;;;;;;;;;;;
  47. +; Pool Definitions ;
  48. +;;;;;;;;;;;;;;;;;;;;
  49. +
  50.  ; Start a new pool named 'www'.
  51.  ; the variable $pool can we used in any directive and will be replaced by the
  52.  ; pool name ('www' here)
  53. @@ -94,6 +115,12 @@
  54.  ; Default Value: none
  55.  ;prefix = /path/to/pools/$pool
  56.  
  57. +; Unix user/group of processes
  58. +; Note: The user is mandatory. If the group is not set, the default user's group
  59. +;       will be used.
  60. +user = @php_fpm_user@
  61. +group = @php_fpm_group@
  62. +
  63.  ; The address on which to accept FastCGI requests.
  64.  ; Valid syntaxes are:
  65.  ;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
  66. @@ -125,12 +152,6 @@
  67.  ;listen.group = @php_fpm_group@
  68.  ;listen.mode = 0666
  69.  
  70. -; Unix user/group of processes
  71. -; Note: The user is mandatory. If the group is not set, the default user's group
  72. -;       will be used.
  73. -user = @php_fpm_user@
  74. -group = @php_fpm_group@
  75. -
  76.  ; Choose how the process manager will control the number of child processes.
  77.  ; Possible Values:
  78.  ;   static  - a fixed number (pm.max_children) of child processes;
  79. @@ -278,7 +299,7 @@
  80.  ;       anything, but it may not be a good idea to use the .php extension or it
  81.  ;       may conflict with a real PHP file.
  82.  ; Default Value: not set
  83. -;pm.status_path = /status
  84. +;diagnostics.status_path = /status
  85.  
  86.  ; The ping URI to call the monitoring page of FPM. If this value is not set, no
  87.  ; URI will be recognized as a ping page. This could be used to test from outside
  88. @@ -290,12 +311,12 @@
  89.  ;       anything, but it may not be a good idea to use the .php extension or it
  90.  ;       may conflict with a real PHP file.
  91.  ; Default Value: not set
  92. -;ping.path = /ping
  93. +;diagnostics.ping_path = /ping
  94.  
  95.  ; This directive may be used to customize the response of a ping request. The
  96.  ; response is formatted as text/plain with a 200 response code.
  97.  ; Default Value: pong
  98. -;ping.response = pong
  99. +;diagnostics.ping_response = pong
  100.  
  101.  ; The access log file
  102.  ; Default: not set
  103. @@ -322,7 +343,7 @@
  104.  ;      - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
  105.  ;      - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
  106.  ;  %f: script filename
  107. -:  %l: content-length of the request (for POST request only)
  108. +;  %l: content-length of the request (for POST request only)
  109.  ;  %m: request method
  110.  ;  %M: peak of memory allocated by PHP
  111.  ;      it can accept the following format:
  112. @@ -355,6 +376,11 @@
  113.  ;
  114.  ; Default: "%R - %u %t \"%m %r\" %s"
  115.  ;access.format = %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%
  116. +
  117. +; The log file for slow requests
  118. +; Default Value: not set
  119. +; Note: slowlog is mandatory if request_slowlog_timeout is set
  120. +;slowlog = log/$pool.log.slow
  121.  
  122.  ; The timeout for serving a single request after which the worker process will
  123.  ; be killed. This option should be used when the 'max_execution_time' ini option
  124. @@ -369,11 +395,6 @@
  125.  ; Default Value: 0
  126.  ;request_slowlog_timeout = 0
  127.  
  128. -; The log file for slow requests
  129. -; Default Value: not set
  130. -; Note: slowlog is mandatory if request_slowlog_timeout is set
  131. -;slowlog = log/$pool.log.slow
  132. -
  133.  ; Set open file descriptor rlimit.
  134.  ; Default Value: system defined value
  135.  ;rlimit_files = 1024
  136. Index: sapi/fpm/fpm/fpm.c
  137. ===================================================================
  138. --- sapi/fpm/fpm/fpm.c  (revision 312829)
  139. +++ sapi/fpm/fpm/fpm.c  (working copy)
  140. @@ -49,27 +49,29 @@
  141.     fpm_globals.prefix = prefix;
  142.     fpm_globals.pid = pid;
  143.  
  144. -   if (0 > fpm_php_init_main()            ||
  145. -       0 > fpm_stdio_init_main()            ||
  146. -       0 > fpm_conf_init_main(test_conf)    ||
  147. -       0 > fpm_unix_init_main()             ||
  148. -       0 > fpm_scoreboard_init_main()       ||
  149. -       0 > fpm_pctl_init_main()             ||
  150. -       0 > fpm_env_init_main()              ||
  151. -       0 > fpm_signals_init_main()          ||
  152. -       0 > fpm_children_init_main()         ||
  153. -       0 > fpm_sockets_init_main()          ||
  154. -       0 > fpm_worker_pool_init_main()      ||
  155. -       0 > fpm_event_init_main()) {
  156. -      
  157. +   if (0 > fpm_php_init_main()              ||
  158. +       0 > fpm_stdio_init_main()            ||
  159. +       0 > fpm_conf_init_main(test_conf)    ||
  160. +       0 > fpm_unix_init_main()             ||
  161. +       0 > fpm_scoreboard_init_main()       ||
  162. +       0 > fpm_pctl_init_main()             ||
  163. +       0 > fpm_env_init_main()              ||
  164. +       0 > fpm_signals_init_main()          ||
  165. +       0 > fpm_children_init_main()         ||
  166. +       0 > fpm_sockets_init_main()          ||
  167. +       0 > fpm_worker_pool_init_main()      ||
  168. +       0 > fpm_event_init_main()) {
  169. +
  170.         if (fpm_globals.test_successful) {
  171.             exit(0);
  172.         } else {
  173. +           zlog(ZLOG_ERROR, "FPM initialization failed");
  174.             return -1;
  175.         }
  176.     }
  177.  
  178.     if (0 > fpm_conf_write_pid()) {
  179. +       zlog(ZLOG_ERROR, "FPM initialization failed");
  180.         return -1;
  181.     }
  182.  
  183. @@ -114,4 +116,3 @@
  184.     return fpm_globals.listening_socket;
  185.  }
  186.  /* }}} */
  187. -
  188. Index: sapi/fpm/fpm/fpm_stdio.c
  189. ===================================================================
  190. --- sapi/fpm/fpm/fpm_stdio.c    (revision 312829)
  191. +++ sapi/fpm/fpm/fpm_stdio.c    (working copy)
  192. @@ -25,16 +25,17 @@
  193.  {
  194.     int fd = open("/dev/null", O_RDWR);
  195.  
  196. -   if (0 > fd) {
  197. +   if (fd < 0) {
  198.         zlog(ZLOG_SYSERROR, "open(\"/dev/null\") failed");
  199.         return -1;
  200.     }
  201.  
  202. -   if (0 > dup2(fd, STDIN_FILENO) || 0 > dup2(fd, STDOUT_FILENO)) {
  203. +   if (dup2(fd, STDIN_FILENO) < 0 || dup2(fd, STDOUT_FILENO) < 0) {
  204.         zlog(ZLOG_SYSERROR, "dup2() failed");
  205.         return -1;
  206.     }
  207.     close(fd);
  208. +
  209.     return 0;
  210.  }
  211.  /* }}} */
  212. @@ -250,7 +251,7 @@
  213.     int fd;
  214.  
  215.     fd = open(fpm_global_config.error_log, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
  216. -   if (0 > fd) {
  217. +   if (fd < 0) {
  218.         zlog(ZLOG_SYSERROR, "open(\"%s\") failed", fpm_global_config.error_log);
  219.         return -1;
  220.     }
  221. Index: sapi/fpm/fpm/fpm_unix.c
  222. ===================================================================
  223. --- sapi/fpm/fpm/fpm_unix.c (revision 312829)
  224. +++ sapi/fpm/fpm/fpm_unix.c (working copy)
  225. @@ -74,14 +74,13 @@
  226.  static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
  227.  {
  228.     int is_root = !geteuid();
  229. +   struct passwd *pwd;
  230.  
  231.     if (is_root) {
  232.         if (wp->config->user && *wp->config->user) {
  233.             if (strlen(wp->config->user) == strspn(wp->config->user, "0123456789")) {
  234.                 wp->set_uid = strtoul(wp->config->user, 0, 10);
  235.             } else {
  236. -               struct passwd *pwd;
  237. -
  238.                 pwd = getpwnam(wp->config->user);
  239.                 if (!pwd) {
  240.                     zlog(ZLOG_ERROR, "[pool %s] cannot get uid for user '%s'", wp->config->name, wp->config->user);
  241. @@ -119,25 +118,23 @@
  242.  #endif
  243.     } else { /* not root */
  244.         if (wp->config->user && *wp->config->user) {
  245. -           zlog(ZLOG_WARNING, "[pool %s] 'user' directive is ignored", wp->config->name);
  246. +           zlog(ZLOG_WARNING, "[pool %s] 'user' directive is ignored (not running as root)", wp->config->name);
  247.         }
  248.         if (wp->config->group && *wp->config->group) {
  249. -           zlog(ZLOG_WARNING, "[pool %s] 'group' directive is ignored", wp->config->name);
  250. +           zlog(ZLOG_WARNING, "[pool %s] 'group' directive is ignored (not running as root)", wp->config->name);
  251.         }
  252.         if (wp->config->chroot && *wp->config->chroot) {
  253. -           zlog(ZLOG_WARNING, "[pool %s] 'chroot' directive is ignored", wp->config->name);
  254. +           zlog(ZLOG_WARNING, "[pool %s] 'chroot' directive is ignored (not running as root)", wp->config->name);
  255.         }
  256.  
  257. -       { /* set up HOME and USER anyway */
  258. -           struct passwd *pwd;
  259. -
  260. -           pwd = getpwuid(getuid());
  261. -           if (pwd) {
  262. -               wp->user = strdup(pwd->pw_name);
  263. -               wp->home = strdup(pwd->pw_dir);
  264. -           }
  265. +       /* set up HOME and USER anyway */
  266. +       pwd = getpwuid(getuid());
  267. +       if (pwd) {
  268. +           wp->user = strdup(pwd->pw_name);
  269. +           wp->home = strdup(pwd->pw_dir);
  270.         }
  271.     }
  272. +
  273.     return 0;
  274.  }
  275.  /* }}} */
  276. Index: sapi/fpm/fpm/fpm_status.c
  277. ===================================================================
  278. --- sapi/fpm/fpm/fpm_status.c   (revision 312829)
  279. +++ sapi/fpm/fpm/fpm_status.c   (working copy)
  280. @@ -22,22 +22,15 @@
  281.  
  282.  int fpm_status_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
  283.  {
  284. -   if (!wp || !wp->config) {
  285. -       zlog(ZLOG_ERROR, "unable to init fpm_status because conf structure is NULL");
  286. -       return -1;
  287. -   }
  288. +   assert(wp);
  289.  
  290. -   if (wp->config->pm_status_path) {
  291. -       fpm_status_uri = strdup(wp->config->pm_status_path);
  292. +   if (wp->config->diag_status_path) {
  293. +       fpm_status_uri = strdup(wp->config->diag_status_path);
  294.     }
  295.  
  296. -   if (wp->config->ping_path) {
  297. -       if (!wp->config->ping_response) {
  298. -           zlog(ZLOG_ERROR, "[pool %s] ping is set (%s) but pong is not set.", wp->config->name, wp->config->ping_path);
  299. -           return -1;
  300. -       }
  301. -       fpm_status_ping_uri = strdup(wp->config->ping_path);
  302. -       fpm_status_ping_response = strdup(wp->config->ping_response);
  303. +   if (wp->config->diag_ping_path && wp->config->diag_ping_response) {
  304. +       fpm_status_ping_uri = strdup(wp->config->diag_ping_path);
  305. +       fpm_status_ping_response = strdup(wp->config->diag_ping_response);
  306.     }
  307.  
  308.     return 0;
  309. Index: sapi/fpm/fpm/fpm_conf.c
  310. ===================================================================
  311. --- sapi/fpm/fpm/fpm_conf.c (revision 312829)
  312. +++ sapi/fpm/fpm/fpm_conf.c (working copy)
  313. @@ -44,6 +44,10 @@
  314.  #include "fpm_log.h"
  315.  #include "zlog.h"
  316.  
  317. +#define STR2STR(a) (a ? a : "undefined")
  318. +#define BOOL2STR(a) (a ? "yes" : "no")
  319. +#define PM2STR(a) (a == PM_STYLE_STATIC ? "static" : "dynamic")
  320. +
  321.  static int fpm_conf_load_ini_file(char *filename TSRMLS_DC);
  322.  static char *fpm_conf_set_integer(zval *value, void **config, intptr_t offset);
  323.  static char *fpm_conf_set_time(zval *value, void **config, intptr_t offset);
  324. @@ -53,8 +57,22 @@
  325.  static char *fpm_conf_set_rlimit_core(zval *value, void **config, intptr_t offset);
  326.  static char *fpm_conf_set_pm(zval *value, void **config, intptr_t offset);
  327.  
  328. -struct fpm_global_config_s fpm_global_config = { .daemonize = 1 };
  329. -static struct fpm_worker_pool_s *current_wp = NULL;
  330. +struct fpm_global_config_s fpm_global_config = {
  331. +   .daemonize = 1
  332. +};
  333. +
  334. +static struct fpm_worker_pool_config_s fpm_pool_default_config = {
  335. +   .user = "nobody",
  336. +   .group = "nobody",
  337. +   .pm_max_children = 50,
  338. +   .pm_max_requests = 0,
  339. +   .pm_max_spare_servers = 15,
  340. +   .pm_start_servers = 5,
  341. +   .diag_ping_response = "pong",
  342. +   .listen_backlog = FPM_BACKLOG_DEFAULT
  343. +};
  344. +
  345. +static struct fpm_worker_pool_config_s *ini_current_config = NULL;
  346.  static int ini_recursion = 0;
  347.  static char *ini_filename = NULL;
  348.  static int ini_lineno = 0;
  349. @@ -64,47 +82,61 @@
  350.  #define WPO(field) offsetof(struct fpm_worker_pool_config_s, field)
  351.  
  352.  static struct ini_value_parser_s ini_fpm_global_options[] = {
  353. -   { "emergency_restart_threshold",    &fpm_conf_set_integer,      GO(emergency_restart_threshold) },
  354. -   { "emergency_restart_interval",     &fpm_conf_set_time,             GO(emergency_restart_interval) },
  355. -   { "process_control_timeout",            &fpm_conf_set_time,             GO(process_control_timeout) },
  356. -   { "daemonize",                                      &fpm_conf_set_boolean,      GO(daemonize) },
  357. -   { "pid",                                                    &fpm_conf_set_string,           GO(pid_file) },
  358. -   { "error_log",                                      &fpm_conf_set_string,           GO(error_log) },
  359. -   { "log_level",                                      &fpm_conf_set_log_level,    0 },
  360. -   { "rlimit_files",                                   &fpm_conf_set_integer,      GO(rlimit_files) },
  361. -   { "rlimit_core",                                    &fpm_conf_set_rlimit_core,GO(rlimit_core) },
  362. +   { "emergency_restart_threshold",        &fpm_conf_set_integer,     GO(emergency_restart_threshold) },
  363. +   { "emergency_restart_interval",         &fpm_conf_set_time,        GO(emergency_restart_interval) },
  364. +   { "process_control_timeout",            &fpm_conf_set_time,        GO(process_control_timeout) },
  365. +   { "daemonize",                          &fpm_conf_set_boolean,     GO(daemonize) },
  366. +   { "pid",                                &fpm_conf_set_string,      GO(pid_file) },
  367. +   { "error_log",                          &fpm_conf_set_string,      GO(error_log) },
  368. +   { "log_level",                          &fpm_conf_set_log_level,   0 },
  369. +   { "rlimit_files",                       &fpm_conf_set_integer,     GO(rlimit_files) },
  370. +   { "rlimit_core",                        &fpm_conf_set_rlimit_core, GO(rlimit_core) },
  371.     { 0, 0, 0 }
  372.  };
  373.  
  374.  static struct ini_value_parser_s ini_fpm_pool_options[] = {
  375. -   { "prefix", &fpm_conf_set_string, WPO(prefix) },
  376. -   { "user", &fpm_conf_set_string, WPO(user) },
  377. -   { "group", &fpm_conf_set_string, WPO(group) },
  378. -   { "chroot", &fpm_conf_set_string, WPO(chroot) },
  379. -   { "chdir", &fpm_conf_set_string, WPO(chdir) },
  380. -   { "request_terminate_timeout", &fpm_conf_set_time, WPO(request_terminate_timeout) },
  381. -   { "request_slowlog_timeout", &fpm_conf_set_time, WPO(request_slowlog_timeout) },
  382. -   { "slowlog", &fpm_conf_set_string, WPO(slowlog) },
  383. -   { "rlimit_files", &fpm_conf_set_integer, WPO(rlimit_files) },
  384. -   { "rlimit_core", &fpm_conf_set_rlimit_core, WPO(rlimit_core) },
  385. -   { "catch_workers_output", &fpm_conf_set_boolean, WPO(catch_workers_output) },
  386. -   { "listen", &fpm_conf_set_string, WPO(listen_address) },
  387. -   { "listen.owner", &fpm_conf_set_string, WPO(listen_owner) },
  388. -   { "listen.group", &fpm_conf_set_string, WPO(listen_group) },
  389. -   { "listen.mode", &fpm_conf_set_string, WPO(listen_mode) },
  390. -   { "listen.backlog", &fpm_conf_set_integer, WPO(listen_backlog) },
  391. -   { "listen.allowed_clients", &fpm_conf_set_string, WPO(listen_allowed_clients) },
  392. -   { "pm", &fpm_conf_set_pm, WPO(pm) },
  393. -   { "pm.max_requests", &fpm_conf_set_integer, WPO(pm_max_requests) },
  394. -   { "pm.max_children", &fpm_conf_set_integer, WPO(pm_max_children) },
  395. -   { "pm.start_servers", &fpm_conf_set_integer, WPO(pm_start_servers) },
  396. -   { "pm.min_spare_servers", &fpm_conf_set_integer, WPO(pm_min_spare_servers) },
  397. -   { "pm.max_spare_servers", &fpm_conf_set_integer, WPO(pm_max_spare_servers) },
  398. -   { "pm.status_path", &fpm_conf_set_string, WPO(pm_status_path) },
  399. -   { "ping.path", &fpm_conf_set_string, WPO(ping_path) },
  400. -   { "ping.response", &fpm_conf_set_string, WPO(ping_response) },
  401. -   { "access.log", &fpm_conf_set_string, WPO(access_log) },
  402. -   { "access.format", &fpm_conf_set_string, WPO(access_format) },
  403. +   { "prefix",                             &fpm_conf_set_string,      WPO(prefix) },
  404. +
  405. +   { "user",                               &fpm_conf_set_string,      WPO(user) },
  406. +   { "group",                              &fpm_conf_set_string,      WPO(group) },
  407. +
  408. +   { "pm",                                 &fpm_conf_set_pm,          WPO(pm) },
  409. +   { "pm.max_children",                    &fpm_conf_set_integer,     WPO(pm_max_children) },
  410. +   { "pm.start_servers",                   &fpm_conf_set_integer,     WPO(pm_start_servers) },
  411. +   { "pm.min_spare_servers",               &fpm_conf_set_integer,     WPO(pm_min_spare_servers) },
  412. +   { "pm.max_spare_servers",               &fpm_conf_set_integer,     WPO(pm_max_spare_servers) },
  413. +   { "pm.max_requests",                    &fpm_conf_set_integer,     WPO(pm_max_requests) },
  414. +
  415. +   { "listen",                             &fpm_conf_set_string,      WPO(listen_address) },
  416. +   { "listen.backlog",                     &fpm_conf_set_integer,     WPO(listen_backlog) },
  417. +   { "listen.allowed_clients",             &fpm_conf_set_string,      WPO(listen_allowed_clients) },
  418. +   { "listen.owner",                       &fpm_conf_set_string,      WPO(listen_owner) },
  419. +   { "listen.group",                       &fpm_conf_set_string,      WPO(listen_group) },
  420. +   { "listen.mode",                        &fpm_conf_set_string,      WPO(listen_mode) },
  421. +
  422. +   { "access.log",                         &fpm_conf_set_string,      WPO(access_log) },
  423. +   { "access.format",                      &fpm_conf_set_string,      WPO(access_format) },
  424. +   { "slowlog",                            &fpm_conf_set_string,      WPO(slowlog) },
  425. +
  426. +   { "request_terminate_timeout",          &fpm_conf_set_time,        WPO(request_terminate_timeout) },
  427. +   { "request_slowlog_timeout",            &fpm_conf_set_time,        WPO(request_slowlog_timeout) },
  428. +   { "rlimit_files",                       &fpm_conf_set_integer,     WPO(rlimit_files) },
  429. +   { "rlimit_core",                        &fpm_conf_set_rlimit_core, WPO(rlimit_core) },
  430. +
  431. +   { "chroot",                             &fpm_conf_set_string,      WPO(chroot) },
  432. +   { "chdir",                              &fpm_conf_set_string,      WPO(chdir) },
  433. +
  434. +   { "catch_workers_output",               &fpm_conf_set_boolean,     WPO(catch_workers_output) },
  435. +
  436. +   { "diagnostics.status_path",            &fpm_conf_set_string,      WPO(diag_status_path) },
  437. +   { "diagnostics.ping_path",              &fpm_conf_set_string,      WPO(diag_ping_path) },
  438. +   { "diagnostics.ping_response",          &fpm_conf_set_string,      WPO(diag_ping_response) },
  439. +
  440. +   /* Backward compatibility options, to be removed in the next major release */
  441. +   { "ping.path",                          &fpm_conf_set_string,      WPO(diag_ping_path) },
  442. +   { "ping.response",                      &fpm_conf_set_string,      WPO(diag_ping_response) },
  443. +   { "pm.status_path",                     &fpm_conf_set_string,      WPO(diag_status_path) },
  444. +
  445.     { 0, 0, 0 }
  446.  };
  447.  
  448. @@ -120,22 +152,28 @@
  449.  }
  450.  /* }}} */
  451.  
  452. +/// Expands the '$pool' token in a dynamically allocated string
  453.  static int fpm_conf_expand_pool_name(char **value) {
  454.     char *token;
  455. +   assert(value);
  456.  
  457. -   if (!value || !*value) {
  458. -       return 0;
  459. -   }
  460. -
  461. -   while ((token = strstr(*value, "$pool"))) {
  462. +   while (*value && (token = strstr(*value, "$pool"))) {
  463.         char *buf;
  464. -       char *p1 = *value;
  465.         char *p2 = token + strlen("$pool");
  466. -       if (!current_wp || !current_wp->config  || !current_wp->config->name) {
  467. +
  468. +       /* If we are not in a pool, we cannot expand this name now */
  469. +       if (!ini_current_config || !ini_current_config->name) {
  470.             return -1;
  471.         }
  472. +
  473. +       /* "aaa$poolbbb" becomes "aaa\0oolbbb" */
  474.         token[0] = '\0';
  475. -       spprintf(&buf, 0, "%s%s%s", p1, current_wp->config->name, p2);
  476. +
  477. +       /* Build a brand new string with the expanded token */
  478. +       spprintf(&buf, 0, "%s%s%s", *value, ini_current_config->name, token + sizeof("$pool") - 1);
  479. +
  480. +       /* Free the previous value and save the new one */
  481. +       free(*value);
  482.         *value = strdup(buf);
  483.         efree(buf);
  484.     }
  485. @@ -160,34 +198,34 @@
  486.  
  487.  static char *fpm_conf_set_string(zval *value, void **config, intptr_t offset) /* {{{ */
  488.  {
  489. -   char *new;
  490. -   char **old = (char **) ((char *) *config + offset);
  491. -   if (*old) {
  492. -       return "it's already been defined. Can't do that twice.";
  493. +   char **config_val = (char **) ((char *) *config + offset);
  494. +
  495. +   /* Check if there is a previous value to deallocate */
  496. +   if (*config_val) {
  497. +       free(*config_val);
  498.     }
  499.  
  500. -   new = strdup(Z_STRVAL_P(value));
  501. -   if (!new) {
  502. +   *config_val = strdup(Z_STRVAL_P(value));
  503. +   if (!*config_val) {
  504.         return "fpm_conf_set_string(): strdup() failed";
  505.     }
  506. -   if (fpm_conf_expand_pool_name(&new) == -1) {
  507. -       return "Can't use '$pool' when the pool is not defined";
  508. +   if (fpm_conf_expand_pool_name(config_val) != 0) {
  509. +       return "can't use \"$pool\" when the pool is not defined";
  510.     }
  511.  
  512. -   *old = new;
  513.     return NULL;
  514.  }
  515.  /* }}} */
  516.  
  517.  static char *fpm_conf_set_integer(zval *value, void **config, intptr_t offset) /* {{{ */
  518.  {
  519. -   char *val = Z_STRVAL_P(value);
  520. -   char *p;
  521. +   char *p, *val = Z_STRVAL_P(value);
  522.  
  523. -   for(p=val; *p; p++) {
  524. -       if ( p == val && *p == '-' ) continue;
  525. +   /* FIXME: can we use strtol here and save this ridiculous for()? */
  526. +   for (p = val; *p; p++) {
  527. +       if (p == val && *p == '-') continue;
  528.         if (*p < '0' || *p > '9') {
  529. -           return "is not a valid number (greater or equal than zero)";
  530. +           return "not a valid number";
  531.         }
  532.     }
  533.     * (int *) ((char *) *config + offset) = atoi(val);
  534. @@ -205,7 +243,7 @@
  535.         return "invalid time value";
  536.     }
  537.  
  538. -   suffix = val[len-1];
  539. +   suffix = val[len - 1];
  540.     switch (suffix) {
  541.         case 'm' :
  542.             val[len-1] = '\0';
  543. @@ -343,25 +381,45 @@
  544.  }
  545.  /* }}} */
  546.  
  547. -static void *fpm_worker_pool_config_alloc() /* {{{ */
  548. +static struct fpm_worker_pool_s *fpm_worker_pool_config_alloc() /* {{{ */
  549. +#define DUP_STR(fieldname) \
  550. +   if (wp->config->fieldname) \
  551. +       wp->config->fieldname = strdup(wp->config->fieldname);
  552.  {
  553.     struct fpm_worker_pool_s *wp;
  554.  
  555.     wp = fpm_worker_pool_alloc();
  556. -
  557.     if (!wp) {
  558. -       return 0;
  559. +       return NULL;
  560.     }
  561.  
  562.     wp->config = malloc(sizeof(struct fpm_worker_pool_config_s));
  563. -
  564. -   if (!wp->config) {
  565. -       return 0;
  566. +   if (!wp->config) {
  567. +       free(wp);
  568. +       return NULL;
  569.     }
  570.  
  571. -   memset(wp->config, 0, sizeof(struct fpm_worker_pool_config_s));
  572. -   wp->config->listen_backlog = FPM_BACKLOG_DEFAULT;
  573. +   /* Initialize this workers pool definition with the defaults */
  574. +   memcpy(wp->config, &fpm_pool_default_config, sizeof(struct fpm_worker_pool_config_s));
  575. +   wp->config->name = NULL;
  576. +   DUP_STR(prefix);
  577. +   DUP_STR(user);
  578. +   DUP_STR(group);
  579. +   DUP_STR(listen_address);
  580. +   DUP_STR(listen_allowed_clients);
  581. +   DUP_STR(listen_owner);
  582. +   DUP_STR(listen_group);
  583. +   DUP_STR(listen_mode);
  584. +   DUP_STR(access_log);
  585. +   DUP_STR(access_format);
  586. +   DUP_STR(slowlog);
  587. +   DUP_STR(chroot);
  588. +   DUP_STR(chdir);
  589. +   DUP_STR(diag_status_path);
  590. +   DUP_STR(diag_ping_path);
  591. +   DUP_STR(diag_ping_response);
  592.  
  593. +   /* Append this pool to the linked list */
  594.     if (!fpm_worker_all_pools) {
  595.         fpm_worker_all_pools = wp;
  596.     } else {
  597. @@ -375,23 +433,15 @@
  598.         }
  599.     }
  600.  
  601. -   current_wp = wp;
  602. -   return wp->config;
  603. +   return wp;
  604.  }
  605. +#undef DUP_STR
  606.  /* }}} */
  607.  
  608.  int fpm_worker_pool_config_free(struct fpm_worker_pool_config_s *wpc) /* {{{ */
  609.  {
  610.     struct key_value_s *kv, *kv_next;
  611.  
  612. -   free(wpc->name);
  613. -   free(wpc->pm_status_path);
  614. -   free(wpc->ping_path);
  615. -   free(wpc->ping_response);
  616. -   free(wpc->listen_address);
  617. -   free(wpc->listen_owner);
  618. -   free(wpc->listen_group);
  619. -   free(wpc->listen_mode);
  620.     for (kv = wpc->php_values; kv; kv = kv_next) {
  621.         kv_next = kv->next;
  622.         free(kv->key);
  623. @@ -410,16 +460,30 @@
  624.         free(kv->value);
  625.         free(kv);
  626.     }
  627. -   free(wpc->listen_allowed_clients);
  628. -   free(wpc->user);
  629. -   free(wpc->group);
  630. +
  631. +   free(wpc->diag_ping_response);
  632. +   free(wpc->diag_ping_path);
  633. +   free(wpc->diag_status_path);
  634. +
  635. +   free(wpc->chdir);
  636.     free(wpc->chroot);
  637. -   free(wpc->chdir);
  638. +
  639.     free(wpc->slowlog);
  640. -   free(wpc->prefix);
  641. +   free(wpc->access_format);
  642.     free(wpc->access_log);
  643. -   free(wpc->access_format);
  644.  
  645. +   free(wpc->listen_mode);
  646. +   free(wpc->listen_group);
  647. +   free(wpc->listen_owner);
  648. +   free(wpc->listen_allowed_clients);
  649. +   free(wpc->listen_address);
  650. +
  651. +   free(wpc->group);
  652. +   free(wpc->user);
  653. +
  654. +   free(wpc->prefix);
  655. +   free(wpc->name);
  656. +
  657.     return 0;
  658.  }
  659.  /* }}} */
  660. @@ -599,8 +663,8 @@
  661.             }
  662.         }
  663.  
  664. -       if (wp->config->ping_path && *wp->config->ping_path) {
  665. -           char *ping = wp->config->ping_path;
  666. +       if (wp->config->diag_ping_path) {
  667. +           char *ping = wp->config->diag_ping_path;
  668.             int i;
  669.  
  670.             if (*ping != '/') {
  671. @@ -613,46 +677,31 @@
  672.                 return -1;
  673.             }
  674.  
  675. -           for (i=0; i<strlen(ping); i++) {
  676. +           for (i = 0; i < strlen(ping); i++) {
  677.                 if (!isalnum(ping[i]) && ping[i] != '/' && ping[i] != '-' && ping[i] != '_' && ping[i] != '.') {
  678.                     zlog(ZLOG_ERROR, "[pool %s] the ping path '%s' must containt only the following characters '[alphanum]/_-.'", wp->config->name, ping);
  679.                     return -1;
  680.                 }
  681.             }
  682. -
  683. -           if (!wp->config->ping_response) {
  684. -               wp->config->ping_response = strdup("pong");
  685. -           } else {
  686. -               if (strlen(wp->config->ping_response) < 1) {
  687. -                   zlog(ZLOG_ERROR, "[pool %s] the ping response page '%s' is not long enough", wp->config->name, wp->config->ping_response);
  688. -                   return -1;
  689. -               }
  690. -           }
  691. -       } else {
  692. -           if (wp->config->ping_response) {
  693. -               free(wp->config->ping_response);
  694. -               wp->config->ping_response = NULL;
  695. -           }
  696.         }
  697.  
  698. -       if (wp->config->pm_status_path && *wp->config->pm_status_path) {
  699. +       if (wp->config->diag_status_path) {
  700.             int i;
  701. -           char *status = wp->config->pm_status_path;
  702. -           /* struct fpm_status_s fpm_status; */
  703. +           char *status = wp->config->diag_status_path;
  704.  
  705.             if (*status != '/') {
  706. -               zlog(ZLOG_ERROR, "[pool %s] the status path '%s' must start with a '/'", wp->config->name, status);
  707. +               zlog(ZLOG_ERROR, "[pool %s] the status path \"%s\" must start with a \"/\"", wp->config->name, status);
  708.                 return -1;
  709.             }
  710.  
  711.             if (strlen(status) < 2) {
  712. -               zlog(ZLOG_ERROR, "[pool %s] the status path '%s' is not long enough", wp->config->name, status);
  713. +               zlog(ZLOG_ERROR, "[pool %s] the status path \"%s\" is not long enough", wp->config->name, status);
  714.                 return -1;
  715.             }
  716.  
  717. -           for (i=0; i<strlen(status); i++) {
  718. +           for (i = 0; i < strlen(status); i++) {
  719.                 if (!isalnum(status[i]) && status[i] != '/' && status[i] != '-' && status[i] != '_' && status[i] != '.') {
  720. -                   zlog(ZLOG_ERROR, "[pool %s] the status path '%s' must contain only the following characters '[alphanum]/_-.'", wp->config->name, status);
  721. +                   zlog(ZLOG_ERROR, "[pool %s] the status path '%s' can contain only the following characters '[alphanum]/_-.'", wp->config->name, status);
  722.                     return -1;
  723.                 }
  724.             }
  725. @@ -707,20 +756,21 @@
  726.                 }
  727.             }
  728.         }
  729. +
  730.         if (!wp->config->chroot) {
  731.             struct key_value_s *kv;
  732.             char *options[] = FPM_PHP_INI_TO_EXPAND;
  733.             char **p;
  734.  
  735.             for (kv = wp->config->php_values; kv; kv = kv->next) {
  736. -               for (p=options; *p; p++) {
  737. +               for (p = options; *p; p++) {
  738.                     if (!strcasecmp(kv->key, *p)) {
  739.                         fpm_evaluate_full_path(&kv->value, wp, NULL, 0);
  740.                     }
  741.                 }
  742.             }
  743.             for (kv = wp->config->php_admin_values; kv; kv = kv->next) {
  744. -               for (p=options; *p; p++) {
  745. +               for (p = options; *p; p++) {
  746.                     if (!strcasecmp(kv->key, *p)) {
  747.                         fpm_evaluate_full_path(&kv->value, wp, NULL, 0);
  748.                     }
  749. @@ -772,7 +822,7 @@
  750.  }
  751.  /* }}} */
  752.  
  753. -static int fpm_conf_post_process(TSRMLS_D) /* {{{ */
  754. +static int fpm_conf_post_process(int test_conf TSRMLS_DC) /* {{{ */
  755.  {
  756.     struct fpm_worker_pool_s *wp;
  757.  
  758. @@ -786,15 +836,17 @@
  759.  
  760.     fpm_evaluate_full_path(&fpm_global_config.error_log, NULL, PHP_LOCALSTATEDIR, 0);
  761.  
  762. -   if (0 > fpm_stdio_open_error_log(0)) {
  763. -       return -1;
  764. -   }
  765. +   if (!test_conf) {
  766. +       if (fpm_stdio_open_error_log(0) != 0) {
  767. +           return -1;
  768. +       }
  769.  
  770. -   if (0 > fpm_log_open(0)) {
  771. -       return -1;
  772. +       if (fpm_log_open(0) != 0) {
  773. +           return -1;
  774. +       }
  775.     }
  776.  
  777. -   if (0 > fpm_conf_process_all_pools()) {
  778. +   if (fpm_conf_process_all_pools() != 0) {
  779.         return -1;
  780.     }
  781.  
  782. @@ -802,7 +854,7 @@
  783.         if (!wp->config->access_log || !*wp->config->access_log) {
  784.             continue;
  785.         }
  786. -       if (0 > fpm_log_write(wp->config->access_format TSRMLS_CC)) {
  787. +       if (fpm_log_write(wp->config->access_format TSRMLS_CC) != 0) {
  788.             zlog(ZLOG_ERROR, "[pool %s] wrong format for access.format '%s'", wp->config->name, wp->config->access_format);
  789.             return -1;
  790.         }
  791. @@ -850,11 +902,11 @@
  792.             return;
  793.         }
  794.  
  795. -       for(i=0; i<g.gl_pathc; i++) {
  796. +       for(i = 0; i < g.gl_pathc; i++) {
  797.             int len = strlen(g.gl_pathv[i]);
  798.             if (len < 1) continue;
  799.             if (g.gl_pathv[i][len - 1] == '/') continue; /* don't parse directories */
  800. -           if (0 > fpm_conf_load_ini_file(g.gl_pathv[i] TSRMLS_CC)) {
  801. +           if (!fpm_conf_load_ini_file(g.gl_pathv[i] TSRMLS_CC)) {
  802.                 zlog(ZLOG_ERROR, "Unable to include %s from %s at line %d", g.gl_pathv[i], filename, ini_lineno);
  803.                 *error = 1;
  804.                 efree(filename);
  805. @@ -864,7 +916,7 @@
  806.         globfree(&g);
  807.     }
  808.  #else /* HAVE_GLOB */
  809. -   if (0 > fpm_conf_load_ini_file(inc TSRMLS_CC)) {
  810. +   if (!fpm_conf_load_ini_file(inc TSRMLS_CC)) {
  811.         zlog(ZLOG_ERROR, "Unable to include %s from %s at line %d", inc, filename, ini_lineno);
  812.         *error = 1;
  813.         efree(filename);
  814. @@ -876,50 +928,72 @@
  815.  }
  816.  /* }}} */
  817.  
  818. +/**
  819. + * Callback for zend_parse_ini_string() for ZEND_INI_PARSER_SECTION type
  820. + */
  821.  static void fpm_conf_ini_parser_section(zval *section, void *arg TSRMLS_DC) /* {{{ */
  822.  {
  823.     struct fpm_worker_pool_s *wp;
  824.     struct fpm_worker_pool_config_s *config;
  825.     int *error = (int *)arg;
  826.  
  827. -   /* switch to global conf */
  828. +   /* Switch to global conf */
  829.     if (!strcasecmp(Z_STRVAL_P(section), "global")) {
  830. -       current_wp = NULL;
  831. +       ini_current_config = NULL;
  832.         return;
  833.     }
  834.  
  835. -   for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
  836. -       if (!wp->config) continue;
  837. -       if (!wp->config->name) continue;
  838. -       if (!strcasecmp(wp->config->name, Z_STRVAL_P(section))) {
  839. -           /* Found a wp with the same name. Bring it back */
  840. -           current_wp = wp;
  841. +   if (!strcasecmp(Z_STRVAL_P(section), "defaults")) {
  842. +       /* If there is a defaults section it must be before any
  843. +        * workers definition */
  844. +       if (fpm_worker_all_pools != NULL) {
  845. +           zlog(ZLOG_ERROR, "[%s:%d] Defaults section must be before any workers pool definition", ini_filename, ini_lineno);
  846. +           *error = 1;
  847.             return;
  848.         }
  849. -   }
  850.  
  851. -   /* it's a new pool */
  852. -   config = (struct fpm_worker_pool_config_s *)fpm_worker_pool_config_alloc();
  853. -   if (!current_wp || !config) {
  854. -       zlog(ZLOG_ERROR, "[%s:%d] Unable to alloc a new WorkerPool for worker '%s'", ini_filename, ini_lineno, Z_STRVAL_P(section));
  855. -       *error = 1;
  856. +       ini_current_config = &fpm_pool_default_config;
  857.         return;
  858.     }
  859. -   config->name = strdup(Z_STRVAL_P(section));
  860. -   if (!config->name) {
  861. -       zlog(ZLOG_ERROR, "[%s:%d] Unable to alloc memory for configuration name for worker '%s'", ini_filename, ini_lineno, Z_STRVAL_P(section));
  862. -       *error = 1;
  863. -       return;
  864. +
  865. +   /* Search for a wp with the same name and bring it back in case */
  866. +   for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
  867. +       if (wp->config->name &&
  868. +           !strcasecmp(wp->config->name, Z_STRVAL_P(section))) {
  869. +           break;
  870. +       }
  871.     }
  872. +
  873. +   /* It's a new pool */
  874. +   if (!wp) {
  875. +       wp = fpm_worker_pool_config_alloc();
  876. +       if (!wp) {
  877. +           zlog(ZLOG_ERROR, "[%s:%d] Unable to allocate a new WorkerPool for \"%s\"", ini_filename, ini_lineno, Z_STRVAL_P(section));
  878. +           *error = 1;
  879. +           return;
  880. +       }
  881. +
  882. +       wp->config->name = strdup(Z_STRVAL_P(section));
  883. +       if (!wp->config->name) {
  884. +           zlog(ZLOG_ERROR, "[%s:%d] Unable to allocate memory for worker \"%s\"", ini_filename, ini_lineno, Z_STRVAL_P(section));
  885. +           *error = 1;
  886. +           return;
  887. +       }
  888. +   }
  889. +
  890. +   ini_current_config = wp->config;
  891.  }
  892.  /* }}} */
  893.  
  894. +/**
  895. + * Callback for zend_parse_ini_string() for ZEND_INI_PARSER_ENTRY type
  896. + */
  897.  static void fpm_conf_ini_parser_entry(zval *name, zval *value, void *arg TSRMLS_DC) /* {{{ */
  898.  {
  899. -   struct ini_value_parser_s *parser;
  900. +   struct ini_value_parser_s *opt;
  901. +   int *error = (int *) arg;
  902.     void *config = NULL;
  903.  
  904. -   int *error = (int *)arg;
  905.     if (!value) {
  906.         zlog(ZLOG_ERROR, "[%s:%d] value is NULL for a ZEND_INI_PARSER_ENTRY", ini_filename, ini_lineno);
  907.         *error = 1;
  908. @@ -928,7 +1002,7 @@
  909.  
  910.     if (!strcmp(Z_STRVAL_P(name), "include")) {
  911.         if (ini_include) {
  912. -           zlog(ZLOG_ERROR, "[%s:%d] two includes at the same time !", ini_filename, ini_lineno);
  913. +           zlog(ZLOG_ERROR, "[%s:%d] two includes at the same time!", ini_filename, ini_lineno);
  914.             *error = 1;
  915.             return;
  916.         }
  917. @@ -936,41 +1010,38 @@
  918.         return;
  919.     }
  920.  
  921. -   if (!current_wp) { /* we are in the global section */
  922. -       parser = ini_fpm_global_options;
  923. +   if (!ini_current_config) {
  924. +       /* We are in the global section */
  925. +       opt = ini_fpm_global_options;
  926.         config = &fpm_global_config;
  927.     } else {
  928. -       parser = ini_fpm_pool_options;
  929. -       config = current_wp->config;
  930. +       /* We are in a pool section or the defaults section */
  931. +       opt = ini_fpm_pool_options;
  932. +       config = ini_current_config;
  933.     }
  934.  
  935. -   for (;parser->name; parser++) {
  936. -       if (!strcasecmp(parser->name, Z_STRVAL_P(name))) {
  937. -           char *ret;
  938. -           if (!parser->parser) {
  939. -               zlog(ZLOG_ERROR, "[%s:%d] the parser for entry '%s' is not defined", ini_filename, ini_lineno, parser->name);
  940. +   /* Find our option */
  941. +   while (opt->name) {
  942. +       if (!strcasecmp(opt->name, Z_STRVAL_P(name))) {
  943. +           char *errmsg = opt->parser(value, &config, opt->offset);
  944. +           if (errmsg) {
  945. +               zlog(ZLOG_ERROR, "[%s:%d] unable to parse value for entry '%s': %s", ini_filename, ini_lineno, opt->name, errmsg);
  946.                 *error = 1;
  947. -               return;
  948.             }
  949. -
  950. -           ret = parser->parser(value, &config, parser->offset);
  951. -           if (ret) {
  952. -               zlog(ZLOG_ERROR, "[%s:%d] unable to parse value for entry '%s': %s", ini_filename, ini_lineno, parser->name, ret);
  953. -               *error = 1;
  954. -               return;
  955. -           }
  956. -
  957. -           /* all is good ! */
  958.             return;
  959.         }
  960. +       opt++;
  961.     }
  962.  
  963.     /* nothing has been found if we got here */
  964. -   zlog(ZLOG_ERROR, "[%s:%d] unknown entry '%s'", ini_filename, ini_lineno, Z_STRVAL_P(name));
  965. +   zlog(ZLOG_ERROR, "[%s:%d] unknown entry \"%s\"", ini_filename, ini_lineno, Z_STRVAL_P(name));
  966.     *error = 1;
  967.  }
  968.  /* }}} */
  969.  
  970. +/**
  971. + * Callback for fpm_conf_ini_parser_entry() for ZEND_INI_PARSER_POP_ENTRY type
  972. + */
  973.  static void fpm_conf_ini_parser_array(zval *name, zval *key, zval *value, void *arg TSRMLS_DC) /* {{{ */
  974.  {
  975.     int *error = (int *)arg;
  976. @@ -982,7 +1053,7 @@
  977.         *error = 1;
  978.         return;
  979.     }
  980. -   if (!current_wp || !current_wp->config) {
  981. +   if (!ini_current_config) {
  982.         zlog(ZLOG_ERROR, "[%s:%d] Array are not allowed in the global section", ini_filename, ini_lineno);
  983.         *error = 1;
  984.         return;
  985. @@ -994,7 +1065,7 @@
  986.             *error = 1;
  987.             return;
  988.         }
  989. -       config = (char *)current_wp->config + WPO(env);
  990. +       config = (char *) ini_current_config + WPO(env);
  991.         err = fpm_conf_set_array(key, value, &config, 0);
  992.  
  993.     } else if (!strcmp("php_value", Z_STRVAL_P(name))) {
  994. @@ -1003,7 +1074,7 @@
  995.             *error = 1;
  996.             return;
  997.         }
  998. -       config = (char *)current_wp->config + WPO(php_values);
  999. +       config = (char *) ini_current_config + WPO(php_values);
  1000.         err = fpm_conf_set_array(key, value, &config, 0);
  1001.  
  1002.     } else if (!strcmp("php_admin_value", Z_STRVAL_P(name))) {
  1003. @@ -1012,15 +1083,15 @@
  1004.             *error = 1;
  1005.             return;
  1006.         }
  1007. -       config = (char *)current_wp->config + WPO(php_admin_values);
  1008. +       config = (char *) ini_current_config + WPO(php_admin_values);
  1009.         err = fpm_conf_set_array(key, value, &config, 0);
  1010.  
  1011.     } else if (!strcmp("php_flag", Z_STRVAL_P(name))) {
  1012. -       config = (char *)current_wp->config + WPO(php_values);
  1013. +       config = (char *) ini_current_config + WPO(php_values);
  1014.         err = fpm_conf_set_array(key, value, &config, 1);
  1015.  
  1016.     } else if (!strcmp("php_admin_flag", Z_STRVAL_P(name))) {
  1017. -       config = (char *)current_wp->config + WPO(php_admin_values);
  1018. +       config = (char *) ini_current_config + WPO(php_admin_values);
  1019.         err = fpm_conf_set_array(key, value, &config, 1);
  1020.  
  1021.     } else {
  1022. @@ -1037,28 +1108,36 @@
  1023.  }
  1024.  /* }}} */
  1025.  
  1026. +/**
  1027. + * Callback for zend_parse_ini_string()
  1028. + *
  1029. + * It's main purpose is to route the callback to the respective ini entry type handler
  1030. + */
  1031.  static void fpm_conf_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg TSRMLS_DC) /* {{{ */
  1032.  {
  1033. -   int *error;
  1034. +   int *error = (int *) arg;
  1035.  
  1036. +   // FIXME: is it possible at all?
  1037.     if (!arg1 || !arg) return;
  1038. -   error = (int *)arg;
  1039. -   if (*error) return; /* We got already an error. Switch to the end. */
  1040.  
  1041. -   switch(callback_type) {
  1042. +   /* Check if we already got an error */
  1043. +   if (*error) {
  1044. +       return;
  1045. +   }
  1046. +
  1047. +   switch (callback_type) {
  1048.         case ZEND_INI_PARSER_ENTRY:
  1049.             fpm_conf_ini_parser_entry(arg1, arg2, error TSRMLS_CC);
  1050. -           break;;
  1051. +           break;
  1052.         case ZEND_INI_PARSER_SECTION:
  1053.             fpm_conf_ini_parser_section(arg1, error TSRMLS_CC);
  1054. -           break;;
  1055. +           break;
  1056.         case ZEND_INI_PARSER_POP_ENTRY:
  1057.             fpm_conf_ini_parser_array(arg1, arg3, arg2, error TSRMLS_CC);
  1058. -           break;;
  1059. +           break;
  1060.         default:
  1061.             zlog(ZLOG_ERROR, "[%s:%d] Unknown INI syntax", ini_filename, ini_lineno);
  1062.             *error = 1;
  1063. -           break;;
  1064.     }
  1065.  }
  1066.  /* }}} */
  1067. @@ -1066,47 +1145,45 @@
  1068.  int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
  1069.  {
  1070.     int error = 0;
  1071. -   char buf[1024+1];
  1072. -   int fd, n;
  1073. -   int nb_read = 1;
  1074. -   char c = '*';
  1075. +   char buf[1024];
  1076. +   FILE *fd;
  1077. +   int tmp;
  1078. +   int retval = 0;
  1079. +   assert(filename);
  1080.  
  1081. -   int ret = 1;
  1082. -
  1083. -   if (!filename || !filename[0]) {
  1084. -       zlog(ZLOG_ERROR, "Configuration file is empty");
  1085. +   if (!filename[0]) {
  1086. +       zlog(ZLOG_ERROR, "Empty configuration file name");
  1087.         return -1;
  1088.     }
  1089.  
  1090. -   fd = open(filename, O_RDONLY, 0);
  1091. -   if (fd < 0) {
  1092. -       zlog(ZLOG_ERROR, "Unable to open file '%s', errno=%d", filename, errno);
  1093. +   fd = fopen(filename, "r");
  1094. +   if (fd == NULL) {
  1095. +       zlog(ZLOG_ERROR, "Unable to open FPM config file \"%s\": %s", filename, strerror(errno));
  1096.         return -1;
  1097.     }
  1098.  
  1099. -   if (ini_recursion++ > 4) {
  1100. -       zlog(ZLOG_ERROR, "You can include more than 5 files recusively");
  1101. +   if (ini_recursion++ >= FPM_CONF_MAX_RECURSION_LEVEL) {
  1102. +       zlog(ZLOG_ERROR, "Config file inclusion depth limit reached, recursion?");
  1103.         return -1;
  1104.     }
  1105.  
  1106.     ini_lineno = 0;
  1107. -   while (nb_read > 0) {
  1108. -       int tmp;
  1109. -       memset(buf, 0, sizeof(char) * (1024 + 1));
  1110. -       for (n=0; n<1024 && (nb_read = read(fd, &c, sizeof(char))) == sizeof(char) && c != '\n'; n++) {
  1111. -           buf[n] = c;
  1112. -       }
  1113. -       buf[n++] = '\n';
  1114. +   while (!feof(fd)) {
  1115. +       fgets(buf, sizeof(buf), fd);
  1116.         ini_lineno++;
  1117.         ini_filename = filename;
  1118. -       tmp = zend_parse_ini_string(buf, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t)fpm_conf_ini_parser, &error TSRMLS_CC);
  1119. +
  1120. +       tmp = zend_parse_ini_string(buf, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) fpm_conf_ini_parser, &error TSRMLS_CC);
  1121.         ini_filename = filename;
  1122. +
  1123.         if (error || tmp == FAILURE) {
  1124. -           if (ini_include) free(ini_include);
  1125. -           ini_recursion--;
  1126. -           close(fd);
  1127. -           return -1;
  1128. +           if (ini_include) {
  1129. +               free(ini_include);
  1130. +           }
  1131. +           retval = -1;
  1132. +           goto out;
  1133.         }
  1134. +
  1135.         if (ini_include) {
  1136.             char *tmp = ini_include;
  1137.             ini_include = NULL;
  1138. @@ -1114,80 +1191,97 @@
  1139.             fpm_conf_ini_parser_include(tmp, &error TSRMLS_CC);
  1140.             if (error) {
  1141.                 free(tmp);
  1142. -               ini_recursion--;
  1143. -               close(fd);
  1144. -               return -1;
  1145. +
  1146. +               retval = -1;
  1147. +               goto out;
  1148.             }
  1149.             free(tmp);
  1150.         }
  1151.     }
  1152.  
  1153. + out:
  1154.     ini_recursion--;
  1155. -   close(fd);
  1156. -   return ret;
  1157. +   fclose(fd);
  1158.  
  1159. +   return retval;
  1160.  }
  1161.  /* }}} */
  1162.  
  1163.  static void fpm_conf_dump() /* {{{ */
  1164.  {
  1165.     struct fpm_worker_pool_s *wp;
  1166. +   int emergency_restart_threshold;
  1167. +   int emergency_restart_interval;
  1168. +   int process_control_timeout;
  1169. +   int daemonize;
  1170. +   char *pid_file;
  1171. +   char *error_log;
  1172. +   int rlimit_files;
  1173. +   int rlimit_core;
  1174.  
  1175. -   zlog(ZLOG_NOTICE, "[General]");
  1176. -   zlog(ZLOG_NOTICE, "\tpid = %s", STR2STR(fpm_global_config.pid_file));
  1177. -   zlog(ZLOG_NOTICE, "\tdaemonize = %s", BOOL2STR(fpm_global_config.daemonize));
  1178. -   zlog(ZLOG_NOTICE, "\terror_log = %s", STR2STR(fpm_global_config.error_log));
  1179. -   zlog(ZLOG_NOTICE, "\tlog_level = %s", zlog_get_level_name());
  1180. -   zlog(ZLOG_NOTICE, "\tprocess_control_timeout = %ds", fpm_global_config.process_control_timeout);
  1181. -   zlog(ZLOG_NOTICE, "\temergency_restart_interval = %ds", fpm_global_config.emergency_restart_interval);
  1182. -   zlog(ZLOG_NOTICE, "\temergency_restart_threshold = %d", fpm_global_config.emergency_restart_threshold);
  1183. -   zlog(ZLOG_NOTICE, "\trlimit_files = %d", fpm_global_config.rlimit_files);
  1184. -   zlog(ZLOG_NOTICE, "\trlimit_core = %d", fpm_global_config.rlimit_core);
  1185. +   zlog(ZLOG_NOTICE, "[global]");
  1186. +   zlog(ZLOG_NOTICE, "emergency_restart_threshold = %d",           fpm_global_config.emergency_restart_threshold);
  1187. +   zlog(ZLOG_NOTICE, "emergency_restart_interval = %ds",           fpm_global_config.emergency_restart_interval);
  1188. +   zlog(ZLOG_NOTICE, "process_control_timeout = %ds",              fpm_global_config.process_control_timeout);
  1189. +   zlog(ZLOG_NOTICE, "daemonize = %s",                             BOOL2STR(fpm_global_config.daemonize));
  1190. +   zlog(ZLOG_NOTICE, "pid_file = %s",                              STR2STR(fpm_global_config.pid_file));
  1191. +   zlog(ZLOG_NOTICE, "error_log = %s",                             STR2STR(fpm_global_config.error_log));
  1192. +   zlog(ZLOG_NOTICE, "rlimit_files = %d",                          fpm_global_config.rlimit_files);
  1193. +   zlog(ZLOG_NOTICE, "rlimit_core = %d",                           fpm_global_config.rlimit_core);
  1194. +   zlog(ZLOG_NOTICE, "log_level = %s",                             zlog_get_level_name());
  1195.     zlog(ZLOG_NOTICE, " ");
  1196.  
  1197.     for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
  1198.         struct key_value_s *kv;
  1199. -       if (!wp->config) continue;
  1200. -       zlog(ZLOG_NOTICE, "[%s]", STR2STR(wp->config->name));
  1201. -       zlog(ZLOG_NOTICE, "\tprefix = %s", STR2STR(wp->config->prefix));
  1202. -       zlog(ZLOG_NOTICE, "\tuser = %s", STR2STR(wp->config->user));
  1203. -       zlog(ZLOG_NOTICE, "\tgroup = %s", STR2STR(wp->config->group));
  1204. -       zlog(ZLOG_NOTICE, "\tchroot = %s", STR2STR(wp->config->chroot));
  1205. -       zlog(ZLOG_NOTICE, "\tchdir = %s", STR2STR(wp->config->chdir));
  1206. -       zlog(ZLOG_NOTICE, "\tlisten = %s", STR2STR(wp->config->listen_address));
  1207. -       zlog(ZLOG_NOTICE, "\tlisten.backlog = %d", wp->config->listen_backlog);
  1208. -       zlog(ZLOG_NOTICE, "\tlisten.owner = %s", STR2STR(wp->config->listen_owner));
  1209. -       zlog(ZLOG_NOTICE, "\tlisten.group = %s", STR2STR(wp->config->listen_group));
  1210. -       zlog(ZLOG_NOTICE, "\tlisten.mode = %s", STR2STR(wp->config->listen_mode));
  1211. -       zlog(ZLOG_NOTICE, "\tlisten.allowed_clients = %s", STR2STR(wp->config->listen_allowed_clients));
  1212. -       zlog(ZLOG_NOTICE, "\tpm = %s", PM2STR(wp->config->pm));
  1213. -       zlog(ZLOG_NOTICE, "\tpm.max_children = %d", wp->config->pm_max_children);
  1214. -       zlog(ZLOG_NOTICE, "\tpm.max_requests = %d", wp->config->pm_max_requests);
  1215. -       zlog(ZLOG_NOTICE, "\tpm.start_servers = %d", wp->config->pm_start_servers);
  1216. -       zlog(ZLOG_NOTICE, "\tpm.min_spare_servers = %d", wp->config->pm_min_spare_servers);
  1217. -       zlog(ZLOG_NOTICE, "\tpm.max_spare_servers = %d", wp->config->pm_max_spare_servers);
  1218. -       zlog(ZLOG_NOTICE, "\tpm.status_path = %s", STR2STR(wp->config->pm_status_path));
  1219. -       zlog(ZLOG_NOTICE, "\tping.path = %s", STR2STR(wp->config->ping_path));
  1220. -       zlog(ZLOG_NOTICE, "\tping.response = %s", STR2STR(wp->config->ping_response));
  1221. -       zlog(ZLOG_NOTICE, "\taccess.log = %s", STR2STR(wp->config->access_log));
  1222. -       zlog(ZLOG_NOTICE, "\taccess.format = %s", STR2STR(wp->config->access_format));
  1223. -       zlog(ZLOG_NOTICE, "\tcatch_workers_output = %s", BOOL2STR(wp->config->catch_workers_output));
  1224. -       zlog(ZLOG_NOTICE, "\trequest_terminate_timeout = %ds", wp->config->request_terminate_timeout);
  1225. -       zlog(ZLOG_NOTICE, "\trequest_slowlog_timeout = %ds", wp->config->request_slowlog_timeout);
  1226. -       zlog(ZLOG_NOTICE, "\tslowlog = %s", STR2STR(wp->config->slowlog));
  1227. -       zlog(ZLOG_NOTICE, "\trlimit_files = %d", wp->config->rlimit_files);
  1228. -       zlog(ZLOG_NOTICE, "\trlimit_core = %d", wp->config->rlimit_core);
  1229.  
  1230. +       zlog(ZLOG_NOTICE, "[%s]",                               STR2STR(wp->config->name));
  1231. +       zlog(ZLOG_NOTICE, "prefix = %s",                        STR2STR(wp->config->prefix));
  1232. +
  1233. +       zlog(ZLOG_NOTICE, "user = %s",                          STR2STR(wp->config->user));
  1234. +       zlog(ZLOG_NOTICE, "group = %s",                         STR2STR(wp->config->group));
  1235. +
  1236. +       zlog(ZLOG_NOTICE, "listen = %s",                        STR2STR(wp->config->listen_address));
  1237. +       zlog(ZLOG_NOTICE, "listen.backlog = %d",                wp->config->listen_backlog);
  1238. +       zlog(ZLOG_NOTICE, "listen.owner = %s",                  STR2STR(wp->config->listen_owner));
  1239. +       zlog(ZLOG_NOTICE, "listen.group = %s",                  STR2STR(wp->config->listen_group));
  1240. +       zlog(ZLOG_NOTICE, "listen.mode = %s",                   STR2STR(wp->config->listen_mode));
  1241. +       zlog(ZLOG_NOTICE, "listen.allowed_clients = %s",        STR2STR(wp->config->listen_allowed_clients));
  1242. +
  1243. +       zlog(ZLOG_NOTICE, "pm = %s",                            PM2STR(wp->config->pm));
  1244. +       zlog(ZLOG_NOTICE, "pm.max_children = %d",               wp->config->pm_max_children);
  1245. +       zlog(ZLOG_NOTICE, "pm.start_servers = %d",              wp->config->pm_start_servers);
  1246. +       zlog(ZLOG_NOTICE, "pm.min_spare_servers = %d",          wp->config->pm_min_spare_servers);
  1247. +       zlog(ZLOG_NOTICE, "pm.max_spare_servers = %d",          wp->config->pm_max_spare_servers);
  1248. +       zlog(ZLOG_NOTICE, "pm.max_requests = %d",               wp->config->pm_max_requests);
  1249. +
  1250. +       zlog(ZLOG_NOTICE, "access.log = %s",                    STR2STR(wp->config->access_log));
  1251. +       zlog(ZLOG_NOTICE, "access.format = %s",                 STR2STR(wp->config->access_format));
  1252. +       zlog(ZLOG_NOTICE, "slowlog = %s",                       STR2STR(wp->config->slowlog));
  1253. +
  1254. +       zlog(ZLOG_NOTICE, "request_terminate_timeout = %ds",    wp->config->request_terminate_timeout);
  1255. +       zlog(ZLOG_NOTICE, "request_slowlog_timeout = %ds",      wp->config->request_slowlog_timeout);
  1256. +       zlog(ZLOG_NOTICE, "rlimit_files = %d",                  wp->config->rlimit_files);
  1257. +       zlog(ZLOG_NOTICE, "rlimit_core = %d",                   wp->config->rlimit_core);
  1258. +
  1259. +       zlog(ZLOG_NOTICE, "chroot = %s",                        STR2STR(wp->config->chroot));
  1260. +       zlog(ZLOG_NOTICE, "chdir = %s",                         STR2STR(wp->config->chdir));
  1261. +
  1262. +       zlog(ZLOG_NOTICE, "catch_workers_output = %s",          BOOL2STR(wp->config->catch_workers_output));
  1263. +
  1264. +       zlog(ZLOG_NOTICE, "diagnostics.status_path = %s",       STR2STR(wp->config->diag_status_path));
  1265. +       zlog(ZLOG_NOTICE, "diagnostics.ping_path = %s",         STR2STR(wp->config->diag_ping_path));
  1266. +       zlog(ZLOG_NOTICE, "diagnostics.ping_response = %s",     STR2STR(wp->config->diag_ping_response));
  1267. +
  1268.         for (kv = wp->config->env; kv; kv = kv->next) {
  1269. -           zlog(ZLOG_NOTICE, "\tenv[%s] = %s", kv->key, kv->value);
  1270. +           zlog(ZLOG_NOTICE, "env[%s] = %s", kv->key, kv->value);
  1271.         }
  1272.  
  1273.         for (kv = wp->config->php_values; kv; kv = kv->next) {
  1274. -           zlog(ZLOG_NOTICE, "\tphp_value[%s] = %s", kv->key, kv->value);
  1275. +           zlog(ZLOG_NOTICE, "php_value[%s] = %s", kv->key, kv->value);
  1276.         }
  1277.  
  1278.         for (kv = wp->config->php_admin_values; kv; kv = kv->next) {
  1279. -           zlog(ZLOG_NOTICE, "\tphp_admin_value[%s] = %s", kv->key, kv->value);
  1280. +           zlog(ZLOG_NOTICE, "php_admin_value[%s] = %s", kv->key, kv->value);
  1281.         }
  1282.         zlog(ZLOG_NOTICE, " ");
  1283.     }
  1284. @@ -1196,7 +1290,6 @@
  1285.  
  1286.  int fpm_conf_init_main(int test_conf) /* {{{ */
  1287.  {
  1288. -   int ret;
  1289.     TSRMLS_FETCH();
  1290.  
  1291.     if (fpm_globals.prefix && *fpm_globals.prefix) {
  1292. @@ -1233,14 +1326,11 @@
  1293.         }
  1294.     }
  1295.  
  1296. -   ret = fpm_conf_load_ini_file(fpm_globals.config TSRMLS_CC);
  1297. -
  1298. -   if (0 > ret) {
  1299. -       zlog(ZLOG_ERROR, "failed to load configuration file '%s'", fpm_globals.config);
  1300. +   if (fpm_conf_load_ini_file(fpm_globals.config TSRMLS_CC) != 0) {
  1301.         return -1;
  1302.     }
  1303.  
  1304. -   if (0 > fpm_conf_post_process(TSRMLS_C)) {
  1305. +   if (fpm_conf_post_process(test_conf TSRMLS_CC) != 0) {
  1306.         zlog(ZLOG_ERROR, "failed to post process the configuration");
  1307.         return -1;
  1308.     }
  1309. @@ -1254,7 +1344,7 @@
  1310.         return -1;
  1311.     }
  1312.  
  1313. -   if (0 > fpm_cleanup_add(FPM_CLEANUP_ALL, fpm_conf_cleanup, 0)) {
  1314. +   if (fpm_cleanup_add(FPM_CLEANUP_ALL, fpm_conf_cleanup, 0) != 0) {
  1315.         return -1;
  1316.     }
  1317.  
  1318. Index: sapi/fpm/fpm/fpm_env.c
  1319. ===================================================================
  1320. --- sapi/fpm/fpm/fpm_env.c  (revision 312829)
  1321. +++ sapi/fpm/fpm/fpm_env.c  (working copy)
  1322. @@ -269,7 +269,7 @@
  1323.  #endif
  1324.  
  1325.     spprintf(&title, 0, "master process (%s)", fpm_globals.config);
  1326. -   fpm_env_setproctitle(title);
  1327. +   fpm_env_setproctitle(title);
  1328.     efree(title);
  1329.     return 0;
  1330.  }
  1331. Index: sapi/fpm/fpm/fpm_conf.h
  1332. ===================================================================
  1333. --- sapi/fpm/fpm/fpm_conf.h (revision 312829)
  1334. +++ sapi/fpm/fpm/fpm_conf.h (working copy)
  1335. @@ -9,10 +9,9 @@
  1336.  #include "php.h"
  1337.  
  1338.  #define FPM_CONF_MAX_PONG_LENGTH 64
  1339. +#define MAX_CONF_RECURSION_LEVEL 5
  1340. +#define FPM_CONF_MAX_RECURSION_LEVEL 5
  1341.  
  1342. -#define STR2STR(a) (a ? a : "undefined")
  1343. -#define BOOL2STR(a) (a ? "yes" : "no")
  1344. -#define PM2STR(a) (a == PM_STYLE_STATIC ? "static" : "dynamic")
  1345.  
  1346.  struct key_value_s;
  1347.  
  1348. @@ -38,33 +37,42 @@
  1349.  struct fpm_worker_pool_config_s {
  1350.     char *name;
  1351.     char *prefix;
  1352. +
  1353.     char *user;
  1354.     char *group;
  1355. -   char *chroot;
  1356. -   char *chdir;
  1357. +
  1358. +   char *listen_address;
  1359. +   int listen_backlog;
  1360. +   char *listen_allowed_clients;
  1361. +   char *listen_owner;
  1362. +   char *listen_group;
  1363. +   char *listen_mode;
  1364. +
  1365. +   int pm;
  1366. +   int pm_max_children;
  1367. +   int pm_start_servers;
  1368. +   int pm_min_spare_servers;
  1369. +   int pm_max_spare_servers;
  1370. +   int pm_max_requests;
  1371. +
  1372.     int request_terminate_timeout;
  1373.     int request_slowlog_timeout;
  1374. -   char *slowlog;
  1375.     int rlimit_files;
  1376.     int rlimit_core;
  1377. +
  1378. +   char *chroot;
  1379. +   char *chdir;        // FIXME: do we really need this?
  1380. +
  1381.     int catch_workers_output;
  1382. -   int pm;
  1383. -   int pm_max_children;
  1384. -   char *pm_status_path;
  1385. -   int pm_max_requests;
  1386. -   int pm_start_servers;
  1387. -   int pm_min_spare_servers;
  1388. -   int pm_max_spare_servers;
  1389. -   char *ping_path;
  1390. -   char *ping_response;
  1391. +
  1392. +   char *diag_status_path;
  1393. +   char *diag_ping_path;
  1394. +   char *diag_ping_response;
  1395. +
  1396.     char *access_log;
  1397.     char *access_format;
  1398. -   char *listen_address;
  1399. -   int listen_backlog;
  1400. -   char *listen_owner;
  1401. -   char *listen_group;
  1402. -   char *listen_mode;
  1403. -   char *listen_allowed_clients;
  1404. +   char *slowlog;
  1405. +
  1406.     struct key_value_s *env;
  1407.     struct key_value_s *php_admin_values;
  1408.     struct key_value_s *php_values;
  1409. @@ -76,7 +84,10 @@
  1410.     intptr_t offset;
  1411.  };
  1412.  
  1413. -enum { PM_STYLE_STATIC = 1, PM_STYLE_DYNAMIC = 2 };
  1414. +enum {
  1415. +   PM_STYLE_STATIC = 1,
  1416. +   PM_STYLE_DYNAMIC = 2
  1417. +};
  1418.  
  1419.  int fpm_conf_init_main(int test_conf);
  1420.  int fpm_worker_pool_config_free(struct fpm_worker_pool_config_s *wpc);
  1421. @@ -84,4 +95,3 @@
  1422.  int fpm_conf_unlink_pid();
  1423.  
  1424.  #endif
  1425. -
  1426. Index: sapi/fpm/fpm/fpm_signals.c
  1427. ===================================================================
  1428. --- sapi/fpm/fpm/fpm_signals.c  (revision 312829)
  1429. +++ sapi/fpm/fpm/fpm_signals.c  (working copy)
  1430. @@ -201,12 +201,11 @@
  1431.     sigfillset(&act.sa_mask);
  1432.  
  1433.     if (0 > sigaction(SIGTERM,  &act, 0) ||
  1434. -       0 > sigaction(SIGINT,   &act, 0) ||
  1435. -       0 > sigaction(SIGUSR1,  &act, 0) ||
  1436. -       0 > sigaction(SIGUSR2,  &act, 0) ||
  1437. -       0 > sigaction(SIGCHLD,  &act, 0) ||
  1438. -       0 > sigaction(SIGQUIT,  &act, 0)) {
  1439. -
  1440. +       0 > sigaction(SIGINT,   &act, 0) ||
  1441. +       0 > sigaction(SIGUSR1,  &act, 0) ||
  1442. +       0 > sigaction(SIGUSR2,  &act, 0) ||
  1443. +       0 > sigaction(SIGCHLD,  &act, 0) ||
  1444. +       0 > sigaction(SIGQUIT,  &act, 0)) {
  1445.         zlog(ZLOG_SYSERROR, "sigaction() failed");
  1446.         return -1;
  1447.     }
  1448. @@ -230,12 +229,11 @@
  1449.     close(sp[1]);
  1450.  
  1451.     if (0 > sigaction(SIGTERM,  &act_dfl,  0) ||
  1452. -       0 > sigaction(SIGINT,   &act_dfl,  0) ||
  1453. -       0 > sigaction(SIGUSR1,  &act_dfl,  0) ||
  1454. -       0 > sigaction(SIGUSR2,  &act_dfl,  0) ||
  1455. -       0 > sigaction(SIGCHLD,  &act_dfl,  0) ||
  1456. -       0 > sigaction(SIGQUIT,  &act,      0)) {
  1457. -
  1458. +       0 > sigaction(SIGINT,   &act_dfl,  0) ||
  1459. +       0 > sigaction(SIGUSR1,  &act_dfl,  0) ||
  1460. +       0 > sigaction(SIGUSR2,  &act_dfl,  0) ||
  1461. +       0 > sigaction(SIGCHLD,  &act_dfl,  0) ||
  1462. +       0 > sigaction(SIGQUIT,  &act,      0)) {
  1463.         zlog(ZLOG_SYSERROR, "sigaction() failed");
  1464.         return -1;
  1465.     }
  1466. @@ -248,4 +246,3 @@
  1467.     return sp[0];
  1468.  }
  1469.  /* }}} */
  1470. -
  1471. Index: sapi/fpm/fpm/fpm_log.c
  1472. ===================================================================
  1473. --- sapi/fpm/fpm/fpm_log.c  (revision 312829)
  1474. +++ sapi/fpm/fpm/fpm_log.c  (working copy)
  1475. @@ -33,9 +33,8 @@
  1476.  int fpm_log_open(int reopen) /* {{{ */
  1477.  {
  1478.     struct fpm_worker_pool_s *wp;
  1479. -   int ret = 1;
  1480. -  
  1481. -   int fd;
  1482. +   int fd, ret = 1;
  1483. +
  1484.     for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
  1485.         if (!wp->config->access_log) {
  1486.             continue;
  1487. Index: sapi/fpm/fpm/fpm_scoreboard.c
  1488. ===================================================================
  1489. --- sapi/fpm/fpm/fpm_scoreboard.c   (revision 312829)
  1490. +++ sapi/fpm/fpm/fpm_scoreboard.c   (working copy)
  1491. @@ -57,7 +57,7 @@
  1492.             return -1;
  1493.         }
  1494.         wp->scoreboard->nprocs = wp->config->pm_max_children;
  1495. -       for (i=0; i<wp->scoreboard->nprocs; i++) {
  1496. +       for (i = 0; i < wp->scoreboard->nprocs; i++) {
  1497.             wp->scoreboard->procs[i] = fpm_shm_alloc(sizeof(struct fpm_scoreboard_proc_s));
  1498.             if (!wp->scoreboard->procs[i]) {
  1499.                 return -1;
  1500. @@ -69,7 +69,7 @@
  1501.         wp->scoreboard->start_epoch = time(NULL);
  1502.         strlcpy(wp->scoreboard->pool, wp->config->name, sizeof(wp->scoreboard->pool));
  1503.     }
  1504. -   return 0;  
  1505. +   return 0;
  1506.  }
  1507.  /* }}} */
  1508.  
  1509. @@ -83,7 +83,6 @@
  1510.         return;
  1511.     }
  1512.  
  1513. -
  1514.     fpm_spinlock(&scoreboard->lock, 0);
  1515.     if (action == FPM_SCOREBOARD_ACTION_SET) {
  1516.         if (idle >= 0) {
  1517. Index: sapi/fpm/fpm/fpm_main.c
  1518. ===================================================================
  1519. --- sapi/fpm/fpm/fpm_main.c (revision 312829)
  1520. +++ sapi/fpm/fpm/fpm_main.c (working copy)
  1521. @@ -674,12 +674,13 @@
  1522.     if (CGIG(fix_pathinfo)) {
  1523.         char *script_name = SG(request_info).request_uri;
  1524.         unsigned int script_name_len = script_name ? strlen(script_name) : 0;
  1525. -       char *path_info = sapi_cgibin_getenv("PATH_INFO", sizeof("PATH_INFO")-1 TSRMLS_CC);
  1526. +       char *path_info = sapi_cgibin_getenv("PATH_INFO", sizeof("PATH_INFO") - 1 TSRMLS_CC);
  1527.         unsigned int path_info_len = path_info ? strlen(path_info) : 0;
  1528.  
  1529.         php_self_len = script_name_len + path_info_len;
  1530.         php_self = emalloc(php_self_len + 1);
  1531.  
  1532. +       /* Concat script_name and path_info into php_self */
  1533.         if (script_name) {
  1534.             memcpy(php_self, script_name, script_name_len + 1);
  1535.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement