From c9eacbdc6407b65b395c13e1e93e8fe25bbbf041 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 22 Mar 1999 07:38:27 +0000 Subject: [PATCH] Round 2 of connection management changes. Mainly updated back-bdb2, back-passwd, back-shell to use slap_get_time(). --- servers/slapd/back-bdb2/search.c | 6 +----- servers/slapd/back-bdb2/txn.c | 6 ++---- servers/slapd/back-passwd/search.c | 6 +----- servers/slapd/back-shell/abandon.c | 12 ++++++++++-- servers/slapd/daemon.c | 2 -- servers/slapd/init.c | 11 +---------- servers/slapd/proto-slap.h | 1 - servers/slapd/tools/mimic.c | 10 ++++++++++ tests/Makefile.in | 2 +- 9 files changed, 26 insertions(+), 30 deletions(-) diff --git a/servers/slapd/back-bdb2/search.c b/servers/slapd/back-bdb2/search.c index 2206f962f0..5080a5faad 100644 --- a/servers/slapd/back-bdb2/search.c +++ b/servers/slapd/back-bdb2/search.c @@ -154,10 +154,7 @@ bdb2i_back_search_internal( ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); /* check time limit */ - ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); - time( ¤ttime ); - if ( tlimit != -1 && currenttime > stoptime ) { - ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); + if ( tlimit != -1 && slap_get_time() > stoptime ) { send_ldap_search_result( conn, op, LDAP_TIMELIMIT_EXCEEDED, NULL, nrefs > 0 ? rbuf : NULL, nentries ); @@ -168,7 +165,6 @@ bdb2i_back_search_internal( } return( 0 ); } - ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); /* get the entry with reader lock */ if ( (e = bdb2i_id2entry_r( be, id )) == NULL ) { diff --git a/servers/slapd/back-bdb2/txn.c b/servers/slapd/back-bdb2/txn.c index cc389deb79..6f5db42024 100644 --- a/servers/slapd/back-bdb2/txn.c +++ b/servers/slapd/back-bdb2/txn.c @@ -764,10 +764,8 @@ bdb2i_set_txn_checkpoint( DB_TXNMGR *txmgr, int forced ) logsize = forced ? (u_int32_t) 0 : txn_max_pending_log; mins = forced ? (u_int32_t) 0 : txn_max_pending_time; - ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); - time( ¤ttime ); - now = currenttime; - ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); + slap_set_time(); + now = slap_get_time(); rc = txn_checkpoint( txmgr, logsize, mins ); diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index 5cccc154fb..6c12f949af 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -82,16 +82,12 @@ passwd_back_search( ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); /* check time limit */ - ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); - time( ¤ttime ); - if ( currenttime > stoptime ) { - ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); + if ( slap_get_time() > stoptime ) { send_ldap_result( conn, op, LDAP_TIMELIMIT_EXCEEDED, NULL, NULL ); endpwent(); return( 0 ); } - ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); e = pw2entry( be, pw ); diff --git a/servers/slapd/back-shell/abandon.c b/servers/slapd/back-shell/abandon.c index e69bab6e4b..8bfb3c9a41 100644 --- a/servers/slapd/back-shell/abandon.c +++ b/servers/slapd/back-shell/abandon.c @@ -26,7 +26,7 @@ shell_back_abandon( /* no abandon command defined - just kill the process handling it */ if ( si->si_abandon == NULL ) { - ldap_pvt_thread_mutex_lock( &conn->c_opsmutex ); + ldap_pvt_thread_mutex_lock( &conn->c_mutex ); pid = -1; for ( o = conn->c_ops; o != NULL; o = o->o_next ) { if ( o->o_msgid == msgid ) { @@ -34,7 +34,15 @@ shell_back_abandon( break; } } - ldap_pvt_thread_mutex_unlock( &conn->c_opsmutex ); + if( pid == -1 ) { + for ( o = conn->c_pending_ops; o != NULL; o = o->o_next ) { + if ( o->o_msgid == msgid ) { + pid = (pid_t) o->o_private; + break; + } + } + } + ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); if ( pid != -1 ) { Debug( LDAP_DEBUG_ARGS, "shell killing pid %d\n", pid, diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 6294f4fb4a..72ece692e9 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -306,8 +306,6 @@ slapd_daemon_task( /* FALL THRU */ } - slap_set_time(); - if ( FD_ISSET( tcps, &readfds ) ) { int s; int len = sizeof(from); diff --git a/servers/slapd/init.c b/servers/slapd/init.c index f464c61e93..acbee9ef63 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -57,7 +57,6 @@ ldap_pvt_thread_mutex_t replog_mutex; static char* slap_name; int slapMode = SLAP_UNDEFINED_MODE; -static time_t currenttime; static ldap_pvt_thread_mutex_t currenttime_mutex; int @@ -160,19 +159,11 @@ int slap_destroy(void) } /* should create a utils.c for these */ - -void slap_set_time(void) -{ - ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); - time( ¤ttime ); - ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); -} - time_t slap_get_time(void) { time_t t; ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); - t = currenttime; + time( &t ); ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); return t; } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index e2876c74d7..b4c90c0ea1 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -287,7 +287,6 @@ extern char **g_argv; extern time_t starttime; time_t slap_get_time LDAP_P((void)); -void slap_set_time LDAP_P((void)); extern ldap_pvt_thread_mutex_t active_threads_mutex; extern ldap_pvt_thread_cond_t active_threads_cond; diff --git a/servers/slapd/tools/mimic.c b/servers/slapd/tools/mimic.c index 87359d3136..ef2b1b21c0 100644 --- a/servers/slapd/tools/mimic.c +++ b/servers/slapd/tools/mimic.c @@ -8,6 +8,16 @@ #include "../slap.h" +/* bogus ../results.c */ +int str2result( + char* s, + int *code, + char **matched, + char **info ) +{ + assert(0); +} + void send_ldap_result( Connection *conn, diff --git a/tests/Makefile.in b/tests/Makefile.in index 7f90640084..0bd9bc8783 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -7,8 +7,8 @@ SUBDIRS= progs BUILD_BDB2 = @BUILD_BDB2@ test-bdb2: FORCE + @-$(LN_S) $(srcdir)/data . @if test "$(BUILD_BDB2)" = "yes" ; then \ - $(LN_S) $(srcdir)/data . ; \ echo "Initiating LDAP tests..." ; \ $(MKDIR) test-db test-repl ; \ $(srcdir)/scripts/all $(srcdir) bdb2 ; \ -- 2.39.5