Skip to content

Commit 2182822

Browse files
committed
fix #9
fix zts segment error
1 parent 3043bee commit 2182822

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

extension/php_xhprof.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern zend_module_entry xhprof_module_entry;
3939
*/
4040

4141
/* XHProf version */
42-
#define XHPROF_VERSION "2.0.0"
42+
#define XHPROF_VERSION "2.0.1"
4343

4444
/* Fictitious function name to represent top of the call tree. The paranthesis
4545
* in the name is to ensure we don't conflict with user function names. */
@@ -293,7 +293,6 @@ PHP_MSHUTDOWN_FUNCTION(xhprof);
293293
PHP_RINIT_FUNCTION(xhprof);
294294
PHP_RSHUTDOWN_FUNCTION(xhprof);
295295
PHP_MINFO_FUNCTION(xhprof);
296-
PHP_GINIT_FUNCTION(xhprof);
297296

298297
PHP_FUNCTION(xhprof_enable);
299298
PHP_FUNCTION(xhprof_disable);

extension/xhprof.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ PHP_FUNCTION(xhprof_sample_disable)
200200
/* else null is returned */
201201
}
202202

203-
PHP_GINIT_FUNCTION(xhprof)
203+
static void php_xhprof_init_globals(zend_xhprof_globals *xhprof_globals)
204204
{
205205
xhprof_globals->enabled = 0;
206206
xhprof_globals->ever_enabled = 0;
@@ -211,6 +211,21 @@ PHP_GINIT_FUNCTION(xhprof)
211211
xhprof_globals->ignored_functions = NULL;
212212
xhprof_globals->sampling_interval = XHPROF_DEFAULT_SAMPLING_INTERVAL;
213213
xhprof_globals->sampling_depth = INT_MAX;
214+
215+
ZVAL_UNDEF(&xhprof_globals->stats_count);
216+
217+
/* no free hp_entry_t structures to start with */
218+
xhprof_globals->entry_free_list = NULL;
219+
220+
int i;
221+
222+
for (i = 0; i < 256; i++) {
223+
xhprof_globals->func_hash_counters[i] = 0;
224+
}
225+
226+
if (xhprof_globals->sampling_interval < XHPROF_MINIMAL_SAMPLING_INTERVAL) {
227+
xhprof_globals->sampling_interval = XHPROF_MINIMAL_SAMPLING_INTERVAL;
228+
}
214229
}
215230

216231
/**
@@ -220,24 +235,12 @@ PHP_GINIT_FUNCTION(xhprof)
220235
*/
221236
PHP_MINIT_FUNCTION(xhprof)
222237
{
223-
int i;
238+
ZEND_INIT_MODULE_GLOBALS(xhprof, php_xhprof_init_globals, NULL);
224239

225240
REGISTER_INI_ENTRIES();
226241

227242
hp_register_constants(INIT_FUNC_ARGS_PASSTHRU);
228243

229-
ZVAL_UNDEF(&XHPROF_G(stats_count));
230-
231-
/* no free hp_entry_t structures to start with */
232-
XHPROF_G(entry_free_list) = NULL;
233-
234-
for (i = 0; i < 256; i++) {
235-
XHPROF_G(func_hash_counters[i]) = 0;
236-
}
237-
if (XHPROF_G(sampling_interval) < XHPROF_MINIMAL_SAMPLING_INTERVAL) {
238-
XHPROF_G(sampling_interval) = XHPROF_MINIMAL_SAMPLING_INTERVAL;
239-
}
240-
241244
/* Replace zend_compile with our proxy */
242245
_zend_compile_file = zend_compile_file;
243246
zend_compile_file = hp_compile_file;

0 commit comments

Comments
 (0)