summaryrefslogtreecommitdiff
path: root/ext/session/mod_files.c
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>1999-08-22 13:43:23 +0000
committerSascha Schumann <sas@php.net>1999-08-22 13:43:23 +0000
commit02d6ec2a6be6eb0ed297e92f8472f560ca572d3c (patch)
tree3edd27be663bbb034a3110cddd75402572894ba4 /ext/session/mod_files.c
parent070dfe0833ff2f26539907e564bc228b4cab5510 (diff)
downloadphp-git-02d6ec2a6be6eb0ed297e92f8472f560ca572d3c.tar.gz
Use O_EXCL where possible.
Diffstat (limited to 'ext/session/mod_files.c')
-rw-r--r--ext/session/mod_files.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index 50679dae8f..65a91792cf 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -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
}
}