-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix#75419 Fix clearing of default link during pg_close()
- Loading branch information
Showing
2 changed files
with
21 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--TEST-- | ||
Bug #75419 Default link leaked via pg_close() | ||
--SKIPIF-- | ||
<?php include("skipif.inc"); ?> | ||
--FILE-- | ||
<?php | ||
include('config.inc'); | ||
|
||
$db1 = pg_connect($conn_str, PGSQL_CONNECT_FORCE_NEW); | ||
$db2 = pg_connect($conn_str, PGSQL_CONNECT_FORCE_NEW); | ||
pg_close($db1); | ||
var_dump(pg_ping()); | ||
--EXPECT-- | ||
bool(true) |
a645af4
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.
What is the expected behavior for connections that don't use PGSQL_CONNECT_FORCE_NEW? I think with this patch pg_close() is going to close shared connections.
a645af4
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.
If you don't pass PGSQL_CONNECT_FORCE_NEW then $db2 and $db1 will be referring to the same zend_resource, yes.
This diff maintains the existing behavior that the connection will close in response to pg_close() and both variables will refer to a dead resource. (Note that in the previous revision, lines 1583 and 1587 essentially resulted in a
zend_list_close()
regardless of the value ofargc
.a645af4
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.
@sgolemon Yeah, you're right, I misread the diff. Another question: Shouldn't we be doing a decref in the default_link branch? We incref when we set the default link, but don't decref here.
a645af4
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.
Good point. I think you're right, will look closer in a bit.
a645af4
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.
Good catch. 68e27b0