From: Kurt Spanier Date: Fri, 5 Feb 1999 13:20:57 +0000 (+0000) Subject: Fix braindead signal handling in linux kernal threads. X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~626 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8107ec91f03e153598b9677d4925e450e4c7db8a;p=openldap Fix braindead signal handling in linux kernal threads. First version with waiting on int to become 0; should be implemented via conditional variable... Fix of typos. First anchor for new bdb2 backend. --- diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index 248f31efef..052b23c6a9 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -163,7 +163,7 @@ ldbm_back_add( 0 ); next_id_return( be, e->e_id ); - entry_rdwr_unlock(e, 1);; + entry_rdwr_unlock(e, 1); entry_free( e ); send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" ); diff --git a/servers/slapd/back-ldbm/alias.c b/servers/slapd/back-ldbm/alias.c index a6e780143e..bc818ada9c 100644 --- a/servers/slapd/back-ldbm/alias.c +++ b/servers/slapd/back-ldbm/alias.c @@ -315,6 +315,7 @@ char *derefDN ( Backend *be, } Debug( LDAP_DEBUG_TRACE, "<= returning deref DN of \"%s\"\n", newDN, 0, 0 ); + if (matched != NULL) free(matched); return newDN; } diff --git a/servers/slapd/back-ldbm/idl.c b/servers/slapd/back-ldbm/idl.c index e04c4c1674..fbc1b5a004 100644 --- a/servers/slapd/back-ldbm/idl.c +++ b/servers/slapd/back-ldbm/idl.c @@ -119,7 +119,7 @@ idl_fetch( idl_free( idl ); idl = idl_allids( be ); - return idl; + return( idl ); } if ( ! ID_BLOCK_INDIRECT( idl ) ) { diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index aaed6b7cc4..86e2606129 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -40,6 +40,9 @@ static volatile sig_atomic_t slapd_shutdown = 0; static void set_shutdown(int sig); static void do_nothing (int sig); +int listener_running = 1; + + /* a link to the slapd.conf configuration parameters */ extern char *slapd_pid_file; extern char *slapd_args_file; @@ -390,6 +393,11 @@ slapd_daemon( } ldap_pvt_thread_mutex_unlock( &active_threads_mutex ); + /* a braindead signal handling in LINUX Kernel Threads needs some + provision, so that the top thread is not killed before the + listener thread (should be better implemented by cond_vars) */ + listener_running = 0; + return NULL; } diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 67de0a0fda..3c08768d6e 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -12,6 +12,8 @@ #include "lutil.h" /* Get lutil_detach() */ +extern int listener_running; + /* * when more than one slapd is running on one machine, each one might have * it's own LOCAL for syslogging and must have its own pid/args files @@ -172,6 +174,10 @@ main( int argc, char **argv ) openlog( serverName, OPENLOG_OPTIONS ); #endif +#ifdef SLAPD_BDB2 + bdb2i_do_timing = 1; +#endif + if ( slap_init( SLAP_SERVER_MODE, serverName ) != 0 ) { rc = 1; goto destroy; @@ -208,7 +214,8 @@ main( int argc, char **argv ) } else { /* wait for the listener thread to complete */ - ldap_pvt_thread_join( listener_tid, (void *) NULL ); + while ( listener_running ) + ldap_pvt_thread_join( listener_tid, (void *) NULL ); } } else { diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 10f0135bf2..5dabb215c6 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -22,6 +22,11 @@ #define ldap_debug slap_debug #endif +#ifdef SLAPD_BDB2 +extern int bdb2i_do_timing; +#endif + + #include "ldap_log.h" #include "../../libraries/liblber/lber-int.h" @@ -151,7 +156,7 @@ typedef struct entry { /* * remaining fields require backend cache lock to access * These items are specific to the LDBM backend and should - * and should be hidden. + * be hidden. */ char e_state; /* for the cache */ #define ENTRY_STATE_DELETED 1