cvs: /php4/ext/session mod_files.c
| From: | Sascha Schumann | Date: | Fri, 03 Dec 1999 16:20:09 +0000 |
| Subject: | cvs: /php4/ext/session mod_files.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-7340@lists.php.net to get a copy of this message | ||
sas Fri Dec 3 11:20:09 1999 EDT
Modified files:
/php4/ext/session mod_files.c
Log:
Improve locking when O_EXCL is available
Index: php4/ext/session/mod_files.c
diff -u php4/ext/session/mod_files.c:1.18 php4/ext/session/mod_files.c:1.19
--- php4/ext/session/mod_files.c:1.18 Thu Oct 21 14:51:57 1999
+++ php4/ext/session/mod_files.c Fri Dec 3 11:19:38 1999
@@ -131,11 +131,13 @@
data->lastkey = estrdup(key);
#ifdef O_EXCL
- /* in the common case, the file already exists */
- data->fd = open(buf, O_EXCL | O_RDWR);
- if(data->fd == -1) {
- /* create it, if necessary */
- data->fd = open(buf, O_EXCL | O_RDWR | O_CREAT, 0600);
+ data->fd = open(buf, O_RDWR);
+ if (data->fd == -1) {
+ if (errno == ENOENT) {
+ data->fd = open(buf, O_EXCL | O_RDWR | O_CREAT, 0600);
+ }
+ } else {
+ flock(data->fd, LOCK_EX);
}
#else
data->fd = open(buf, O_CREAT | O_RDWR, 0600);