From 25de19a2fbec1db3e889ab473a493496c3ba51bb Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Thu, 8 Dec 2005 19:35:05 +0000 Subject: [PATCH] - MFH Change dba/db4 to use its own locking --- ext/dba/dba.c | 2 +- ext/dba/dba_db4.c | 9 +++++---- ext/dba/tests/dba_db4.phpt | 18 ++---------------- ext/dba/tests/dba_handler.inc | 2 +- 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/ext/dba/dba.c b/ext/dba/dba.c index a7842922ad..4cd5baf268 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -250,7 +250,7 @@ static dba_handler handler[] = { DBA_HND(db3, DBA_LOCK_ALL) /* No lock in lib */ #endif #if DBA_DB4 - DBA_HND(db4, DBA_LOCK_ALL) /* No lock in lib */ + DBA_HND(db4, DBA_LOCK_EXT) /* Locking done in library itself */ #endif #if DBA_INIFILE DBA_HND(inifile, DBA_STREAM_OPEN|DBA_LOCK_ALL|DBA_CAST_AS_FD) /* No lock in lib */ diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c index 6dee094832..93ec4bc235 100644 --- a/ext/dba/dba_db4.c +++ b/ext/dba/dba_db4.c @@ -77,14 +77,15 @@ DBA_OPEN_FUNC(db4) info->mode == DBA_WRITER ? 0 : info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1; - if (info->flags & DBA_PERSISTENT) { - gmode |= DB_THREAD; - } - if (gmode == -1) { return FAILURE; /* not possible */ } + gmode |= DB_INIT_LOCK; + if (info->flags & DBA_PERSISTENT) { + gmode |= DB_THREAD; + } + if (info->argc > 0) { convert_to_long_ex(info->argv[0]); filemode = Z_LVAL_PP(info->argv[0]); diff --git a/ext/dba/tests/dba_db4.phpt b/ext/dba/tests/dba_db4.phpt index fcf089a1e9..252797bf41 100644 --- a/ext/dba/tests/dba_db4.phpt +++ b/ext/dba/tests/dba_db4.phpt @@ -9,6 +9,7 @@ DBA DB4 handler test ===DONE=== @@ -17,22 +18,7 @@ database handler: db4 3NYNYY Content String 2 Content 2 replaced -Read during write: not allowed -Content 2 replaced 2nd time -The 6th value -array(3) { - ["key number 6"]=> - string(13) "The 6th value" - ["key2"]=> - string(27) "Content 2 replaced 2nd time" - ["key5"]=> - string(23) "The last content string" -} ---NO-LOCK-- -3NYNYY -Content String 2 -Content 2 replaced -Read during write: not allowed +Read during write: allowed Content 2 replaced 2nd time The 6th value array(3) { diff --git a/ext/dba/tests/dba_handler.inc b/ext/dba/tests/dba_handler.inc index c1e3c49c70..1c3f5127ef 100644 --- a/ext/dba/tests/dba_handler.inc +++ b/ext/dba/tests/dba_handler.inc @@ -73,7 +73,7 @@ do { if (!empty($dba_reader)) { dba_close($dba_reader); } - if (($db_file = dba_popen($db_filename, 'r'.($handler!='gdbm'?'-':''), $handler))!==FALSE) { + if (($db_file = dba_popen($db_filename, 'r'.($lock_flag==''?'':'-'), $handler))!==FALSE) { if ($handler == 'dbm') { dba_close($db_file); } -- 2.40.0