]> granicus.if.org Git - php/commitdiff
Sync with PHP6 - TSRMLS_FETCH
authorAndrey Hristov <andrey@php.net>
Thu, 11 Jun 2009 08:30:08 +0000 (08:30 +0000)
committerAndrey Hristov <andrey@php.net>
Thu, 11 Jun 2009 08:30:08 +0000 (08:30 +0000)
Extract reference decrement in own function
Remove PHPAPI of a function and make it static as it is not called
externally

ext/mysqlnd/mysqlnd.h
ext/mysqlnd/mysqlnd_palloc.c
ext/mysqlnd/mysqlnd_wireprotocol.c
ext/mysqlnd/php_mysqlnd.c

index 99fedc9ef8e9928596ced0062540394eeb2e4d8a..414ff5052f660b627e032da8d05f8d7f141be327 100644 (file)
@@ -318,11 +318,9 @@ PHPAPI MYSQLND_THD_ZVAL_PCACHE * _mysqlnd_palloc_rinit(MYSQLND_ZVAL_PCACHE * cac
 PHPAPI void                                             _mysqlnd_palloc_rshutdown(MYSQLND_THD_ZVAL_PCACHE * cache TSRMLS_DC);
 
 
-#define mysqlnd_palloc_init_thd_cache(cache)                   _mysqlnd_palloc_init_thd_cache((cache) TSRMLS_CC)
 #define mysqlnd_palloc_free_thd_cache_reference(cache) _mysqlnd_palloc_free_thd_cache_reference((cache) TSRMLS_CC)
 #define mysqlnd_palloc_get_thd_cache_reference(cache)  _mysqlnd_palloc_get_thd_cache_reference((cache) TSRMLS_CC)
 
-PHPAPI MYSQLND_THD_ZVAL_PCACHE*        _mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCACHE * const cache TSRMLS_DC);
 MYSQLND_THD_ZVAL_PCACHE*               _mysqlnd_palloc_get_thd_cache_reference(MYSQLND_THD_ZVAL_PCACHE * const cache TSRMLS_DC);
 PHPAPI void                                            _mysqlnd_palloc_free_thd_cache_reference(MYSQLND_THD_ZVAL_PCACHE **cache TSRMLS_DC);
 
