Skip to content

Commit c3019a1

Browse files
committed
try not to crash when closing persistent sockets, because EG(persistent_list)
is cleaned before the extensions' MSHUTDOWNs are called.
1 parent 3cddf1d commit c3019a1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ext/mysqlnd/mysqlnd_net.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,15 @@ mysqlnd_net_free(MYSQLND_NET * const net TSRMLS_DC)
932932
if (net->stream) {
933933
DBG_INF_FMT("Freeing stream. abstract=%p", net->stream->abstract);
934934
if (pers) {
935-
php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
935+
if (EG(active)) {
936+
php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR);
937+
} else {
938+
/*
939+
otherwise we will crash because the EG(persistent_list) has been freed already,
940+
before the modules are shut down
941+
*/
942+
php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_RSRC_DTOR);
943+
}
936944
} else {
937945
php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE);
938946
}

0 commit comments

Comments
 (0)