]> granicus.if.org Git - php/commitdiff
The pread/pwrite macros check for a bug in the Linux glibc now.
authorSascha Schumann <sas@php.net>
Wed, 2 Oct 2002 06:05:16 +0000 (06:05 +0000)
committerSascha Schumann <sas@php.net>
Wed, 2 Oct 2002 06:05:16 +0000 (06:05 +0000)
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).

acinclude.m4
ext/session/config.m4
ext/session/mod_files.c

index 4b3221c63758dc27d49383efc4fd4f09a25775bd..3926bd08bf70364557e5c65ab5b9b9087492d85e 100644 (file)
@@ -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,[
index 8bb43b676b11575a1596f7c1cd5ea8600b931ba5..4e5a4ddd2c1ee66b1397376e9577af88330145dc 100644 (file)
@@ -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)
index 1a784e8b1efe2ff7c1efb01be0252b026f9b4d8f..541adbea91fff6eaa42368d3e45265f58f41d8c3 100644 (file)
@@ -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);