]> granicus.if.org Git - php/commitdiff
Better fix for bug #51347 mysqli_close / connection memory leak
authorAndrey Hristov <andrey@php.net>
Thu, 1 Apr 2010 12:46:21 +0000 (12:46 +0000)
committerAndrey Hristov <andrey@php.net>
Thu, 1 Apr 2010 12:46:21 +0000 (12:46 +0000)
ext/mysqlnd/mysqlnd_net.c

index 7db43d3ea5c49efb3d9705dfcdac62ec4629580f..41e1bd7fc1cc47f42dc3c408e97701032ac4bf60 100644 (file)
@@ -159,6 +159,14 @@ MYSQLND_METHOD(mysqlnd_net, connect)(MYSQLND_NET * net, const char * const schem
 #endif
                efree(hashed_details);
        }
+       /*
+         Streams are not meant for C extensions! Thus we need a hack. Every connected stream will
+         be registered as resource (in EG(regular_list). So far, so good. However, it won't be
+         unregistered till the script ends. So, we need to take care of that.
+       */
+       net->stream->in_free = 1;
+       zend_hash_index_del(&EG(regular_list), net->stream->rsrc_id);
+       net->stream->in_free = 0;
 
        if (!net->options.timeout_read) {
                /* should always happen because read_timeout cannot be set via API */
@@ -703,15 +711,6 @@ mysqlnd_net_free(MYSQLND_NET * const net TSRMLS_DC)
                        mnd_pefree(net->cmd_buffer.buffer, pers);
                        net->cmd_buffer.buffer = NULL;
                }
-               /*
-                 Streams are not meant for C extensions! Thus we need a hack. Every connected stream will
-                 be registered as resource (in EG(regular_list). So far, so good. However, it won't be
-                 unregistered till the script ends. So, we need to take care of that.
-                 */
-               net->stream->in_free = 1;
-               zend_hash_index_del(&EG(regular_list), net->stream->rsrc_id);
-               net->stream->in_free = 0;
-
                if (net->stream) {
                        DBG_INF_FMT("Freeing stream. abstract=%p", net->stream->abstract);
                        if (pers) {