]> granicus.if.org Git - php/commitdiff
Add $lock_flag which allows to change lock behaviour for both 'l' and 'd'
authorMarcus Boerger <helly@php.net>
Sun, 10 Nov 2002 22:56:29 +0000 (22:56 +0000)
committerMarcus Boerger <helly@php.net>
Sun, 10 Nov 2002 22:56:29 +0000 (22:56 +0000)
Remember gdbm has its own locking so 't' does not work here - maybe a
warning is needed for that, too.

ext/dba/tests/dba_gdbm.phpt
ext/dba/tests/dba_handler.inc
ext/dba/tests/test.inc

index 79b41dadea9505772d74970a2aa50d6ac517f51a..11e267d6504680ab89ba94c58cde8931f1d4dd32 100644 (file)
@@ -9,6 +9,7 @@ DBA GDBM handler test
 <?php
        require_once('test.inc');
        $handler = 'gdbm';
+       $lock_flag = ''; // lock in library
        require_once('dba_handler.inc');
 ?>
 --EXPECT--
index acc8dd4e2a7f3e9ef25e7450fa38ad0ee8da0ffa..98048bb7c08eb405e350687e5a8415523bed5f19 100644 (file)
@@ -1,7 +1,7 @@
 <?php
        echo "database handler: $handler\n";
        @unlink($db_filename);
-       if (($db_file = @dba_open($db_filename, "nl", $handler))!==FALSE) {
+       if (($db_file = dba_open($db_filename, 'n'.$lock_flag, $handler))!==FALSE) {
                dba_insert("key1", "Content String 1", $db_file);
                dba_insert("key2", "Content String 2", $db_file);
                dba_insert("key3", "Third Content String", $db_file);
@@ -27,8 +27,8 @@
        } else {
                echo "Error creating database\n";
        }
-       $db_writer = @dba_open($db_filename, "wl", $handler);
-       if (($dba_reader = @dba_open($db_filename, "rlt", $handler))===false) {
+       $db_writer = dba_open($db_filename, 'w'.$lock_flag, $handler);
+       if (($dba_reader = dba_open($db_filename, 'r'.$lock_flag.($lock_flag ? 't' : ''), $handler))===false) {
                echo "Cannot read during write operation\n";
        } else {
                echo "Read during write permitted\n";
@@ -44,7 +44,7 @@
        } else {
                die("Error reopening database\n");
        }
-       if (($db_file = @dba_open($db_filename, "rd", $handler))!==FALSE) {
+       if (($db_file = dba_open($db_filename, 'r'.$lock_flag, $handler))!==FALSE) {
                $key = dba_firstkey($db_file);
                $res = array();
                while($key) {
index 0f920838cea938566c07f0f210183698b54703fc..bd617bc8d63619b5c978e6e65f5ff1e37b1d6ac0 100644 (file)
@@ -10,4 +10,5 @@
        } else {
                $handler = $handler[0];
        }
+       $lock_flag = 'l';
 ?>