--- php-5.2.6/sapi/cgi/fpm/fpm_php.c 2008-11-03 21:14:16.462343387 +0200 +++ php-5.2.6-zts/sapi/cgi/fpm/fpm_php.c 2008-11-03 20:48:33.138185064 +0200 @@ -19,7 +19,7 @@ #include "fpm_cleanup.h" #include "fpm_worker_pool.h" -static int zend_ini_alter_master(char *name, int name_length, char *new_value, int new_value_length, int stage) +static int zend_ini_alter_master(char *name, int name_length, char *new_value, int new_value_length, int stage TSRMLS_DC) { zend_ini_entry *ini_entry; char *duplicate; @@ -32,7 +32,7 @@ if (!ini_entry->on_modify || ini_entry->on_modify(ini_entry, duplicate, new_value_length, - ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage) == SUCCESS) { + ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC) == SUCCESS) { ini_entry->value = duplicate; ini_entry->value_length = new_value_length; } else { @@ -42,7 +42,7 @@ return SUCCESS; } -static void fpm_php_disable(char *value, int (*zend_disable)(char *, uint)) +static void fpm_php_disable(char *value, int (*zend_disable)(char *, uint TSRMLS_DC) TSRMLS_DC) { char *s = 0, *e = value; @@ -52,7 +52,7 @@ case ',': if (s) { *e = '\0'; - zend_disable(s, e - s); + zend_disable(s, e - s TSRMLS_CC); s = 0; } break; @@ -66,11 +66,11 @@ } if (s) { - zend_disable(s, e - s); + zend_disable(s, e - s TSRMLS_CC); } } -static int fpm_php_apply_defines(struct fpm_worker_pool_s *wp) +static int fpm_php_apply_defines(struct fpm_worker_pool_s *wp TSRMLS_DC) { struct key_value_s *kv; @@ -89,29 +89,29 @@ zval filename; ZVAL_STRINGL(&filename, value, value_len, 0); #if (PHP_MAJOR_VERSION >= 5) - php_dl(&filename, MODULE_PERSISTENT, &zv, 1); + php_dl(&filename, MODULE_PERSISTENT, &zv, 1 TSRMLS_CC); #else - php_dl(&filename, MODULE_PERSISTENT, &zv); + php_dl(&filename, MODULE_PERSISTENT, &zv TSRMLS_CC); #endif #endif continue; } - zend_ini_alter_master(name, name_len + 1, value, value_len, PHP_INI_STAGE_ACTIVATE); + zend_ini_alter_master(name, name_len + 1, value, value_len, PHP_INI_STAGE_ACTIVATE TSRMLS_CC); if (!strcmp(name, "disable_functions") && *value) { char *v = strdup(value); #if (PHP_MAJOR_VERSION >= 5) PG(disable_functions) = v; #endif - fpm_php_disable(v, zend_disable_function); + fpm_php_disable(v, zend_disable_function TSRMLS_CC); } else if (!strcmp(name, "disable_classes") && *value) { char *v = strdup(value); #if (PHP_MAJOR_VERSION >= 5) PG(disable_classes) = v; #endif - fpm_php_disable(v, zend_disable_class); + fpm_php_disable(v, zend_disable_class TSRMLS_CC); } } @@ -127,24 +127,24 @@ return 0; } -char *fpm_php_script_filename() +char *fpm_php_script_filename(TSRMLS_D) { return SG(request_info).path_translated; } -char *fpm_php_request_method() +char *fpm_php_request_method(TSRMLS_D) { return (char *) SG(request_info).request_method; } -size_t fpm_php_content_length() +size_t fpm_php_content_length(TSRMLS_D) { return SG(request_info).content_length; } -static void fpm_php_cleanup(int which, void *arg) +static void fpm_php_cleanup(int which, void *arg TSRMLS_DC) { - php_module_shutdown(); + php_module_shutdown(TSRMLS_C); sapi_shutdown(); } @@ -155,14 +155,15 @@ int fpm_php_init_main() { + // XXX unable to pass TSRMLS_CC to the cleanup func! fpm_cleanup_add(FPM_CLEANUP_PARENT, fpm_php_cleanup, 0); return 0; } -int fpm_php_init_child(struct fpm_worker_pool_s *wp) +int fpm_php_init_child(struct fpm_worker_pool_s *wp TSRMLS_DC) { - if (0 > fpm_php_apply_defines(wp) || + if (0 > fpm_php_apply_defines(wp TSRMLS_CC) || 0 > fpm_php_set_allowed_clients(wp)) { return -1; } --- php-5.2.6-zts/sapi/cgi/fpm/fpm_php.h 2008-11-03 20:46:17.348139255 +0200 +++ php-5.2.6/sapi/cgi/fpm/fpm_php.h 2008-11-03 21:40:41.811143906 +0200 @@ -6,10 +6,11 @@ #define FPM_PHP_H 1 #include "fpm_worker_pool.h" +#include "TSRM.h" #include "build-defs.h" /* for PHP_ defines */ -int fpm_php_init_child(struct fpm_worker_pool_s *wp); +int fpm_php_init_child(struct fpm_worker_pool_s *wp TSRMLS_DC); char *fpm_php_script_filename(); char *fpm_php_request_method(); size_t fpm_php_content_length(); --- php-5.2.6/sapi/cgi/fpm/fpm_php_trace.c 2008-11-03 21:14:16.462343387 +0200 +++ php-5.2.6-zts/sapi/cgi/fpm/fpm_php_trace.c 2008-11-03 20:47:26.611462721 +0200 @@ -35,7 +35,7 @@ #endif -static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog) +static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog TSRMLS_DC) { int callers_limit = 20; pid_t pid = child->pid; @@ -131,7 +131,7 @@ return 0; } -void fpm_php_trace(struct fpm_child_s *child) +void fpm_php_trace(struct fpm_child_s *child TSRMLS_DC) { FILE *slowlog; @@ -148,7 +148,7 @@ goto done1; } - if (0 > fpm_php_trace_dump(child, slowlog)) { + if (0 > fpm_php_trace_dump(child, slowlog TSRMLS_CC)) { fprintf(slowlog, "+++ dump failed\n"); } --- php-5.2.6/sapi/cgi/fpm/fpm_php_trace.h 2008-11-03 21:14:16.462343387 +0200 +++ php-5.2.6-zts/sapi/cgi/fpm/fpm_php_trace.h 2008-11-03 20:47:38.411626098 +0200 @@ -7,7 +7,7 @@ struct fpm_child_s; -void fpm_php_trace(struct fpm_child_s *); +void fpm_php_trace(struct fpm_child_s *child TSRMLS_DC); #endif --- php-5.2.6/sapi/cgi/fpm/fpm_children.c 2008-11-03 21:47:04.141104879 +0200 +++ php-5.2.6-zts/sapi/cgi/fpm/fpm_children.c 2008-11-03 21:45:17.088199172 +0200 @@ -32,7 +32,7 @@ static time_t *last_faults; static int fault; -static int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop); +static int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop TSRMLS_DC); static void fpm_children_cleanup(int which, void *arg) { @@ -127,7 +127,7 @@ return child; } -static void fpm_child_init(struct fpm_worker_pool_s *wp) +static void fpm_child_init(struct fpm_worker_pool_s *wp TSRMLS_DC) { fpm_globals.max_requests = wp->config->max_requests; @@ -135,7 +135,7 @@ 0 > fpm_unix_init_child(wp) || 0 > fpm_signals_init_child() || 0 > fpm_env_init_child(wp) || - 0 > fpm_php_init_child(wp)) { + 0 > fpm_php_init_child(wp TSRMLS_CC)) { zlog(ZLOG_STUFF, ZLOG_ERROR, "child failed to initialize (pool %s)", wp->config->name); exit(255); @@ -154,7 +154,7 @@ return 0; } -void fpm_children_bury() +void fpm_children_bury(TSRMLS_D) { int status; pid_t pid; @@ -246,7 +246,7 @@ } } - fpm_children_make(wp, 1 /* in event loop */); + fpm_children_make(wp, 1 /* in event loop */ TSRMLS_CC); if (fpm_globals.is_child) { break; @@ -308,7 +308,7 @@ fpm_child_link(child); } -static int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop) +static int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop TSRMLS_DC) { int enough = 0; pid_t pid; @@ -333,7 +333,7 @@ if (in_event_loop) { fpm_event_exit_loop(); } - fpm_child_init(wp); + fpm_child_init(wp TSRMLS_CC); return 0; case -1 : @@ -357,9 +357,9 @@ return 1; /* we are done */ } -int fpm_children_create_initial(struct fpm_worker_pool_s *wp) +int fpm_children_create_initial(struct fpm_worker_pool_s *wp TSRMLS_DC) { - return fpm_children_make(wp, 0 /* not in event loop yet */); + return fpm_children_make(wp, 0 /* not in event loop yet */ TSRMLS_CC); } int fpm_children_init_main() --- php-5.2.6/sapi/cgi/fpm/fpm_children.h 2008-11-03 21:47:04.141104879 +0200 +++ php-5.2.6-zts/sapi/cgi/fpm/fpm_children.h 2008-11-03 21:45:49.607859881 +0200 @@ -9,9 +9,10 @@ #include #include +#include "TSRM.h" #include "fpm_worker_pool.h" -int fpm_children_create_initial(struct fpm_worker_pool_s *wp); +int fpm_children_create_initial(struct fpm_worker_pool_s *wp TSRMLS_DC); int fpm_children_free(struct fpm_child_s *child); void fpm_children_bury(); int fpm_children_init_main(); --- php-5.2.6/sapi/cgi/fpm/fpm_clock.c 2008-11-03 21:47:04.141104879 +0200 +++ php-5.2.6-zts/sapi/cgi/fpm/fpm_clock.c 2008-11-03 21:46:02.415277547 +0200 @@ -13,7 +13,7 @@ /* posix monotonic clock - preferred source of time */ -#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) +#if 0 && defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) static int monotonic_works; --- php-5.2.6/sapi/cgi/fpm/fpm.c 2008-11-03 22:08:17.285352817 +0200 +++ php-5.2.6-zts/sapi/cgi/fpm/fpm.c 2008-11-03 22:07:14.678692152 +0200 @@ -56,7 +56,7 @@ /* children: return listening socket parent: never return */ -int fpm_run(int *max_requests) +int fpm_run(int *max_requests TSRMLS_DC) { struct fpm_worker_pool_s *wp; @@ -64,7 +64,7 @@ for (wp = fpm_worker_all_pools; wp; wp = wp->next) { int is_parent; - is_parent = fpm_children_create_initial(wp); + is_parent = fpm_children_create_initial(wp TSRMLS_CC); if (!is_parent) { goto run_child; --- php-5.2.6/sapi/cgi/fpm/fpm.h 2008-11-03 22:08:17.288686240 +0200 +++ php-5.2.6-zts/sapi/cgi/fpm/fpm.h 2008-11-03 22:06:06.847658292 +0200 @@ -6,8 +6,9 @@ #define FPM_H 1 #include +#include "TSRM.h" -int fpm_run(int *max_requests); +int fpm_run(int *max_requests TSRMLS_DC); int fpm_init(int argc, char **argv, char *config); struct fpm_globals_s { --- php-5.2.6/sapi/cgi/cgi_main.c~ 2008-11-03 22:09:38.000000000 +0200 +++ php-5.2.6/sapi/cgi/cgi_main.c 2008-11-03 22:13:01.700949038 +0200 @@ -1604,7 +1604,7 @@ return FAILURE; } - fcgi_fd = fpm_run(&max_requests); + fcgi_fd = fpm_run(&max_requests TSRMLS_CC); fcgi_set_is_fastcgi(fastcgi = 1); }