From: Andrey Hristov Date: Thu, 6 Oct 2011 00:45:58 +0000 (+0000) Subject: try not to crash when closing persistent sockets, because EG(persistent_list) X-Git-Tag: php-5.4.0beta2~44 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c3019a16d551c9f3540be1d35776d71f19c8aa8b;p=php try not to crash when closing persistent sockets, because EG(persistent_list) is cleaned before the extensions' MSHUTDOWNs are called. --- diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c index 15a539fdb9..b558ce3af4 100644 --- a/ext/mysqlnd/mysqlnd_net.c +++ b/ext/mysqlnd/mysqlnd_net.c @@ -932,7 +932,15 @@ mysqlnd_net_free(MYSQLND_NET * const net TSRMLS_DC) if (net->stream) { DBG_INF_FMT("Freeing stream. abstract=%p", net->stream->abstract); if (pers) { - php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR); + if (EG(active)) { + php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR); + } else { + /* + otherwise we will crash because the EG(persistent_list) has been freed already, + before the modules are shut down + */ + php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_RSRC_DTOR); + } } else { php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE); }