cvs: php4 / acinclude.m4 /ext/session config.m4 mod_files.c
| From: | Sascha Schumann | Date: | Fri, 06 Sep 2002 10:27:26 +0000 |
| Subject: | cvs: php4 / acinclude.m4 /ext/session config.m4 mod_files.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-13880@lists.php.net to get a copy of this message | ||
sas Fri Sep 6 06:27:26 2002 EDT
Modified files:
/php4 acinclude.m4
/php4/ext/session config.m4 mod_files.c
Log:
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.
Index: php4/acinclude.m4
diff -u php4/acinclude.m4:1.204 php4/acinclude.m4:1.205
--- php4/acinclude.m4:1.204 Wed Sep 4 14:47:20 2002
+++ php4/acinclude.m4 Fri Sep 6 06:27:26 2002
@@ -1,4 +1,4 @@
-dnl $Id: acinclude.m4,v 1.204 2002/09/04 18:47:20 sniper Exp $
+dnl $Id: acinclude.m4,v 1.205 2002/09/06 10:27:26 sas Exp $
dnl
dnl This file contains local autoconf functions.
@@ -374,77 +374,73 @@
rm -fr conftest*
])
-AC_DEFUN(PHP_MISSING_PREAD_DECL,[
- AC_CACHE_CHECK(whether pread works without custom declaration,ac_cv_pread,[
- AC_TRY_COMPILE([#include <unistd.h>],[size_t (*func)() = pread],[
- ac_cv_pread=yes
- ],[
- echo test > conftest_in
- AC_TRY_RUN([
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
- main() { char buf[3]; return !(pread(open("conftest_in", O_RDONLY), buf, 2, 0) ==
2); }
- ],[
- ac_cv_pread=yes
- ],[
- echo test > conftest_in
- AC_TRY_RUN([
+AC_DEFUN(PHP_DOES_PWRITE_WORK,[
+ AC_TRY_RUN([
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
- ssize_t pread(int, void *, size_t, off64_t);
- main() { char buf[3]; return !(pread(open("conftest_in", O_RDONLY), buf, 2, 0) ==
2); }
- ],[
- ac_cv_pread=64
- ],[
- ac_cv_pread=no
- ])
- ],[
- ac_cv_pread=no
- ])
- ])
+$1
+ main() { return !(pwrite(open("conftest_in", O_WRONLY|O_CREAT, 0600), "hi",
2, 0) == 2); }
+ ],[
+ ac_cv_pwrite=yes
+ ],[
+ ac_cv_pwrite=no
+ ],[
+ ac_cv_pwrite=no
])
- case $ac_cv_pread in
- no) ac_cv_func_pread=no;;
- 64) AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default]);;
- esac
])
-AC_DEFUN(PHP_MISSING_PWRITE_DECL,[
- AC_CACHE_CHECK(whether pwrite works without custom declaration,ac_cv_pwrite,[
- AC_TRY_COMPILE([#include <unistd.h>],[size_t (*func)() = pwrite],[
- ac_cv_pwrite=yes
- ],[
- AC_TRY_RUN([
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
- main() { return !(pwrite(open("conftest_out", O_WRONLY|O_CREAT, 0600),
"Ok", 2, 0) == 2); }
- ],[
- ac_cv_pwrite=yes
- ],[
- AC_TRY_RUN([
+AC_DEFUN(PHP_DOES_PREAD_WORK,[
+ echo test > conftest_in
+ AC_TRY_RUN([
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
- ssize_t pwrite(int, void *, size_t, off64_t);
- main() { return !(pwrite(open("conftest_out", O_WRONLY|O_CREAT, 0600),
"Ok", 2, 0) == 2); }
- ],[
- ac_cv_pwrite=64
- ],[
- ac_cv_pwrite=no
- ])
- ],[
- ac_cv_pwrite=no
- ])
+$1
+ main() { char buf[3]; return !(pread(open("conftest_in", O_RDONLY), buf, 2, 0) == 2);
}
+ ],[
+ ac_cv_pread=yes
+ ],[
+ ac_cv_pread=no
+ ],[
+ ac_cv_pread=no
])
+ rm -f conftest_in
+])
+
+AC_DEFUN(PHP_PWRITE_TEST,[
+ AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[
+ PHP_DOES_PWRITE_WORK
+ if test "$ac_cv_pwrite" = "no"; then
+ PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);])
+ if test "$ac_cv_pwrite" = "yes"; then
+ ac_cv_pwrite=64
+ fi
+ fi
])
+
case $ac_cv_pwrite in
no) ac_cv_func_pwrite=no;;
64) AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default]);;
+ esac
+])
+
+AC_DEFUN(PHP_PREAD_TEST,[
+ AC_CACHE_CHECK(whether pread works,ac_cv_pread,[
+ PHP_DOES_PREAD_WORK
+ if test "$ac_cv_pread" = "no"; then
+ PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);])
+ if test "$ac_cv_pread" = "yes"; then
+ ac_cv_pread=64
+ fi
+ fi
+ ])
+
+ case $ac_cv_pread in
+ no) ac_cv_func_pread=no;;
+ 64) AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default]);;
esac
])
Index: php4/ext/session/config.m4
diff -u php4/ext/session/config.m4:1.21 php4/ext/session/config.m4:1.22
--- php4/ext/session/config.m4:1.21 Wed Sep 4 14:47:24 2002
+++ php4/ext/session/config.m4 Fri Sep 6 06:27:26 2002
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.21 2002/09/04 18:47:24 sniper Exp $
+dnl $Id: config.m4,v 1.22 2002/09/06 10:27:26 sas Exp $
dnl
PHP_ARG_ENABLE(session, whether to enable PHP sessions,
@@ -9,6 +9,9 @@
[ --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,[ ])
Index: php4/ext/session/mod_files.c
diff -u php4/ext/session/mod_files.c:1.78 php4/ext/session/mod_files.c:1.79
--- php4/ext/session/mod_files.c:1.78 Wed Sep 4 09:51:08 2002
+++ php4/ext/session/mod_files.c Fri Sep 6 06:27:26 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mod_files.c,v 1.78 2002/09/04 13:51:08 kalowsky Exp $ */
+/* $Id: mod_files.c,v 1.79 2002/09/06 10:27:26 sas Exp $ */
#include "php.h"
@@ -267,8 +267,13 @@
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 @@
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);