Hello nicos,

Tuesday, September 16, 2003, 11:43:44 AM, you wrote:


> ----- Original Message ----- 
> From: "Marcus Börger" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Tuesday, September 16, 2003 11:28 AM
> Subject: Re: [PHP-DEV] Re: Bug in xxxxx_close();


>> 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.

> Do you consider the default link as the last created one?

If no link is open already then a xxx_open() will store the created link as
the default link. So in the example the default link would be created and
directly closed inside the loop. I think the example doesn't work because
the variable $link keeps a second connection to the link. The close call
should work on the default link and hence reduce its refcount. When the next
assign to $link occures it must be freed before doing so. And that should
result in another refcount reduction which should also free the resource and
hence close the db connection.

Lemme try to unroll the loop and explain what i would expect to happen:

$link = mysql_open()   // default-link set (refcount=1), $link= (refcount=2)
mysql_close()          // default-link refcount-- (refcount=1)
$link = mysql_open()   // new-link, zval_dtor($link)->close default-link,
// $link=new-link, ?? what happens to default-link, imo it should be closed
// new-link(refcount=1)
mysql_close()          // ?? nothing no default-link
$link = mysql_open()   // ?? default-link-set (refcount=1),
// zval_dtor($link)->close, $link= default-link (refcount=2)
mysql_close() // ...
<EOF>
-- 
Best regards,
 Marcus                            mailto:[EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to