From: Marcus Boerger Date: Thu, 12 Jun 2003 19:53:40 +0000 (+0000) Subject: Bugfix #2397: dba_open locking error with db3 X-Git-Tag: RELEASE_1_0_2~298 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=48cc4a7be62173ae982e68349242966bb92a0544;p=php Bugfix #2397: dba_open locking error with db3 --- diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 7f0121c267..9eb92ac1da 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -636,15 +636,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;