Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix GH-13519: PGSQL_CONNECT_FORCE_RENEW with persistent connections.
persistent connections did not take in account this flag, after the usual link sanity checks, we remove its entry. Close GH-13519
- Loading branch information
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -562,6 +562,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) | |
|
||
/* try to find if we already have this link in our persistent list */ | ||
if ((le = zend_hash_find_ptr(&EG(persistent_list), str.s)) == NULL) { /* we don't */ | ||
newpconn: | ||
if (PGG(max_links) != -1 && PGG(num_links) >= PGG(max_links)) { | ||
php_error_docref(NULL, E_WARNING, | ||
"Cannot create new link. Too many open links (" ZEND_LONG_FMT ")", PGG(num_links)); | ||
|
@@ -590,6 +591,12 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) | |
PGG(num_links)++; | ||
PGG(num_persistent)++; | ||
} else { /* we do */ | ||
if ((connect_type & PGSQL_CONNECT_FORCE_NEW)) { | ||
if (zend_hash_del(&EG(persistent_list), str.s) != SUCCESS) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nielsdos
Member
|
||
goto err; | ||
} | ||
goto newpconn; | ||
} | ||
if (le->type != le_plink) { | ||
goto err; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--TEST-- | ||
GH-13519 - PGSQL_CONNECT_FORCE_NEW with persistent connections. | ||
--EXTENSIONS-- | ||
pgsql | ||
--SKIPIF-- | ||
<?php include("skipif.inc"); ?> | ||
--FILE-- | ||
<?php | ||
include 'config.inc'; | ||
|
||
$db1 = pg_pconnect($conn_str); | ||
$pid1 = pg_get_pid($db1); | ||
for ($i = 0; $i < 3; $i ++) { | ||
$db2 = pg_pconnect($conn_str); | ||
var_dump($pid1 === pg_get_pid($db2)); | ||
} | ||
for ($i = 0; $i < 3; $i ++) { | ||
$db2 = pg_pconnect($conn_str, PGSQL_CONNECT_FORCE_NEW); | ||
var_dump($pid1 === pg_get_pid($db2)); | ||
pg_close($db2); | ||
} | ||
pg_close($db1); | ||
?> | ||
--EXPECT-- | ||
bool(true) | ||
bool(true) | ||
bool(true) | ||
bool(false) | ||
bool(false) | ||
bool(false) |
1 comment
on commit b9a9790
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saundefined This change needs to be reverted from 8.2.17
@nielsdos just asking your opinion since you know well this area. Is there a need to do more steps or using a different approach when removing persistent resources, seems then when the module shutdown it segfaults with non ZTS build/release. Thanks.