Skip to content

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

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

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

Conversation

@iliaal

@iliaal iliaal commented Nov 8, 2026

Copy link
Copy Markdown
Owner

dba_close() never closed a dba_popen() connection: it looked up the persistent entry after dba_close_connection() had cleared connection->info, so the file and its lock stayed held until shutdown.

Connections now count on the entry's refcount, as in PHP 8.3, so the last dba_close() closes the handle. A handle whose stream another persistent handle shares (modes rl and rd on one file) stays open, as today. Lock checks also see persistent handles in use, which closing a second connection with the same key used to hide.

Found from Girgias's comment on php#25155. Red/green with flatfile, inifile and cdb; dba015.phpt and the new test pass under valgrind.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant