summaryrefslogtreecommitdiff
path: root/ext/session/mod_files.c
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2002-09-06 10:27:26 +0000
committerSascha Schumann <sas@php.net>2002-09-06 10:27:26 +0000
commit702d7afc3cbc8599ca8113c223079d57dfec939a (patch)
tree024cc6160d68b5fc415a2f0b2eecb88fa91f952e /ext/session/mod_files.c
parent8f14aafe97639984022364afc544565a052ba399 (diff)
downloadphp-git-702d7afc3cbc8599ca8113c223079d57dfec939a.tar.gz
Reenable pwrite/pread support
The old checks supposed that pread/pwrite worked, if a declaration was found in <unistd.h>. We now actually check whether they work successfully before using them.
Diffstat (limited to 'ext/session/mod_files.c')
-rw-r--r--ext/session/mod_files.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index 2fce69d792..52dddadc6d 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -267,8 +267,13 @@ PS_READ_FUNC(files)
data->st_size = *vallen = sbuf.st_size;
*val = emalloc(sbuf.st_size);
+#ifdef HAVE_PREAD
+ n = pread(data->fd, *val, sbuf.st_size, 0);
+#else
lseek(data->fd, 0, SEEK_SET);
n = read(data->fd, *val, sbuf.st_size);
+#endif
+
if (n != sbuf.st_size) {
efree(*val);
return FAILURE;
@@ -294,8 +299,12 @@ PS_WRITE_FUNC(files)
if (vallen < (int)data->st_size)
ftruncate(data->fd, 0);
+#ifdef HAVE_PWRITE
+ n = pwrite(data->fd, val, vallen, 0);
+#else
lseek(data->fd, 0, SEEK_SET);
n = write(data->fd, val, vallen);
+#endif
if (n != vallen) {
php_error(E_WARNING, "write failed: %s (%d)", strerror(errno), errno);