diff options
author | Andrey Hristov <andrey@php.net> | 2010-04-01 11:50:24 +0000 |
---|---|---|
committer | Andrey Hristov <andrey@php.net> | 2010-04-01 11:50:24 +0000 |
commit | 311ab2c822e0a14a8785d8889953d7f8a744d4f6 (patch) | |
tree | de9fb9426336d465f87e5a1faf062f95e6e09afd /ext/mysqlnd/mysqlnd_net.c | |
parent | 60176163f13dae8fe1902b3f1c4cc9e5970d8ba7 (diff) | |
download | php-git-311ab2c822e0a14a8785d8889953d7f8a744d4f6.tar.gz |
Fixed bug #51347 mysqli_close / connection memory leak
Streams API registers every stream as resource, which lands then
in EG(regular_list), however doesn't clean that when the stream is
closed. At the end this is a para-leak. At the end of the script
all memory is cleaned, however this is a problem for long runnig
scripts that open connections. For every opened and closed connection
about 150 Bytes on 32bit and 250 Bytes on 64bit will be "lost",
according to memory_get_usage().
Diffstat (limited to 'ext/mysqlnd/mysqlnd_net.c')
-rw-r--r-- | ext/mysqlnd/mysqlnd_net.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c index 8f4c46e9df..7db43d3ea5 100644 --- a/ext/mysqlnd/mysqlnd_net.c +++ b/ext/mysqlnd/mysqlnd_net.c @@ -703,6 +703,14 @@ 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); |