andrey                                   Wed, 02 Nov 2011 15:08:01 +0000

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

Log:
- shift a bit of code around
- when cloning use the methods of the original object

Changed paths:
    U   php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd.c
    U   php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_driver.c
    U   php/php-src/trunk/ext/mysqlnd/mysqlnd.c
    U   php/php-src/trunk/ext/mysqlnd/mysqlnd_driver.c

Modified: php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd.c  2011-11-02 15:06:38 UTC 
(rev 318693)
+++ php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd.c  2011-11-02 15:08:01 UTC 
(rev 318694)
@@ -1698,6 +1698,12 @@
        DBG_INF_FMT("conn=%llu conn->net->stream->abstract=%p",
                                conn->thread_id, conn->net->stream? 
conn->net->stream->abstract:NULL);

+       if (CONN_GET_STATE(conn) >= CONN_READY) {
+               MYSQLND_DEC_CONN_STATISTIC(conn->stats, 
STAT_OPENED_CONNECTIONS);
+               if (conn->persistent) {
+                       MYSQLND_DEC_CONN_STATISTIC(conn->stats, 
STAT_OPENED_PERSISTENT_CONNECTIONS);
+               }
+       }
        switch (CONN_GET_STATE(conn)) {
                case CONN_READY:
                        DBG_INF("Connection clean, sending COM_QUIT");
@@ -2652,24 +2658,18 @@
        size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_methods, close);
        MYSQLND_CONN_DATA * conn = conn_handle->data;
        enum_func_status ret = FAIL;
-       static enum_mysqlnd_collected_stats
-       close_type_to_stat_map[MYSQLND_CLOSE_LAST] = {
-               STAT_CLOSE_EXPLICIT,
-               STAT_CLOSE_IMPLICIT,
-               STAT_CLOSE_DISCONNECT
-       };
-       enum_mysqlnd_collected_stats statistic = 
close_type_to_stat_map[close_type];

        DBG_ENTER("mysqlnd_conn::close");
        DBG_INF_FMT("conn=%llu", conn->thread_id);

        if (PASS == conn->m->local_tx_start(conn, this_func TSRMLS_CC)) {
                if (CONN_GET_STATE(conn) >= CONN_READY) {
-                       MYSQLND_INC_CONN_STATISTIC(conn->stats, statistic);
-                       MYSQLND_DEC_CONN_STATISTIC(conn->stats, 
STAT_OPENED_CONNECTIONS);
-                       if (conn->persistent) {
-                               MYSQLND_DEC_CONN_STATISTIC(conn->stats, 
STAT_OPENED_PERSISTENT_CONNECTIONS);
-                       }
+                       static enum_mysqlnd_collected_stats 
close_type_to_stat_map[MYSQLND_CLOSE_LAST] = {
+                               STAT_CLOSE_EXPLICIT,
+                               STAT_CLOSE_IMPLICIT,
+                               STAT_CLOSE_DISCONNECT
+                       };
+                       MYSQLND_INC_CONN_STATISTIC(conn->stats, 
close_type_to_stat_map[close_type]);
                }

                /*
@@ -2678,7 +2678,7 @@
                */
                ret = conn->m->send_close(conn TSRMLS_CC);

-               /* do it after free_reference and we might crash */
+               /* do it after free_reference/dtor and we might crash */
                conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC);

                conn_handle->m->dtor(conn_handle TSRMLS_CC);

Modified: php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_driver.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_driver.c   2011-11-02 
15:06:38 UTC (rev 318693)
+++ php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_driver.c   2011-11-02 
15:08:01 UTC (rev 318694)
@@ -174,7 +174,7 @@
                DBG_RETURN(NULL);
        }
        new_object->persistent = to_be_cloned->persistent;
-       new_object->m = mysqlnd_conn_get_methods();
+       new_object->m = to_be_cloned->m;

        new_object->data = 
to_be_cloned->data->m->get_reference(to_be_cloned->data TSRMLS_CC);
        if (!new_object->data) {

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd.c     2011-11-02 15:06:38 UTC (rev 
318693)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd.c     2011-11-02 15:08:01 UTC (rev 
318694)
@@ -1698,6 +1698,12 @@
        DBG_INF_FMT("conn=%llu conn->net->stream->abstract=%p",
                                conn->thread_id, conn->net->stream? 
conn->net->stream->abstract:NULL);

+       if (CONN_GET_STATE(conn) >= CONN_READY) {
+               MYSQLND_DEC_CONN_STATISTIC(conn->stats, 
STAT_OPENED_CONNECTIONS);
+               if (conn->persistent) {
+                       MYSQLND_DEC_CONN_STATISTIC(conn->stats, 
STAT_OPENED_PERSISTENT_CONNECTIONS);
+               }
+       }
        switch (CONN_GET_STATE(conn)) {
                case CONN_READY:
                        DBG_INF("Connection clean, sending COM_QUIT");
@@ -2652,24 +2658,18 @@
        size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_methods, close);
        MYSQLND_CONN_DATA * conn = conn_handle->data;
        enum_func_status ret = FAIL;
-       static enum_mysqlnd_collected_stats
-       close_type_to_stat_map[MYSQLND_CLOSE_LAST] = {
-               STAT_CLOSE_EXPLICIT,
-               STAT_CLOSE_IMPLICIT,
-               STAT_CLOSE_DISCONNECT
-       };
-       enum_mysqlnd_collected_stats statistic = 
close_type_to_stat_map[close_type];

        DBG_ENTER("mysqlnd_conn::close");
        DBG_INF_FMT("conn=%llu", conn->thread_id);

        if (PASS == conn->m->local_tx_start(conn, this_func TSRMLS_CC)) {
                if (CONN_GET_STATE(conn) >= CONN_READY) {
-                       MYSQLND_INC_CONN_STATISTIC(conn->stats, statistic);
-                       MYSQLND_DEC_CONN_STATISTIC(conn->stats, 
STAT_OPENED_CONNECTIONS);
-                       if (conn->persistent) {
-                               MYSQLND_DEC_CONN_STATISTIC(conn->stats, 
STAT_OPENED_PERSISTENT_CONNECTIONS);
-                       }
+                       static enum_mysqlnd_collected_stats 
close_type_to_stat_map[MYSQLND_CLOSE_LAST] = {
+                               STAT_CLOSE_EXPLICIT,
+                               STAT_CLOSE_IMPLICIT,
+                               STAT_CLOSE_DISCONNECT
+                       };
+                       MYSQLND_INC_CONN_STATISTIC(conn->stats, 
close_type_to_stat_map[close_type]);
                }

                /*
@@ -2678,7 +2678,7 @@
                */
                ret = conn->m->send_close(conn TSRMLS_CC);

-               /* do it after free_reference and we might crash */
+               /* do it after free_reference/dtor and we might crash */
                conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC);

                conn_handle->m->dtor(conn_handle TSRMLS_CC);

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_driver.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_driver.c      2011-11-02 15:06:38 UTC 
(rev 318693)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_driver.c      2011-11-02 15:08:01 UTC 
(rev 318694)
@@ -175,7 +175,7 @@
                DBG_RETURN(NULL);
        }
        new_object->persistent = to_be_cloned->persistent;
-       new_object->m = mysqlnd_conn_get_methods();
+       new_object->m = to_be_cloned->m;

        new_object->data = 
to_be_cloned->data->m->get_reference(to_be_cloned->data TSRMLS_CC);
        if (!new_object->data) {

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

Reply via email to