Back to index

php5  5.3.10
Defines | Functions | Variables
mysqlnd_statistics.c File Reference
#include "php.h"
#include "mysqlnd.h"
#include "mysqlnd_priv.h"
#include "mysqlnd_statistics.h"
#include "mysqlnd_debug.h"

Go to the source code of this file.

Defines

#define STR_W_LEN(str)   str, (sizeof(str) - 1)

Functions

PHPAPI void mysqlnd_fill_stats_hash (const MYSQLND_STATS *const stats, const MYSQLND_STRING *names, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC)
PHPAPI void _mysqlnd_get_client_stats (zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC)
PHPAPI void mysqlnd_stats_init (MYSQLND_STATS **stats, size_t statistic_count)
PHPAPI void mysqlnd_stats_end (MYSQLND_STATS *stats)
PHPAPI mysqlnd_stat_trigger mysqlnd_stats_set_trigger (MYSQLND_STATS *const stats, enum_mysqlnd_collected_stats statistic, mysqlnd_stat_trigger trigger TSRMLS_DC)
PHPAPI mysqlnd_stat_trigger mysqlnd_stats_reset_triggers (MYSQLND_STATS *const stats TSRMLS_DC)

Variables

const MYSQLND_STRING mysqlnd_stats_values_names [STAT_LAST]

Define Documentation

#define STR_W_LEN (   str)    str, (sizeof(str) - 1)

Definition at line 29 of file mysqlnd_statistics.c.


Function Documentation

PHPAPI void _mysqlnd_get_client_stats ( zval *return_value TSRMLS_DC  ZEND_FILE_LINE_DC)

Definition at line 231 of file mysqlnd_statistics.c.

{
       MYSQLND_STATS stats, *stats_ptr = mysqlnd_global_stats;
       DBG_ENTER("_mysqlnd_get_client_stats");
       if (!stats_ptr) {
              memset(&stats, 0, sizeof(stats));
              stats_ptr = &stats;
       }
       mysqlnd_fill_stats_hash(stats_ptr, mysqlnd_stats_values_names, return_value TSRMLS_CC ZEND_FILE_LINE_CC);
       DBG_VOID_RETURN;
}

Here is the call graph for this function:

PHPAPI void mysqlnd_fill_stats_hash ( const MYSQLND_STATS *const  stats,
const MYSQLND_STRING names,
zval *return_value TSRMLS_DC  ZEND_FILE_LINE_DC 
)

Definition at line 202 of file mysqlnd_statistics.c.

{
       unsigned int i;

       mysqlnd_array_init(return_value, stats->count);
       for (i = 0; i < stats->count; i++) {
#if MYSQLND_UNICODE
              UChar *ustr, *tstr;
              int ulen, tlen;
#endif
              char tmp[25];

              sprintf((char *)&tmp, MYSQLND_LLU_SPEC, stats->values[i]);
#if MYSQLND_UNICODE
              zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, names[i].s, names[i].l + 1 TSRMLS_CC);
              zend_string_to_unicode(UG(utf8_conv), &tstr, &tlen, tmp, strlen(tmp) + 1 TSRMLS_CC);
              add_u_assoc_unicode_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen, tstr, 1);
              efree(ustr);
              efree(tstr);
#else
              add_assoc_string_ex(return_value, names[i].s, names[i].l + 1, tmp, 1);
#endif
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHPAPI void mysqlnd_stats_end ( MYSQLND_STATS *  stats)

Definition at line 267 of file mysqlnd_statistics.c.

{
#ifdef ZTS
       tsrm_mutex_free(stats->LOCK_access);
#endif
       free(stats->triggers);
       free(stats->values);
       /* mnd_free will reference LOCK_access and crash...*/
       free(stats);
}

Here is the caller graph for this function:

PHPAPI void mysqlnd_stats_init ( MYSQLND_STATS **  stats,
size_t  statistic_count 
)

Definition at line 247 of file mysqlnd_statistics.c.

{
       *stats = calloc(1, sizeof(MYSQLND_STATS));
       if (*stats == NULL) {
              return;
       }
       (*stats)->values = calloc(statistic_count, sizeof(uint64_t));
       (*stats)->triggers = calloc(statistic_count, sizeof(mysqlnd_stat_trigger));
       (*stats)->in_trigger = FALSE;
       (*stats)->count = statistic_count;
#ifdef ZTS
       (*stats)->LOCK_access = tsrm_mutex_alloc();
#endif

}

Here is the caller graph for this function:

PHPAPI mysqlnd_stat_trigger mysqlnd_stats_reset_triggers ( MYSQLND_STATS *const stats  TSRMLS_DC)

Definition at line 299 of file mysqlnd_statistics.c.

{
       mysqlnd_stat_trigger ret = NULL;
       DBG_ENTER("mysqlnd_stats_reset_trigger");
       if (stats) {
              MYSQLND_STATS_LOCK(stats);
              memset(stats->triggers, 0, stats->count * sizeof(mysqlnd_stat_trigger));
              MYSQLND_STATS_UNLOCK(stats);
       }
       DBG_RETURN(ret);
}

Here is the call graph for this function:

PHPAPI mysqlnd_stat_trigger mysqlnd_stats_set_trigger ( MYSQLND_STATS *const  stats,
enum_mysqlnd_collected_stats  statistic,
mysqlnd_stat_trigger trigger  TSRMLS_DC 
)

Definition at line 282 of file mysqlnd_statistics.c.

{
       mysqlnd_stat_trigger ret = NULL;
       DBG_ENTER("mysqlnd_stats_set_trigger");
       if (stats) {
              MYSQLND_STATS_LOCK(stats);
              ret = stats->triggers[statistic];
              stats->triggers[statistic] = trigger;
              MYSQLND_STATS_UNLOCK(stats);
       }
       DBG_RETURN(ret);
}

Here is the call graph for this function:


Variable Documentation

Definition at line 34 of file mysqlnd_statistics.c.