Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ext/dba/dba.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ ZEND_BEGIN_MODULE_GLOBALS(dba)
const char *default_handler;
const dba_handler *default_hptr;
HashTable connections;
unsigned int connection_counter;
ZEND_END_MODULE_GLOBALS(dba)

ZEND_DECLARE_MODULE_GLOBALS(dba)
Expand Down Expand Up @@ -571,7 +572,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent)

char *resource_key;
size_t resource_key_len = spprintf(&resource_key, 0,
"dba_%d_%s_%s_%s", persistent, ZSTR_VAL(path), ZSTR_VAL(mode), handler_str ? ZSTR_VAL(handler_str) : ""
"dba_%d_%u_%s_%s_%s", persistent, persistent ? 0 : DBA_G(connection_counter)++, ZSTR_VAL(path), ZSTR_VAL(mode), handler_str ? ZSTR_VAL(handler_str) : ""
);

if (persistent) {
Expand Down
34 changes: 34 additions & 0 deletions ext/dba/tests/dba_duplicateopen.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
DBA open same read only file multiple times
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip('cdb_make');
?>
--CONFLICTS--
test.cdb
--FILE--
<?php
echo "database handler: cdb\n";
$handler = 'cdb';
$db_filename = __DIR__.'/test.cdb';
if (($db_file=dba_open($db_filename, "r", $handler))!==FALSE) {
echo dba_fetch(1, $db_file);
if (($db_file2=dba_open($db_filename, "r", $handler))!==FALSE) {
echo dba_fetch(1, $db_file2);
echo dba_fetch(2, $db_file2);
dba_close($db_file2);
} else {
echo "Error opening database 2nd time\n";
}
echo dba_fetch(2, $db_file);
dba_close($db_file);
} else {
echo "Error opening database\n";
}
?>
--EXPECT--
database handler: cdb
1122
Loading