summaryrefslogtreecommitdiff
path: root/ext
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
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')
-rw-r--r--ext/session/config.m43
-rw-r--r--ext/session/mod_files.c9
2 files changed, 12 insertions, 0 deletions
diff --git a/ext/session/config.m4 b/ext/session/config.m4
index ddb92441ed..8bb43b676b 100644
--- a/ext/session/config.m4
+++ b/ext/session/config.m4
@@ -9,6 +9,9 @@ PHP_ARG_WITH(mm,for mm support,
[ --with-mm[=DIR] Include mm support for session storage], no, no)
if test "$PHP_SESSION" != "no"; then
+ AC_CHECK_FUNCS(pread pwrite)
+ PHP_PWRITE_TEST
+ PHP_PREAD_TEST
PHP_NEW_EXTENSION(session, session.c mod_files.c mod_mm.c mod_user.c, $ext_shared)
PHP_SUBST(SESSION_SHARED_LIBADD)
AC_DEFINE(HAVE_PHP_SESSION,1,[ ])
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);