helly Tue Dec 10 17:49:33 2002 EDT
Modified files:
/php4/ext/dba dba.c
Log:
LOCK_EX is not allowed in read mode -> try using existing .lck file in read
only mode only when in read mode.
Index: php4/ext/dba/dba.c
diff -u php4/ext/dba/dba.c:1.68 php4/ext/dba/dba.c:1.69
--- php4/ext/dba/dba.c:1.68 Tue Dec 10 17:02:52 2002
+++ php4/ext/dba/dba.c Tue Dec 10 17:49:33 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba.c,v 1.68 2002/12/10 22:02:52 helly Exp $ */
+/* $Id: dba.c,v 1.69 2002/12/10 22:49:33 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -531,12 +531,18 @@
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) {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php