mirror of
https://github.com/php/php-src.git
synced 2025-01-23 12:13:37 +08:00
Moved initialization code into a function.
This commit is contained in:
parent
9770b3cb00
commit
00877eff13
@ -133,10 +133,7 @@ void mysqlnd_library_init(TSRMLS_D)
|
||||
mysqlnd_library_initted = TRUE;
|
||||
_mysqlnd_init_ps_subsystem();
|
||||
/* Should be calloc, as mnd_calloc will reference LOCK_access*/
|
||||
mysqlnd_global_stats = calloc(1, sizeof(MYSQLND_STATS));
|
||||
#ifdef ZTS
|
||||
mysqlnd_global_stats->LOCK_access = tsrm_mutex_alloc();
|
||||
#endif
|
||||
mysqlnd_stats_init(&mysqlnd_global_stats);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -146,11 +143,7 @@ void mysqlnd_library_init(TSRMLS_D)
|
||||
void mysqlnd_library_end(TSRMLS_D)
|
||||
{
|
||||
if (mysqlnd_library_initted == TRUE) {
|
||||
#ifdef ZTS
|
||||
tsrm_mutex_free(mysqlnd_global_stats->LOCK_access);
|
||||
#endif
|
||||
/* mnd_free will reference LOCK_access and crash...*/
|
||||
free(mysqlnd_global_stats);
|
||||
mysqlnd_stats_end(mysqlnd_global_stats);
|
||||
mysqlnd_global_stats = NULL;
|
||||
mysqlnd_library_initted = FALSE;
|
||||
}
|
||||
|
@ -145,6 +145,32 @@ PHPAPI void _mysqlnd_get_client_stats(zval *return_value TSRMLS_DC ZEND_FILE_LIN
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_stats_init */
|
||||
void
|
||||
mysqlnd_stats_init(MYSQLND_STATS ** stats)
|
||||
{
|
||||
*stats = calloc(1, sizeof(MYSQLND_STATS));
|
||||
#ifdef ZTS
|
||||
(*stats)->LOCK_access = tsrm_mutex_alloc();
|
||||
#endif
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ mysqlnd_stats_end */
|
||||
void
|
||||
mysqlnd_stats_end(MYSQLND_STATS * stats)
|
||||
{
|
||||
#ifdef ZTS
|
||||
tsrm_mutex_free(stats->LOCK_access);
|
||||
#endif
|
||||
/* mnd_free will reference LOCK_access and crash...*/
|
||||
free(stats);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
|
@ -196,6 +196,10 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
|
||||
void mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, zval *return_value
|
||||
TSRMLS_DC ZEND_FILE_LINE_DC);
|
||||
|
||||
|
||||
void mysqlnd_stats_init(MYSQLND_STATS ** stats);
|
||||
void mysqlnd_stats_end(MYSQLND_STATS * stats);
|
||||
|
||||
#endif /* MYSQLND_STATISTICS_H */
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user