From: Marcus Boerger Date: Thu, 12 Jun 2003 19:55:16 +0000 (+0000) Subject: MFH: Bugfix #2397: dba_open locking error with db3 X-Git-Tag: php-4.3.3RC1~55 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4cc45a7ba96e16868be3cd9e62b2c54e350c9071;p=php MFH: Bugfix #2397: dba_open locking error with db3 --- diff --git a/ext/dba/dba.c b/ext/dba/dba.c index c23a18029c..c8b8e17e00 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -642,15 +642,20 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) lock_mode = (lock_flag & DBA_LOCK_WRITER) ? LOCK_EX : 0; file_mode = "r+b"; break; - case 'n': - modenr = DBA_TRUNC; - lock_mode = (lock_flag & DBA_LOCK_TRUNC) ? LOCK_EX : 0; - file_mode = "w+b"; - break; case 'c': modenr = DBA_CREAT; lock_mode = (lock_flag & DBA_LOCK_CREAT) ? LOCK_EX : 0; file_mode = "a+b"; + if (!lock_mode || !lock_dbf) { + break; + } + /* When we lock the db file it will be created before the handler + * even tries to open it, hence we must change to truncate mode. + */ + case 'n': + modenr = DBA_TRUNC; + lock_mode = (lock_flag & DBA_LOCK_TRUNC) ? LOCK_EX : 0; + file_mode = "w+b"; break; default: modenr = 0;