index 1b035ed365b9f0f6893761666f11e87c72754dac..eeaedd18f8366b98165957ba8f0c19ca1573c581 100644 (file)
@@ -82,6 +82,7 @@ PHPAPI MYSQLND_ZVAL_PCACHE* _mysqlnd_palloc_init_cache(unsigned int cache_size T
 
 
 /* {{{ mysqlnd_palloc_get_cache_reference */
+static inline
 MYSQLND_ZVAL_PCACHE* mysqlnd_palloc_get_cache_reference(MYSQLND_ZVAL_PCACHE * const cache)
 {
        if (cache) {
@@ -94,6 +95,20 @@ MYSQLND_ZVAL_PCACHE* mysqlnd_palloc_get_cache_reference(MYSQLND_ZVAL_PCACHE * co
 /* }}} */
 
 
+/* {{{ mysqlnd_palloc_release_cache_reference */
+static inline
+MYSQLND_ZVAL_PCACHE* mysqlnd_palloc_release_cache_reference(MYSQLND_ZVAL_PCACHE * const cache)
+{
+       if (cache) {
+               LOCK_PCACHE(cache);
+               cache->references--;
+               UNLOCK_PCACHE(cache);
+       }
+       return cache;
+}
+/* }}} */
+
+
 /* {{{ mysqlnd_palloc_free_cache */
 /*
   As this call will happen on MSHUTDOWN(), then we don't need to copy the zvals with
@@ -122,7 +137,7 @@ void _mysqlnd_palloc_free_cache(MYSQLND_ZVAL_PCACHE *cache TSRMLS_DC)
 
 
 /* {{{ _mysqlnd_palloc_init_thd_cache */
-PHPAPI MYSQLND_THD_ZVAL_PCACHE* _mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCACHE * const cache TSRMLS_DC)
+MYSQLND_THD_ZVAL_PCACHE* mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCACHE * const cache TSRMLS_DC)
 {
        MYSQLND_THD_ZVAL_PCACHE *ret = calloc(1, sizeof(MYSQLND_THD_ZVAL_PCACHE));
        DBG_ENTER("_mysqlnd_palloc_init_thd_cache");
@@ -163,17 +178,18 @@ MYSQLND_THD_ZVAL_PCACHE* _mysqlnd_palloc_get_thd_cache_reference(MYSQLND_THD_ZVA
 {
        DBG_ENTER("_mysqlnd_palloc_get_thd_cache_reference");
        if (cache) {
-               ++cache->references;
                DBG_INF_FMT("cache=%p new_refc=%d gc_list.canary1=%p gc_list.canary2=%p",
                                        cache, cache->references, cache->gc_list.canary1, cache->gc_list.canary2);
                mysqlnd_palloc_get_cache_reference(cache->parent);
+               /* No concurrency here, we are in the same thread */
+               ++cache->references;
        }
        DBG_RETURN(cache);
 }
 /* }}} */
 
 
-/* {{{ mysqlnd_palloc_free_cache */
+/* {{{ mysqlnd_palloc_free_thd_cache */
 /*
   As this call will happen on MSHUTDOWN(), then we don't need to copy the zvals with
   copy_ctor but scrap what they point to with zval_dtor() and then just free our
@@ -230,7 +246,7 @@ PHPAPI void _mysqlnd_palloc_free_thd_cache_reference(MYSQLND_THD_ZVAL_PCACHE **c
 {
        DBG_ENTER("_mysqlnd_palloc_free_thd_cache_reference");
        if (*cache) {
-               --(*cache)->parent->references;
+               mysqlnd_palloc_release_cache_reference((*cache)->parent);
                DBG_INF_FMT("cache=%p references_left=%d canary1=%p canary2=%p",
                                        *cache, (*cache)->references, (*cache)->gc_list.canary1, (*cache)->gc_list.canary2);
 
@@ -528,7 +544,7 @@ void mysqlnd_palloc_zval_ptr_dtor(zval **zv, MYSQLND_THD_ZVAL_PCACHE * const thd
 /* {{{ _mysqlnd_palloc_rinit */
 PHPAPI MYSQLND_THD_ZVAL_PCACHE * _mysqlnd_palloc_rinit(MYSQLND_ZVAL_PCACHE * cache TSRMLS_DC)
 {
-       return mysqlnd_palloc_init_thd_cache(cache);
+       return mysqlnd_palloc_init_thd_cache(cache TSRMLS_CC);
 }
 /* }}} */
 
index 2924827e9c00cdcdc809dbb5dca2f20d040909bd..c9cc38241e33774e4afd715ad8a3b6c19f627016 100644 (file)
@@ -42,7 +42,6 @@
 #define MYSQLND_DUMP_HEADER_N_BODY2
 #define MYSQLND_DUMP_HEADER_N_BODY_FULL2
 
-
 #define        PACKET_READ_HEADER_AND_BODY(packet, conn, buf, buf_size, packet_type_as_text, packet_type) \
        { \
                if (FAIL == mysqlnd_read_header((conn), &((packet)->header) TSRMLS_CC)) {\
@@ -1364,7 +1363,7 @@ void php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffe
        zval **current_field, **end_field, **start_field;
        zend_bool as_unicode = conn->options.numeric_and_datetime_as_unicode;
        zend_bool allocated;
-       void *obj;
+       void *obj = NULL;
 
        DBG_ENTER("php_mysqlnd_rowp_read_binary_protocol");
 
index 7ebb748024d0f91f2debd86afab62746b99d353f..196b96e88407428655eb918a7851932d4522a269 100644 (file)
@@ -46,13 +46,13 @@ PHPAPI void mysqlnd_minfo_print_hash(zval *values)
 
        zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos_values);
        while (zend_hash_get_current_data_ex(Z_ARRVAL_P(values),
-                                                                               (void **)&values_entry, &pos_values) == SUCCESS) {
-               TSRMLS_FETCH();
+               (void **)&values_entry, &pos_values) == SUCCESS) {
                zstr    string_key;
                uint    string_key_len;
                ulong   num_key;
                int     s_len;
                char    *s = NULL;
+               TSRMLS_FETCH();
 
                zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &string_key, &string_key_len, &num_key, 0, &pos_values);