diff options
| author | Marcus Boerger <helly@php.net> | 2002-12-10 22:02:52 +0000 |
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2002-12-10 22:02:52 +0000 |
| commit | 17117063cedb3c2a1e81e643922a92994986b5ac (patch) | |
| tree | b00da586feba519bec01c9cda59f7b1b178e8316 /ext/dba/dba.c | |
| parent | dbf4bcc08bc9ab9cf3d0dfbde2816d006e875439 (diff) | |
| download | php-git-17117063cedb3c2a1e81e643922a92994986b5ac.tar.gz | |
-remove second attempt to close lock file
-default to lock on db file instead on .lck file.
-try to use existing .lck file and only create it on failure (allows ro access)
Diffstat (limited to 'ext/dba/dba.c')
| -rw-r--r-- | ext/dba/dba.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 36a05203de..743611e27b 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -219,7 +219,7 @@ static void dba_close(dba_info *info TSRMLS_DC) 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); @@ -444,6 +444,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent) } } else { lock_flag = (hptr->flags&DBA_LOCK_ALL); + lock_dbf = 1; } switch (*pmode++) { case 'r': @@ -530,9 +531,14 @@ 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 = "a+b"; + lock_file_mode = "rb"; } 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"; + 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 */ @@ -801,4 +807,3 @@ PHP_FUNCTION(dba_list) * vim600: sw=4 ts=4 fdm=marker * vim<600: sw=4 ts=4 */ - |
