]> granicus.if.org Git - php/commitdiff
Use O_EXCL where possible.
authorSascha Schumann <sas@php.net>
Sun, 22 Aug 1999 13:43:23 +0000 (13:43 +0000)
committerSascha Schumann <sas@php.net>
Sun, 22 Aug 1999 13:43:23 +0000 (13:43 +0000)
ext/session/mod_files.c

index 50679dae8ff61116f81c885eba0b4c17c1a606af..65a91792cf9be253e995aa2b4a19aecb345aeccf 100644 (file)
@@ -110,10 +110,18 @@ static void _ps_files_open(ps_files *data, const char *key)
                
                data->lastkey = estrdup(key);
                
+#ifdef O_EXCL
+               data->fd = open(buf, O_EXCL | O_RDWR | O_CREAT, 0600);
+               /* -1, if file exists and access failed due to O_EXCL|O_CREAT */
+               if(data->fd == -1) {
+                       data->fd = open(buf, O_EXCL | O_RDWR);
+               }
+#else
                data->fd = open(buf, O_CREAT | O_RDWR, 0600);
-               if(data->fd > -1) {
+               if(data->fd != -1) {
                        flock(data->fd, LOCK_EX);
                }
+#endif
        }
 }