]> granicus.if.org Git - php/commitdiff
fixes bug 7055 & 7235
authorDaniel Beulshausen <dbeu@php.net>
Mon, 16 Oct 2000 10:35:43 +0000 (10:35 +0000)
committerDaniel Beulshausen <dbeu@php.net>
Mon, 16 Oct 2000 10:35:43 +0000 (10:35 +0000)
ext/session/mod_files.c

index 70554a2b072b5c068eb8f256b4718498ab8c2e6f..061e0ca0caf21a8807d121656ac22d243cb27f47 100644 (file)
@@ -107,6 +107,14 @@ static char *ps_files_path_create(char *buf, size_t buflen, ps_files *data, cons
 #define O_BINARY 0
 #endif 
 
+static void ps_files_close(ps_files *data)
+{
+       if (data->fd != -1) {
+               close(data->fd);
+               data->fd = -1;
+       }
+}
+
 static void ps_files_open(ps_files *data, const char *key)
 {
        char buf[MAXPATHLEN];
@@ -116,10 +124,8 @@ static void ps_files_open(ps_files *data, const char *key)
                        efree(data->lastkey);
                        data->lastkey = NULL;
                }
-               if (data->fd != -1) {
-                       close(data->fd);
-                       data->fd = -1;
-               }
+
+       ps_files_close(data);
                
                if (!ps_files_valid_key(key) || 
                                !ps_files_path_create(buf, sizeof(buf), data, key))
@@ -209,8 +215,8 @@ PS_CLOSE_FUNC(files)
 {
        PS_FILES_DATA;
 
-       if (data->fd > -1) 
-               close(data->fd);
+       ps_files_close(data);
+
        if (data->lastkey) 
                efree(data->lastkey);
        efree(data->basedir);
@@ -273,6 +279,8 @@ PS_DESTROY_FUNC(files)
        if (!ps_files_path_create(buf, sizeof(buf), data, key))
                return FAILURE;
        
+       ps_files_close(data);
+       
        if (V_UNLINK(buf) == -1) {
                return FAILURE;
        }