Skip to content

Commit

Permalink
fix #9
Browse files Browse the repository at this point in the history
fix zts segment error
  • Loading branch information
longxinH committed Jun 11, 2018
1 parent 3043bee commit 2182822
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
3 changes: 1 addition & 2 deletions extension/php_xhprof.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern zend_module_entry xhprof_module_entry;
*/

/* XHProf version */
#define XHPROF_VERSION "2.0.0"
#define XHPROF_VERSION "2.0.1"

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

PHP_FUNCTION(xhprof_enable);
PHP_FUNCTION(xhprof_disable);
Expand Down
31 changes: 17 additions & 14 deletions extension/xhprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ PHP_FUNCTION(xhprof_sample_disable)
/* else null is returned */
}

PHP_GINIT_FUNCTION(xhprof)
static void php_xhprof_init_globals(zend_xhprof_globals *xhprof_globals)
{
xhprof_globals->enabled = 0;
xhprof_globals->ever_enabled = 0;
Expand All @@ -211,6 +211,21 @@ PHP_GINIT_FUNCTION(xhprof)
xhprof_globals->ignored_functions = NULL;
xhprof_globals->sampling_interval = XHPROF_DEFAULT_SAMPLING_INTERVAL;
xhprof_globals->sampling_depth = INT_MAX;

ZVAL_UNDEF(&xhprof_globals->stats_count);

/* no free hp_entry_t structures to start with */
xhprof_globals->entry_free_list = NULL;

int i;

for (i = 0; i < 256; i++) {
xhprof_globals->func_hash_counters[i] = 0;
}

if (xhprof_globals->sampling_interval < XHPROF_MINIMAL_SAMPLING_INTERVAL) {
xhprof_globals->sampling_interval = XHPROF_MINIMAL_SAMPLING_INTERVAL;
}
}

/**
Expand All @@ -220,24 +235,12 @@ PHP_GINIT_FUNCTION(xhprof)
*/
PHP_MINIT_FUNCTION(xhprof)
{
int i;
ZEND_INIT_MODULE_GLOBALS(xhprof, php_xhprof_init_globals, NULL);

REGISTER_INI_ENTRIES();

hp_register_constants(INIT_FUNC_ARGS_PASSTHRU);

ZVAL_UNDEF(&XHPROF_G(stats_count));

/* no free hp_entry_t structures to start with */
XHPROF_G(entry_free_list) = NULL;

for (i = 0; i < 256; i++) {
XHPROF_G(func_hash_counters[i]) = 0;
}
if (XHPROF_G(sampling_interval) < XHPROF_MINIMAL_SAMPLING_INTERVAL) {
XHPROF_G(sampling_interval) = XHPROF_MINIMAL_SAMPLING_INTERVAL;
}

/* Replace zend_compile with our proxy */
_zend_compile_file = zend_compile_file;
zend_compile_file = hp_compile_file;
Expand Down

0 comments on commit 2182822

Please sign in to comment.