helly           Tue Dec 10 18:03:25 2002 EDT

  Modified files:              (Branch: PHP_4_3)
    /php4/ext/dba       dba.c 
  Log:
  MFH
  
  
Index: php4/ext/dba/dba.c
diff -u php4/ext/dba/dba.c:1.61.2.4 php4/ext/dba/dba.c:1.61.2.5
--- php4/ext/dba/dba.c:1.61.2.4 Mon Dec  9 13:07:23 2002
+++ php4/ext/dba/dba.c  Tue Dec 10 18:03:24 2002
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dba.c,v 1.61.2.4 2002/12/09 18:07:23 helly Exp $ */
+/* $Id: dba.c,v 1.61.2.5 2002/12/10 23:03:24 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -215,7 +215,7 @@
        if (info->fp && info->fp!=info->lock.fp) php_stream_close(info->fp);
        if (info->lock.fd) {
                php_flock(info->lock.fd, LOCK_UN);
-               close(info->lock.fd);
+               /*close(info->lock.fd);*/
                info->lock.fd = 0;
        }
        if (info->lock.fp) php_stream_close(info->lock.fp);
@@ -417,6 +417,7 @@
         *
         * d: force lock on database file
         * l: force lock on lck file
+        * -: ignore locking
         *
         * t: test open database, warning if locked
         */
@@ -440,6 +441,7 @@
                }
        } else {
                lock_flag = (hptr->flags&DBA_LOCK_ALL);
+               lock_dbf = 1;
        }
        switch (*pmode++) {
                case 'r': 
@@ -526,9 +528,20 @@
                        lock_file_mode = file_mode;
                } else {
                        spprintf(&info->lock.name, 0, "%s.lck", info->path);
+                       if (!strcmp(file_mode, "r")) {
+                               /* when in read only mode try to use existing .lck 
+file first */
+                               /* do not log errors for .lck file while in read ony 
+mode on .lck file */
+                       lock_file_mode = "rb";
+                               info->lock.fp = 
+php_stream_open_wrapper(info->lock.name, lock_file_mode, 
+STREAM_MUST_SEEK|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL);
+               }
+                       if (!info->lock.fp) {
+                               /* when not in read mode or failed to open .lck file 
+read only. now try again in create(write) mode and log errors */
                        lock_file_mode = "a+b";
+                       }
+               }
+               if (!info->lock.fp) {
+                       info->lock.fp = php_stream_open_wrapper(info->lock.name, 
+lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL);
                }
-               info->lock.fp = php_stream_open_wrapper(info->lock.name, 
lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL);
                if (!info->lock.fp) {
                        dba_close(info TSRMLS_CC);
                        /* stream operation already wrote an error message */
@@ -797,4 +810,3 @@
  * vim600: sw=4 ts=4 fdm=marker
  * vim<600: sw=4 ts=4
  */
-



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to