Hello nicos,

Tuesday, September 16, 2003, 9:45:37 AM, you wrote:


> "Georg Richter" <[EMAIL PROTECTED]> a écrit dans le message de
> news:[EMAIL PROTECTED]
>> 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:[EMAIL PROTECTED]
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;
        }
 
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to