andrey                                   Mon, 11 Jan 2010 12:37:42 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=293402

Log:
missed to commit to the branch

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_statistics.c
    U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_statistics.h
    U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_statistics.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_statistics.c       
2010-01-11 12:34:10 UTC (rev 293401)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_statistics.c       
2010-01-11 12:37:42 UTC (rev 293402)
@@ -240,7 +240,8 @@
 mysqlnd_stats_init(MYSQLND_STATS ** stats)
 {
        *stats = calloc(1, sizeof(MYSQLND_STATS));
-       (*stats)->handlers = calloc(STAT_LAST, sizeof(mysqlnd_stat_handler));
+       (*stats)->triggers = calloc(STAT_LAST, sizeof(mysqlnd_stat_trigger));
+       (*stats)->in_trigger = FALSE;
 #ifdef ZTS
        (*stats)->LOCK_access = tsrm_mutex_alloc();
 #endif
@@ -256,13 +257,46 @@
 #ifdef ZTS
        tsrm_mutex_free(stats->LOCK_access);
 #endif
-       free(stats->handlers);
+       free(stats->triggers);
        /* mnd_free will reference LOCK_access and crash...*/
        free(stats);
 }
 /* }}} */


+/* {{{ mysqlnd_stats_set_trigger */
+PHPAPI mysqlnd_stat_trigger
+mysqlnd_stats_set_trigger(MYSQLND_STATS * const stats, 
enum_mysqlnd_collected_stats stat, mysqlnd_stat_trigger trigger TSRMLS_DC)
+{
+       mysqlnd_stat_trigger ret = NULL;
+       DBG_ENTER("mysqlnd_stats_set_trigger");
+       if (stats) {
+               MYSQLND_STATS_LOCK(stats);
+               ret = stats->triggers[stat];
+               stats->triggers[stat] = trigger;
+               MYSQLND_STATS_UNLOCK(stats);
+       }
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_stats_set_handler */
+PHPAPI mysqlnd_stat_trigger
+mysqlnd_stats_reset_triggers(MYSQLND_STATS * const stats TSRMLS_DC)
+{
+       mysqlnd_stat_trigger ret = NULL;
+       DBG_ENTER("mysqlnd_stats_reset_trigger");
+       if (stats) {
+               MYSQLND_STATS_LOCK(stats);
+               memset(stats->triggers, 0, STAT_LAST * 
sizeof(mysqlnd_stat_trigger));
+               MYSQLND_STATS_UNLOCK(stats);
+       }
+       DBG_RETURN(ret);
+}
+/* }}} */
+
+
 /*
  * Local variables:
  * tab-width: 4

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_statistics.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_statistics.h       
2010-01-11 12:34:10 UTC (rev 293401)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_statistics.h       
2010-01-11 12:37:42 UTC (rev 293402)
@@ -43,10 +43,10 @@
 #endif

 #define MYSQLND_CHECK_AND_CALL_HANDLER(stats, statistic, value) \
-                       if ((stats)->handlers[(statistic)] && 
(stats)->in_handler == FALSE) { \
-                               (stats)->in_handler = TRUE; \
-                               (stats)->handlers[(statistic)]((stats), 
(statistic), (value) TSRMLS_CC); \
-                               (stats)->in_handler = FALSE; \
+                       if ((stats)->triggers[(statistic)] && 
(stats)->in_trigger == FALSE) { \
+                               (stats)->in_trigger = TRUE; \
+                               (stats)->triggers[(statistic)]((stats), 
(statistic), (value) TSRMLS_CC); \
+                               (stats)->in_trigger = FALSE; \
                        } \


@@ -223,6 +223,10 @@
 PHPAPI void mysqlnd_stats_init(MYSQLND_STATS ** stats);
 PHPAPI void mysqlnd_stats_end(MYSQLND_STATS * stats);

+PHPAPI mysqlnd_stat_trigger mysqlnd_stats_set_trigger(MYSQLND_STATS * const 
stats, enum_mysqlnd_collected_stats stat, mysqlnd_stat_trigger trigger 
TSRMLS_DC);
+PHPAPI mysqlnd_stat_trigger mysqlnd_stats_reset_triggers(MYSQLND_STATS * const 
stats TSRMLS_DC);
+
+
 #endif /* MYSQLND_STATISTICS_H */



Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h  2010-01-11 
12:34:10 UTC (rev 293401)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h  2010-01-11 
12:37:42 UTC (rev 293402)
@@ -210,13 +210,13 @@

 typedef struct st_mysqlnd_stats MYSQLND_STATS;

-typedef void (*mysqlnd_stat_handler)(MYSQLND_STATS * stats, 
enum_mysqlnd_collected_stats stat, int64_t change TSRMLS_DC);
+typedef void (*mysqlnd_stat_trigger)(MYSQLND_STATS * stats, 
enum_mysqlnd_collected_stats stat, int64_t change TSRMLS_DC);

 struct st_mysqlnd_stats
 {
        uint64_t                                values[STAT_LAST];
-       mysqlnd_stat_handler    *handlers;
-       zend_bool                               in_handler;
+       mysqlnd_stat_trigger    *triggers;
+       zend_bool                               in_trigger;
 #ifdef ZTS
        MUTEX_T LOCK_access;
 #endif

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to