]> granicus.if.org Git - php/commitdiff
Use stream locking support
authorMarcus Boerger <helly@php.net>
Tue, 4 Mar 2003 23:45:48 +0000 (23:45 +0000)
committerMarcus Boerger <helly@php.net>
Tue, 4 Mar 2003 23:45:48 +0000 (23:45 +0000)
# needs more testing

ext/dba/dba.c
ext/dba/php_dba.h

index f897667982d7435b086a1769182dd4cc241613a9..583eba9c97262dec564cbe4dbea0a04a457b0ff7 100644 (file)
@@ -28,7 +28,6 @@
 #if HAVE_DBA
 
 #include "php_ini.h"
-#include "ext/standard/flock_compat.h" 
 #include <stdio.h> 
 #include <fcntl.h>
 #ifdef HAVE_SYS_FILE_H
@@ -319,11 +318,6 @@ static void dba_close(dba_info *info TSRMLS_DC)
        if (info->hnd) info->hnd->close(info TSRMLS_CC);
        if (info->path) pefree(info->path, info->flags&DBA_PERSISTENT);
        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);*/
-               info->lock.fd = 0;
-       }
        if (info->lock.fp) php_stream_close(info->lock.fp);
        if (info->lock.name) pefree(info->lock.name, info->flags&DBA_PERSISTENT);
        pefree(info, info->flags&DBA_PERSISTENT);
@@ -707,13 +701,10 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                        FREENOW;
                        RETURN_FALSE;
                }
-               if (php_stream_cast(info->lock.fp, PHP_STREAM_AS_FD, (void*)&info->lock.fd, 1) == FAILURE)      {
-                       dba_close(info TSRMLS_CC);
-                       /* stream operation already wrote an error message */
-                       FREENOW;
-                       RETURN_FALSE;
+               if (!php_stream_supports_lock(info->lock.fp)) {
+                       error = "Stream does not support locking";
                }
-               if (php_flock(info->lock.fd, lock_mode)) {
+               if (php_stream_lock(info->lock.fp, lock_mode)) {
                        error = "Unable to establish lock"; /* force failure exit */
                }
        }
index 18ace81984bf280d49f21651f4799d7b40fb81cc..1133de6bc9cfb5e9e77ae86f8c8f3989cf5e0e0e 100644 (file)
@@ -33,7 +33,6 @@ typedef enum {
 
 typedef struct dba_lock {
        php_stream *fp;
-       int fd;
        char *name;
        int mode; /* LOCK_EX,LOCK_SH */
 } dba_lock;