Skip to content

ext/dba: Fix dba_close() not closing a dba_popen() connection - #25350

Closed
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/aph-dba-close-persistent-5dhu-84
Closed

iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/aph-dba-close-persistent-5dhu-84

Conversation

@iliaal

@iliaal iliaal commented Nov 9, 2026

Copy link
Copy Markdown
Member

After dba_popen(), dba_close() left the file open and its lock held until shutdown, because it looked up the persistent entry after dba_close_connection() had already cleared connection->info. Count connections on the persistent resource's refcount again, as PHP 8.3 did, so the last dba_close() closes the handle. A handle sharing its stream with another persistent handle (modes rl and rd on one file) stays open, as before. Lock checks also see persistent handles still in use. Girgias pointed this out on #25155.

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable, just some nits.

Comment thread ext/dba/dba.c Resolved
Comment thread ext/dba/dba.c Resolved
dba_close() looked up the persistent entry with connection->info after
dba_close_connection() had cleared it, so the entry was never removed and
the database file and its lock stayed held. Count the connections on the
entry's refcount again, as PHP 8.3 did, and close the handle when
dba_close() releases the last one, unless another persistent handle to the
same file shares its stream. Lock conflict checks now also see persistent
handles still in use, since closing one of two connections with the same
key removed the other's DBA_G(connections) entry.
@iliaal
iliaal force-pushed the fix/aph-dba-close-persistent-5dhu-84 branch from ddb77d7 to b425175 Compare November 10, 2026 00:10
@iliaal iliaal closed this in 7302ff4 Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants