Browse Source

The pread/pwrite macros check for a bug in the Linux glibc now.

The bug causes the kernel not to return -1/EAGAIN. The new test case
has been borrowed from the Linux Test Project.

This also fixes a bug which apparently caused HAVE_PREAD/WRITE to be
defined even if the more complex checks failed (ac_cv_func_NAME=no
was set albeit with no difference).
migration/unlabaled-1.1.2
Sascha Schumann 24 years ago
parent
commit
e1dd35bddb
  1. 41
      acinclude.m4
  2. 1
      ext/session/config.m4
  3. 4
      ext/session/mod_files.c

41
acinclude.m4

@ -381,7 +381,16 @@ AC_DEFUN(PHP_DOES_PWRITE_WORK,[
#include <fcntl.h>
#include <unistd.h>
$1
main() { return !(pwrite(open("conftest_in", O_WRONLY|O_CREAT, 0600), "hi", 2, 0) == 2); }
main() {
int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600);
if (fd < 0) exit(1);
if (pwrite(fd, "text", 4, 0) != 4) exit(1);
/* Linux glibc breakage until 2.2.5 */
if (pwrite(fd, "text", 4, -1) != -1) exit(1);
exit(0);
}
],[
ac_cv_pwrite=yes
],[
@ -399,7 +408,15 @@ AC_DEFUN(PHP_DOES_PREAD_WORK,[
#include <fcntl.h>
#include <unistd.h>
$1
main() { char buf[3]; return !(pread(open("conftest_in", O_RDONLY), buf, 2, 0) == 2); }
main() {
char buf[3];
int fd = open("conftest_in", O_RDONLY);
if (fd < 0) exit(1);
if (pread(fd, buf, 2, 0) != 2) exit(1);
/* Linux glibc breakage until 2.2.5 */
if (pread(fd, buf, 2, -1) != -1) exit(1);
exit(0);
}
],[
ac_cv_pread=yes
],[
@ -421,10 +438,12 @@ AC_DEFUN(PHP_PWRITE_TEST,[
fi
])
case $ac_cv_pwrite in
no) ac_cv_func_pwrite=no;;
64) AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default]);;
esac
if test "$ac_cv_pwrite" != "no"; then
AC_DEFINE(HAVE_PWRITE, 1, [ ])
if test "$ac_cv_pwrite" = "64"; then
AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default])
fi
fi
])
AC_DEFUN(PHP_PREAD_TEST,[
@ -438,10 +457,12 @@ AC_DEFUN(PHP_PREAD_TEST,[
fi
])
case $ac_cv_pread in
no) ac_cv_func_pread=no;;
64) AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default]);;
esac
if test "$ac_cv_pread" != "no"; then
AC_DEFINE(HAVE_PREAD, 1, [ ])
if test "$ac_cv_pread" = "64"; then
AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default])
fi
fi
])
AC_DEFUN(PHP_MISSING_TIME_R_DECL,[

1
ext/session/config.m4

@ -9,7 +9,6 @@ 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)

4
ext/session/mod_files.c

@ -271,7 +271,7 @@ PS_READ_FUNC(files)
data->st_size = *vallen = sbuf.st_size;
*val = emalloc(sbuf.st_size);
#if defined(HAVE_WORKING_PREAD_TEST) && defined(HAVE_PREAD)
#if defined(HAVE_PREAD)
n = pread(data->fd, *val, sbuf.st_size, 0);
#else
lseek(data->fd, 0, SEEK_SET);
@ -307,7 +307,7 @@ PS_WRITE_FUNC(files)
if (vallen < (int)data->st_size)
ftruncate(data->fd, 0);
#if defined(HAVE_WORKING_PWRITE_TEST) && defined(HAVE_PWRITE)
#if defined(HAVE_PWRITE)
n = pwrite(data->fd, val, vallen, 0);
#else
lseek(data->fd, 0, SEEK_SET);

Loading…
Cancel
Save