sas             Wed Oct  2 02:05:16 2002 EDT

  Modified files:              
    /php4       acinclude.m4 
    /php4/ext/session   config.m4 mod_files.c 
  Log:
  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).
  
  
Index: php4/acinclude.m4
diff -u php4/acinclude.m4:1.207 php4/acinclude.m4:1.208
--- php4/acinclude.m4:1.207     Sun Sep 29 20:03:09 2002
+++ php4/acinclude.m4   Wed Oct  2 02:05:15 2002
@@ -1,4 +1,4 @@
-dnl $Id: acinclude.m4,v 1.207 2002/09/30 00:03:09 sas Exp $
+dnl $Id: acinclude.m4,v 1.208 2002/10/02 06:05:15 sas Exp $
 dnl
 dnl This file contains local autoconf functions.
 
@@ -381,7 +381,16 @@
 #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 @@
 #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 @@
     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 @@
     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: php4/ext/session/config.m4
diff -u php4/ext/session/config.m4:1.22 php4/ext/session/config.m4:1.23
--- php4/ext/session/config.m4:1.22     Fri Sep  6 06:27:26 2002
+++ php4/ext/session/config.m4  Wed Oct  2 02:05:16 2002
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4,v 1.22 2002/09/06 10:27:26 sas Exp $
+dnl $Id: config.m4,v 1.23 2002/10/02 06:05:16 sas Exp $
 dnl
 
 PHP_ARG_ENABLE(session, whether to enable PHP sessions,
@@ -9,7 +9,6 @@
 [  --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: php4/ext/session/mod_files.c
diff -u php4/ext/session/mod_files.c:1.82 php4/ext/session/mod_files.c:1.83
--- php4/ext/session/mod_files.c:1.82   Tue Oct  1 15:19:10 2002
+++ php4/ext/session/mod_files.c        Wed Oct  2 02:05:16 2002
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mod_files.c,v 1.82 2002/10/01 19:19:10 sas Exp $ */
+/* $Id: mod_files.c,v 1.83 2002/10/02 06:05:16 sas Exp $ */
 
 #include "php.h"
 
@@ -271,7 +271,7 @@
        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 @@
        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);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to