On Thu, Feb 15, 2001 at 01:47:46PM +0200, Zeev Suraski wrote:
> At 13:01 15/2/2001, Thies C. Arntzen wrote:
> >On Thu, Feb 15, 2001 at 04:17:06AM +0200, Zeev Suraski wrote:
> > > This patch won't always work (it may cause the link not to be closed when
> > > it's supposed to). I committed a different patch to the CVS - can you
> >
> > under what circumstances?
>
> Well, if you have an open link, and then you reopen the same link, then the
> original code would fail. Why?
>
> pgsql_connect(); // default_link is -1, so no ref-- is
> done. ref is 1 after it, and link is set to n (e.g. 2)
> pgsql_connect(); // default_link is 2, ref is 1, so ref--
> brings it to 0, deletes it, and only afterwards theres ref++ which brings
> it to 1, but it's already too late
>
> with the original patch:
> pgsql_connect(); // default_link is -1, so no ref-- is
> done. ref is 1 after it, and link is set to n (e.g. 2)
> pgsql_connect(); // default link is 2, ref is 1. with the
> patch, no ref-- is done, and then there's a ref++ - which brings ref to
> 2. this refcount is wrong...
>
> with my patch:
> pgsql_connect(); // default_link is -1, so no ref-- is
> done. ref is 1 after it, and link is set to n (e.g. 2)
> pgsql_connect(); // default_link is 2, ref++ brings it the
> refcount to 2, ref-- brings it back to 1. all is well...
ok - got you.
tc
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]