]> git.sur5r.net Git - openldap/commitdiff
Round 2 of connection management changes.
authorKurt Zeilenga <kurt@openldap.org>
Mon, 22 Mar 1999 07:38:27 +0000 (07:38 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 22 Mar 1999 07:38:27 +0000 (07:38 +0000)
Mainly updated back-bdb2, back-passwd, back-shell to use slap_get_time().

servers/slapd/back-bdb2/search.c
servers/slapd/back-bdb2/txn.c
servers/slapd/back-passwd/search.c
servers/slapd/back-shell/abandon.c
servers/slapd/daemon.c
servers/slapd/init.c
servers/slapd/proto-slap.h
servers/slapd/tools/mimic.c
tests/Makefile.in

index 2206f962f04ebad82e9ea5316044962f7829e42e..5080a5faadb3aceb2ba99a25587709926e152c8e 100644 (file)
@@ -154,10 +154,7 @@ bdb2i_back_search_internal(
                ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
 
                /* check time limit */
-               ldap_pvt_thread_mutex_lock( &currenttime_mutex );
-               time( &currenttime );
-               if ( tlimit != -1 && currenttime > stoptime ) {
-                       ldap_pvt_thread_mutex_unlock( &currenttime_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( &currenttime_mutex );
 
                /* get the entry with reader lock */
                if ( (e = bdb2i_id2entry_r( be, id )) == NULL ) {
index cc389deb79b90b58df6bc6531c1f476d71989305..6f5db42024105f5ce50bf87b5f5616a9822acf47 100644 (file)
@@ -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( &currenttime_mutex );
-               time( &currenttime );
-               now = currenttime;
-               ldap_pvt_thread_mutex_unlock( &currenttime_mutex );
+               slap_set_time();
+               now = slap_get_time();
 
                rc = txn_checkpoint( txmgr, logsize, mins );
 
index 5cccc154fb1e7fde22f1bf303f3fd88e61160496..6c12f949afb333bcab0c7142fedac0c827e0ca8b 100644 (file)
@@ -82,16 +82,12 @@ passwd_back_search(
                ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
 
                /* check time limit */
-               ldap_pvt_thread_mutex_lock( &currenttime_mutex );
-               time( &currenttime );
-               if ( currenttime > stoptime ) {
-                       ldap_pvt_thread_mutex_unlock( &currenttime_mutex );
+               if ( slap_get_time() > stoptime ) {
                        send_ldap_result( conn, op, LDAP_TIMELIMIT_EXCEEDED,
                            NULL, NULL );
                        endpwent();
                        return( 0 );
                }
-               ldap_pvt_thread_mutex_unlock( &currenttime_mutex );
 
                e = pw2entry( be, pw );
 
index e69bab6e4b19c31dc8269ebff3bf9832f7180f5b..8bfb3c9a419e591ba119fb7bea846fd48dd5fa26 100644 (file)
@@ -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,
index 6294f4fb4ad29b896c0bd2dd5fe8e15e007ef8a0..72ece692e9911fe775b82cc1ad992c52b6428775 100644 (file)
@@ -306,8 +306,6 @@ slapd_daemon_task(
                        /* FALL THRU */
                }
 
-               slap_set_time();
-
                if ( FD_ISSET( tcps, &readfds ) ) {
                        int s;
                        int len = sizeof(from);
index f464c61e93d0c483dfea2f551a2e4e9941aef734..acbee9ef631c1fd0c82a418dd237ccdf296b353f 100644 (file)
@@ -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( &currenttime_mutex );
-       time( &currenttime );
-       ldap_pvt_thread_mutex_unlock( &currenttime_mutex );
-}
-
 time_t slap_get_time(void)
 {
        time_t t;
        ldap_pvt_thread_mutex_lock( &currenttime_mutex );
-       t = currenttime;
+       time( &t );
        ldap_pvt_thread_mutex_unlock( &currenttime_mutex );
        return t;
 }
index e2876c74d7e55f5cb08f9f2a0567815ce66cd5d5..b4c90c0ea11cf742f2decf1d993cc0e06209bde1 100644 (file)
@@ -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;
index 87359d313677d49ef35e5613fbe1b09afc793dda..ef2b1b21c0963c939798a30d579eebed2ec0df07 100644 (file)
@@ -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, 
index 7f90640084586bed5540b64fe67670a3e2cbd1d7..0bd9bc87832ad7fd5d59f95ff98c75ad85489349 100644 (file)
@@ -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 ; \