]> git.sur5r.net Git - openldap/commitdiff
Replace sched_yield(2) on Linux with select(2) (ITS#3950)
authorKurt Zeilenga <kurt@openldap.org>
Fri, 6 Jan 2006 19:47:59 +0000 (19:47 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 6 Jan 2006 19:47:59 +0000 (19:47 +0000)
CHANGES
configure
configure.in
include/portable.hin
libraries/libldap_r/thr_posix.c

diff --git a/CHANGES b/CHANGES
index 3e54c35d1341ea6de4cc8c20be4ba09d2d9c7f7f..679e46e4ca7e8d458b337e6d03a37809f4778316 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
 OpenLDAP 2.3 Change Log
 
 OpenLDAP 2.3.16 Engineering
+       Build environment
+               Replace sched_yield(2) on Linux with select(2) (ITS#3950)
 
 OpenLDAP 2.3.15 Release
        Fixed slapd strerror logging bug (ITS#4292)
index 57c920c4d5bcb7d65d58cde15e54487a04b6cf42..91164f73c415828131b50d7132de6f7722e14e9e 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in OpenLDAP: pkg/ldap/configure.in,v 1.560.2.18 2005/11/26 17:01:54 kurt Exp .
+# From configure.in OpenLDAP: pkg/ldap/configure.in,v 1.560.2.20 2006/01/03 22:16:00 kurt Exp .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59.
 #
@@ -24740,6 +24740,21 @@ echo "${ECHO_T}$ol_cv_pthread_create_works" >&6
                                { { echo "$as_me:$LINENO: error: pthread_create is not usable, check environment settings" >&5
 echo "$as_me: error: pthread_create is not usable, check environment settings" >&2;}
    { (exit 1); exit 1; }; }
+                       fi
+
+                       ol_replace_broken_yield=no
+                       case "$target" in
+                       *-*-linux*)
+                               ol_replace_broken_yield=yes
+                       ;;
+                       esac
+
+                       if test $ol_replace_broken_yield = yes ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define REPLACE_BROKEN_YIELD 1
+_ACEOF
+
                        fi
 
                                                if test $ol_with_yielding_select = auto ; then
@@ -42898,7 +42913,6 @@ fi
 
 
 
-
 
 
 for ac_func in \
@@ -42950,7 +42964,6 @@ for ac_func in \
        strtoll                 \
        strspn                  \
        sysconf                 \
-       usleep                  \
        waitpid                 \
        wait4                   \
        write                   \
index 3192c2587387f23f2d1ae9fbb0492064f4ecf34c..728040b4995a452d9c5a6d3a8931b3c6d9f12e16 100644 (file)
@@ -1585,6 +1585,18 @@ dnl                      [ol_cv_pthread_lpthread_lexc])
                                AC_MSG_ERROR([pthread_create is not usable, check environment settings])
                        fi
 
+                       ol_replace_broken_yield=no
+                       case "$target" in
+                       *-*-linux*) 
+                               ol_replace_broken_yield=yes
+                       ;;
+                       esac
+
+                       if test $ol_replace_broken_yield = yes ; then
+                               AC_DEFINE([REPLACE_BROKEN_YIELD],1,
+                                       [define if sched_yield yields the entire process])
+                       fi
+
                        dnl Check if select causes an yield
                        if test $ol_with_yielding_select = auto ; then
                                AC_CACHE_CHECK([if select yields when using pthreads],
@@ -2564,7 +2576,6 @@ AC_CHECK_FUNCS(           \
        strtoll                 \
        strspn                  \
        sysconf                 \
-       usleep                  \
        waitpid                 \
        wait4                   \
        write                   \
index 69ce9a7cae530dbe2db0a31309fac2b3ecc2d3de..d1576801b671b13f83cfbefef3bf7c819a24e6d5 100644 (file)
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
-/* Define to 1 if you have the `usleep' function. */
-#undef HAVE_USLEEP
-
 /* Define to 1 if you have the <utime.h> header file. */
 #undef HAVE_UTIME_H
 
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
+/* define if sched_yield yields the entire process */
+#undef REPLACE_BROKEN_YIELD
+
 /* Define as the return type of signal handlers (`int' or `void'). */
 #undef RETSIGTYPE
 
index 2a05236399b3df2c4a324dcb243abf778c94b9fa..c867e5715bebe9a895b2d8f2c9fb8d23c814c877 100644 (file)
 
 #include <ac/errno.h>
 
+#ifdef REPLACE_BROKEN_YIELD
+#ifndef HAVE_NANOSLEEP
+#include <ac/socket.h>
+#endif
+#include <ac/time.h>
+#endif
+
 #include "ldap_pvt_thread.h" /* Get the thread interface */
 #define LDAP_THREAD_IMPLEMENTATION
 #define LDAP_THREAD_RDWR_IMPLEMENTATION
@@ -207,7 +214,16 @@ ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
 int 
 ldap_pvt_thread_yield( void )
 {
-#if HAVE_THR_YIELD
+#ifdef REPLACE_BROKEN_YIELD
+#ifdef HAVE_NANOSLEEP
+       struct timespec t = { 0, 0 };
+       nanosleep(&t, NULL);
+#else
+       struct timeval tv = {0,0};
+       select( 0, NULL, NULL, NULL, &tv );
+#endif
+       return 0;
+#elif HAVE_THR_YIELD
        return thr_yield();
 
 #elif HAVE_PTHREADS == 10