]> granicus.if.org Git - php/commitdiff
- Do locking in lib rather then on streams
authorMarcus Boerger <helly@php.net>
Sun, 20 Nov 2005 12:39:04 +0000 (12:39 +0000)
committerMarcus Boerger <helly@php.net>
Sun, 20 Nov 2005 12:39:04 +0000 (12:39 +0000)
ext/dba/dba.c
ext/dba/dba_db4.c
ext/dba/tests/dba_db4.phpt
ext/dba/tests/dba_handler.inc

index 3a96fe7ef04c08124ea31c1cdf953de4ab908591..535b54b40c21b4b227c09a613227a5aab60d97f9 100644 (file)
@@ -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 */
index 6dee09483258020fca73e330301d972f616f944c..93ec4bc2353e1720d112cde7e6e230d99fee26c3 100644 (file)
@@ -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]);
index fcf089a1e90b017113f6ed991302c630027eb571..252797bf41168a4ddd361f7a380200f7e5f68870 100644 (file)
@@ -9,6 +9,7 @@ DBA DB4 handler test
 <?php
        $handler = 'db4';
        require_once('test.inc');
+       $lock_flag = ''; // lock in library
        require_once('dba_handler.inc');
 ?>
 ===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) {
index c1e3c49c70e0fdb295dee93988ed70884423815f..1c3f5127ef3846206825d545b080782105f05eb8 100644 (file)
@@ -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);
                }