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

Multi-threaded slapd on AIX 4.2.1



Hello!

Phew! I hope I finally post this message to the right group...
I have applied a few patches to the latest openldap "stable" release to
compile a multi-threaded slapd on AIX 4.2.1. Here they are :

1) Threads need a special setup on AIX 4.2.1 so the cc_r compiler must be
used instead of cc :
export CC=cc_r
./configure --my-options

2) By default, threads are created "detached" on AIX 4.2.1. To create them
"undetached" (or "joinable"), an explicit parameter must be passed to
pthread_create :

---- Original ldap_pvt_thread_create
int
ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
        int detach,
        void *(*start_routine)( void * ),
        void *arg)
{
        int rtn = pthread_create( thread, NULL, start_routine, arg );
 
        if( detach ) {
#ifdef HAVE_PTHREADS_FINAL
                pthread_detach( *thread );
#else
                pthread_detach( thread );
#endif
        }
        return rtn;
}
---- Patched ldap_pvt_thread_create
int
ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
        int detach,
        void *(*start_routine)( void * ),
        void *arg)
{
        pthread_attr_t attr;
        int rtn;
 
        rtn = pthread_attr_init(&attr);
        if ( rtn != 0 ) {
                return rtn;
        }
        rtn = pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_UNDETACHED);
        if ( rtn != 0 ) {
                return rtn;
        }
        rtn = pthread_create( thread, &attr, start_routine, arg );
        if ( rtn != 0 ) {
                return rtn;
        }
 
        if( detach ) {
#ifdef HAVE_PTHREADS_FINAL
                pthread_detach( *thread );
#else
                pthread_detach( thread );
#endif
        }
        return rtn;
}
---- END

Note that some #ifdef's should be set somewhere as the parameter that must
be given to pthread_attr_setdetachstate varies from system to system
(PTHREAD_CREATE_UNDETACHED becomes PTHREAD_CREATE_JOINABLE on Linux).

3) pthread_yield() returns void and not int on AIX 4.2.1 :

---- Original ldap_pvt_thread_yield
int
ldap_pvt_thread_yield( void )
{
#ifdef HAVE_SCHED_YIELD
        return sched_yield();
#elif HAVE_PTHREAD_YIELD
        return pthread_yield();
#elif HAVE_THR_YIELD
        return thr_yield();
#else
        return 0;
#endif
}
---- Patched ldap_pvt_thread_yield
int
ldap_pvt_thread_yield( void )
{
#ifdef HAVE_SCHED_YIELD
        return sched_yield();
#elif HAVE_PTHREAD_YIELD
        pthread_yield();
        return 0;
#elif HAVE_THR_YIELD
        return thr_yield();
#else
        return 0;
#endif
}
---- END

Again it might be wise to set some #ifdef's


The resulting slapd (with the gdbm backend) runs fine and gives a good
response time but is subject to huge memory leaks. The same server compiled
on a Linux box does not appear to grow (with the gdbm backend again).
Neither does the same server compiled on AIX without threads support. Can
anybody help?

Regards,

Frederic Poels.