summaryrefslogtreecommitdiff
path: root/ext/dba/dba.c
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2002-12-10 22:49:33 +0000
committerMarcus Boerger <helly@php.net>2002-12-10 22:49:33 +0000
commitb94e0d9eacfca8413ec32f59fd2759cfbc8cbd7f (patch)
treeb999f407fa14dc234fbc288f25851a78b78e150e /ext/dba/dba.c
parentac8469bd559b2218ba1e0aaab4ee89a2d7c70a55 (diff)
downloadphp-git-b94e0d9eacfca8413ec32f59fd2759cfbc8cbd7f.tar.gz
LOCK_EX is not allowed in read mode -> try using existing .lck file in read
only mode only when in read mode.
Diffstat (limited to 'ext/dba/dba.c')
-rw-r--r--ext/dba/dba.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/ext/dba/dba.c b/ext/dba/dba.c
index 743611e27b..a229b8195c 100644
--- a/ext/dba/dba.c
+++ b/ext/dba/dba.c
@@ -531,12 +531,18 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
lock_file_mode = file_mode;
} else {
spprintf(&info->lock.name, 0, "%s.lck", info->path);
- lock_file_mode = "rb";
+ 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";
+ }
}
- 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 && !lock_dbf) {
- /* when using a .lck file and that could not be opened we try to create one */
- 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);
}
if (!info->lock.fp) {