andrey                                   Thu, 06 Oct 2011 00:45:58 +0000

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

Log:
try not to crash when closing persistent sockets, because EG(persistent_list)
is cleaned before the extensions' MSHUTDOWNs are called.

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

Modified: php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_net.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_net.c      2011-10-06 
00:24:01 UTC (rev 317814)
+++ php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_net.c      2011-10-06 
00:45:58 UTC (rev 317815)
@@ -932,7 +932,15 @@
                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);
                        }

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2011-10-06 00:24:01 UTC (rev 
317814)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_net.c 2011-10-06 00:45:58 UTC (rev 
317815)
@@ -932,7 +932,15 @@
                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);
                        }

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

Reply via email to