#include <termios.h>
#endif /* defined( NeXT ) || defined( ultrix ) etc. */
#endif /* !DOS */
-#if defined( aix ) || defined( __NetBSD__ )
+#if defined( aix ) || defined( __NetBSD__ ) \
+ || defined( __FreeBSD__ ) || defined( linux )
#include <sys/ioctl.h>
#endif /* aix || __NetBSD__ */
#include <ctype.h>
#define pthread_attr_setdetachstate( a, b ) \
pthread_attr_setdetach_np( a, b )
+#else /* end dce pthreads */
+
+#if defined( POSIX_THREADS )
+
+#define _THREAD
+
+#include <pthread.h>
+
+#define pthread_mutexattr_default NULL
+#define pthread_condattr_default NULL
+
+#endif /* posix threads */
#endif /* dce pthreads */
#endif /* mit pthreads */
#endif /* sunos5 */
* Are sys_errlist and sys_nerr declared in stdio.h?
*/
#ifndef SYSERRLIST_IN_STDIO
-#if defined( freebsd ) || defined( linux )
+#if defined( freebsd ) || defined( __GLIBC__ ) && ( __GLIBC__ > 1 )
#define SYSERRLIST_IN_STDIO
#endif
#endif
kill( getpid(), sig );
}
+#else
+
+#if defined ( POSIX_THREADS )
+
+void p_thread_yield( void )
+{
+ sched_yield();
+}
+
+#endif /* posix threads */
#endif /* dce pthreads */
#endif /* mit pthreads */
#endif /* sunos5 lwp */
}
char **
-str2charray( char *str, char *brkstr )
+str2charray( char *str_in, char *brkstr )
{
char **res;
char *s;
int i;
+ /* protect the input string from strtok */
+ char *str = strdup( str_in );
+
i = 1;
for ( s = str; *s; s++ ) {
if ( strchr( brkstr, *s ) != NULL ) {
}
res[i] = NULL;
+ free( str );
return( res );
}
pthread_attr_init( &attr );
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
- if ( pthread_create( &arg->co_op->o_tid, attr,
+ if ( pthread_create( &arg->co_op->o_tid, &attr,
(void *) connection_operation, (void *) arg ) != 0 ) {
Debug( LDAP_DEBUG_ANY, "pthread_create failed\n", 0, 0, 0 );
} else {
}
(void) SIGNAL( SIGPIPE, SIG_IGN );
+#ifdef SIGSTKFLT
+ (void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
+#else
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
+#endif
+#ifdef SIGSTKFLT
+ (void) SIGNAL( SIGUNUSED, (void *) set_shutdown );
+#else
(void) SIGNAL( SIGUSR2, (void *) set_shutdown );
+#endif
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
(void) SIGNAL( SIGINT, (void *) set_shutdown );
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
{
Debug( LDAP_DEBUG_ANY, "slapd got shutdown signal\n", 0, 0, 0 );
slapd_shutdown = 1;
+#ifdef SIGSTKFLT
+ pthread_kill( listener_tid, SIGSTKFLT );
+#else
pthread_kill( listener_tid, SIGUSR1 );
+#endif
+#ifdef SIGUNUSED
+ (void) SIGNAL( SIGUNUSED, (void *) set_shutdown );
+#else
(void) SIGNAL( SIGUSR2, (void *) set_shutdown );
+#endif
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
(void) SIGNAL( SIGINT, (void *) set_shutdown );
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
static void
do_nothing()
{
- Debug( LDAP_DEBUG_TRACE, "slapd got SIGUSR1\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "slapd got do_nothing signal\n", 0, 0, 0 );
+#ifdef SIGSTKFLT
+ (void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
+#else
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
+#endif
}
#include "slap.h"
#include "ldapconfig.h"
-extern void daemon();
+extern void slapd_daemon();
extern int lber_debug;
extern char Versionstr[];
pthread_attr_init( &attr );
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
- if ( pthread_create( &listener_tid, attr, (void *) daemon,
+ if ( pthread_create( &listener_tid, &attr, (void *) slapd_daemon,
(void *) port ) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"listener pthread_create failed\n", 0, 0, 0 );
pthread_mutex_lock( &active_threads_mutex );
active_threads--;
conn->c_writewaiter = 1;
+#ifdef SIGSTKFLT
+ pthread_kill( listener_tid, SIGSTKFLT );
+#else
pthread_kill( listener_tid, SIGUSR1 );
+#endif
pthread_cond_wait( &conn->c_wcv, &active_threads_mutex );
pthread_mutex_unlock( &active_threads_mutex );
/* Set up our signal handlers:
* SIG{TERM,INT,HUP} causes a shutdown
- * SIGUSR1 - does nothing, used to wake up sleeping threads.
- * SIGUSR2 - causes slurpd to read its administrative interface file.
+ * SIG(STKFLT|USR1) - does nothing, used to wake up sleeping threads.
+ * SIG(UNUSED|USR2) - causes slurpd to read its administrative interface file.
* (not yet implemented).
*/
+#ifdef SIGSTKFLT
+ (void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
+#else
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
+#endif
+#ifdef SIGUNUSED
+ (void) SIGNAL( SIGUNUSED, (void *) do_admin );
+#else
(void) SIGNAL( SIGUSR2, (void *) do_admin );
+#endif
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
(void) SIGNAL( SIGINT, (void *) set_shutdown );
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
int i;
sglob->slurpd_shutdown = 1; /* set flag */
+#ifdef SIGSTKFLT
+ pthread_kill( sglob->fm_tid, SIGSTKFLT ); /* wake up file mgr */
+#else
pthread_kill( sglob->fm_tid, SIGUSR1 ); /* wake up file mgr */
+#endif
sglob->rq->rq_lock( sglob->rq ); /* lock queue */
pthread_cond_broadcast( &(sglob->rq->rq_more) ); /* wake repl threads */
for ( i = 0; i < sglob->num_replicas; i++ ) {
void
do_nothing()
{
+#ifdef SIGSTKFLT
+ (void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
+#else
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
+#endif
}
* Start the main file manager thread (in fm.c).
*/
pthread_attr_init( &attr );
- if ( pthread_create( &(sglob->fm_tid), attr, (void *) fm, (void *) NULL )
+ if ( pthread_create( &(sglob->fm_tid), &attr, (void *) fm, (void *) NULL )
!= 0 ) {
Debug( LDAP_DEBUG_ANY, "file manager pthread_create failed\n",
0, 0, 0 );
pthread_attr_init( &attr );
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
- if ( pthread_create( &(ri->ri_tid), attr, (void *) replicate,
+ if ( pthread_create( &(ri->ri_tid), &attr, (void *) replicate,
(void *) ri ) != 0 ) {
Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" pthread_create failed\n",
ri->ri_hostname, ri->ri_port, 0 );
int rc ;
char *errmsg;
+#ifdef SIGSTKFLT
+ (void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
+#else
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
+#endif
(void) SIGNAL( SIGPIPE, SIG_IGN );
if ( ri == NULL ) {
Debug( LDAP_DEBUG_ANY, "Error: Ri_process: ri == NULL!\n", 0, 0, 0 );
/*
- * Wake a replication thread which may be sleeping. Send it a SIGUSR1.
+ * Wake a replication thread which may be sleeping.
+ * Send it a SIG(STKFLT|USR1).
*/
static void
Ri_wake(
if ( ri == NULL ) {
return;
}
+#ifdef SIGSTKFLT
+ pthread_kill( ri->ri_tid, SIGSTKFLT );
+ (void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
+#else
pthread_kill( ri->ri_tid, SIGUSR1 );
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
+#endif
}