Re: Re: Bug in xxxxx_close();
| From: | (Marcus B�rger) | Date: | Tue, 16 Sep 2003 09:28:29 +0000 |
| Subject: | Re: Re: Bug in xxxxx_close(); | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-4493@lists.php.net to get a copy of this message | ||
Hello nicos,
Tuesday, September 16, 2003, 9:45:37 AM, you wrote:
> "Georg Richter" <georg@php.net> a écrit dans le message de
> news:200309132116.45988.georg@php.net...
>> Hi,
>>
>> currently I don't have time to analyze or fix it, so I hope someone will
> take
>> a look, it affects most of db-extensions which support (optional) default
>> connection.
>>
>> Sample:
>>
>> <?php
>> for ($i=0;$i<1000; $i++) {
>> $link = mysql_connect("localhost", "foo", "bar");
>> mysql_close();
>> }
>> ?>
>>
>> doesn't work correct:
> I see, is mysql_close() supposed to close every link opened then ? If so I
> could work on a patch soon.
No, these functions are supposed to close the default link only when called
without a link. I had an idea and experimented with a patch, unfortunatley
it didn't help. Maybe it gives you some more ideas and something you might
want to try out.
--
Best regards,
Marcus mailto:helly@php.net
Index: ext/mysql/php_mysql.c =================================================================== RCS file: /repository/php-src/ext/mysql/php_mysql.c,v retrieving revision 1.199 diff -u -p -d -r1.199 php_mysql.c --- ext/mysql/php_mysql.c 28 Aug 2003 19:17:34 -0000 1.199 +++ ext/mysql/php_mysql.c 13 Sep 2003 19:35:27 -0000 @@ -865,13 +865,15 @@ PHP_FUNCTION(mysql_close) if (id==-1) { /* explicit resource number */ PHPMY_UNBUFFERED_QUERY_CHECK(); + if (Z_RESVAL_PP(mysql_link) == MySG(default_link)) { + zend_list_delref(Z_RESVAL_PP(mysql_link)); + MySG(default_link) = -1; + } zend_list_delete(Z_RESVAL_PP(mysql_link)); - } - - if (id!=-1 - || (mysql_link && Z_RESVAL_PP(mysql_link)==MySG(default_link))) { + } else { PHPMY_UNBUFFERED_QUERY_CHECK(); - zend_list_delete(MySG(default_link)); + zend_list_delref(id); + zend_list_delete(id); MySG(default_link) = -1; }
Index: ext/mysql/php_mysql.c =================================================================== RCS file: /repository/php-src/ext/mysql/php_mysql.c,v retrieving revision 1.199 diff -u -p -d -r1.199 php_mysql.c --- ext/mysql/php_mysql.c 28 Aug 2003 19:17:34 -0000 1.199 +++ ext/mysql/php_mysql.c 13 Sep 2003 19:35:27 -0000 @@ -865,13 +865,15 @@ PHP_FUNCTION(mysql_close) if (id==-1) { /* explicit resource number */ PHPMY_UNBUFFERED_QUERY_CHECK(); + if (Z_RESVAL_PP(mysql_link) == MySG(default_link)) { + zend_list_delref(Z_RESVAL_PP(mysql_link)); + MySG(default_link) = -1; + } zend_list_delete(Z_RESVAL_PP(mysql_link)); - } - - if (id!=-1 - || (mysql_link && Z_RESVAL_PP(mysql_link)==MySG(default_link))) { + } else { PHPMY_UNBUFFERED_QUERY_CHECK(); - zend_list_delete(MySG(default_link)); + zend_list_delref(id); + zend_list_delete(id); MySG(default_link) = -1; }