1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 01:02:25 +01:00

Moved initialization into a separate function

This commit is contained in:
Andrey Hristov
2008-01-29 12:00:52 +00:00
parent 76640a615f
commit 2687e55829
3 changed files with 32 additions and 9 deletions

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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 */