Re: cvs: php4 /ext/pgsql pgsql.c

From: Date: Thu, 15 Feb 2001 11:47:46 +0000
Subject: Re: cvs: php4 /ext/pgsql pgsql.c
References: 1 2 3  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-4037@lists.php.net to get a copy of this message
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...
Zeev
please check it?
    will do -
    tc
At 18:54 13/2/2001, Thies C. Arntzen wrote:
thies           Tue Feb 13 08:54:48 2001 EDT
Modified files:
    /php4/ext/pgsql     pgsql.c
Log: @- fixes PostgeSQL pg_connect() bug. We would sometimes close the
default
@ link by acciedent. (Patch by: aja@nlgroup.ca) Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.85 php4/ext/pgsql/pgsql.c:1.86 --- php4/ext/pgsql/pgsql.c:1.85 Wed Jan 31 13:53:29 2001
+++ php4/ext/pgsql/pgsql.c      Tue Feb 13 08:54:48 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/ -/* $Id: pgsql.c,v 1.85 2001/01/31 21:53:29 andi Exp $ */ +/* $Id: pgsql.c,v 1.86 2001/02/13 16:54:48 thies Exp $ */ #include <stdlib.h> @@ -114,9 +114,10 @@ {
        PGLS_FETCH();
-    if (PGG(default_link)!=-1) {
+    if ((PGG(default_link) != -1) && (PGG(default_link) != id)) {
         zend_list_delete(PGG(default_link));
     }
+
     if (PGG(default_link) != id) {
         PGG(default_link) = id;
         zend_list_addref(id);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net For additional commands, e-mail: php-cvs-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
-- Zeev Suraski <zeev@zend.com> CTO & co-founder, Zend Technologies Ltd. http://www.zend.com/ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net For additional commands, e-mail: php-cvs-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net For additional commands, e-mail: php-cvs-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
-- Zeev Suraski <zeev@zend.com> CTO & co-founder, Zend Technologies Ltd. http://www.zend.com/

« previous php.cvs (#4037) next »