[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#3950) sched_yield() considered harmful



Howard Chu wrote:

> Try this patch for libldap_r/thr_posix.c; recompile libldap_r and relink
> slapd...

IT WORKS!  Everything is blazingly fast again, thank you!

I've attached this patch to the RedHat bug I had opened.

> 
> RCS file: /repo/OpenLDAP/pkg/ldap/libraries/libldap_r/thr_posix.c,v
> retrieving revision 1.40
> diff -u -r1.40 thr_posix.c
> --- thr_posix.c 17 Sep 2005 21:28:08 -0000      1.40
> +++ thr_posix.c 25 Nov 2005 20:07:23 -0000
> @@ -20,6 +20,11 @@
> 
> #include <ac/errno.h>
> 
> +#if defined( HAVE_YIELDING_SELECT )
> +#include <ac/socket.h>
> +#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 +212,11 @@
> int
> ldap_pvt_thread_yield( void )
> {
> -#if HAVE_THR_YIELD
> +#if HAVE_YIELDING_SELECT
> +       struct timeval tv = {0,0};
> +       select( 0, NULL, NULL, NULL, &tv );
> +       return 0;
> +#elif HAVE_THR_YIELD
>        return thr_yield();
> 
> #elif HAVE_PTHREADS == 10
> 
> 
> 
> 

-- 
  // Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/  http://www.develer.com/