From 9cb23b462e8b6c466008528eea59fe9b18517d11 Mon Sep 17 00:00:00 2001 From: Kurt Spanier Date: Mon, 22 Feb 1999 11:22:44 +0000 Subject: [PATCH] More timing for performance testing. Re-introduction of cache.c_mutex. --- servers/slapd/back-bdb2/add.c | 37 ++++++++++++++-- servers/slapd/back-bdb2/back-bdb2.h | 1 + servers/slapd/back-bdb2/bind.c | 2 +- servers/slapd/back-bdb2/cache.c | 53 ++++++++++++++++++++++- servers/slapd/back-bdb2/compare.c | 2 +- servers/slapd/back-bdb2/dbcache.c | 16 +++++++ servers/slapd/back-bdb2/delete.c | 2 +- servers/slapd/back-bdb2/group.c | 2 +- servers/slapd/back-bdb2/init.c | 3 ++ servers/slapd/back-bdb2/modify.c | 2 +- servers/slapd/back-bdb2/modrdn.c | 2 +- servers/slapd/back-bdb2/porter.c | 36 +++++---------- servers/slapd/back-bdb2/proto-back-bdb2.h | 19 ++++---- servers/slapd/back-bdb2/search.c | 2 +- servers/slapd/back-bdb2/startup.c | 4 +- servers/slapd/back-bdb2/timing.c | 37 ++++++++-------- servers/slapd/back-bdb2/txn.c | 4 +- 17 files changed, 156 insertions(+), 68 deletions(-) diff --git a/servers/slapd/back-bdb2/add.c b/servers/slapd/back-bdb2/add.c index 6d56b48012..e04f77591f 100644 --- a/servers/slapd/back-bdb2/add.c +++ b/servers/slapd/back-bdb2/add.c @@ -23,6 +23,7 @@ bdb2i_back_add_internal( char *pdn; Entry *p = NULL; int rc; + struct timeval time1; Debug(LDAP_DEBUG_ARGS, "==> bdb2i_back_add: %s\n", e->e_dn, 0, 0); @@ -106,8 +107,12 @@ bdb2i_back_add_internal( /* * Try to add the entry to the cache, assign it a new dnid. */ + bdb2i_start_timing( be->bd_info, &time1 ); + rc = bdb2i_cache_add_entry_rw( &li->li_cache, e, CACHE_WRITE_LOCK ); + bdb2i_stop_timing( be->bd_info, time1, "ADD-CACHE", conn, op ); + if ( rc != 0 ) { if( p != NULL) { /* free parent and writer lock */ @@ -138,37 +143,57 @@ bdb2i_back_add_internal( * add it to the id2children index for the parent */ + bdb2i_start_timing( be->bd_info, &time1 ); + if ( bdb2i_id2children_add( be, p, e ) != 0 ) { Debug( LDAP_DEBUG_TRACE, "bdb2i_id2children_add failed\n", 0, 0, 0 ); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); + bdb2i_stop_timing( be->bd_info, time1, "ADD-ID2CHILDREN", conn, op ); + goto return_results; } + bdb2i_stop_timing( be->bd_info, time1, "ADD-ID2CHILDREN", conn, op ); + /* * Add the entry to the attribute indexes, then add it to * the id2children index, dn2id index, and the id2entry index. */ + bdb2i_start_timing( be->bd_info, &time1 ); + /* attribute indexes */ if ( bdb2i_index_add_entry( be, e ) != 0 ) { Debug( LDAP_DEBUG_TRACE, "bdb2i_index_add_entry failed\n", 0, 0, 0 ); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); + bdb2i_stop_timing( be->bd_info, time1, "ADD-INDEX", conn, op ); + goto return_results; } + bdb2i_stop_timing( be->bd_info, time1, "ADD-INDEX", conn, op ); + + bdb2i_start_timing( be->bd_info, &time1 ); + /* dn2id index */ if ( bdb2i_dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) { Debug( LDAP_DEBUG_TRACE, "bdb2i_dn2id_add failed\n", 0, 0, 0 ); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); + bdb2i_stop_timing( be->bd_info, time1, "ADD-DN2ID", conn, op ); + goto return_results; } + bdb2i_stop_timing( be->bd_info, time1, "ADD-DN2ID", conn, op ); + + bdb2i_start_timing( be->bd_info, &time1 ); + /* id2entry index */ if ( bdb2i_id2entry_add( be, e ) != 0 ) { Debug( LDAP_DEBUG_TRACE, "bdb2i_id2entry_add failed\n", 0, @@ -176,9 +201,13 @@ bdb2i_back_add_internal( (void) bdb2i_dn2id_delete( be, e->e_ndn ); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); + bdb2i_stop_timing( be->bd_info, time1, "ADD-ID2ENTRY", conn, op ); + goto return_results; } + bdb2i_stop_timing( be->bd_info, time1, "ADD-ID2ENTRY", conn, op ); + send_ldap_result( conn, op, LDAP_SUCCESS, "", "" ); rc = 0; @@ -186,7 +215,6 @@ return_results:; if (p != NULL) { /* free parent and writer lock */ bdb2i_cache_return_entry_w( &li->li_cache, p ); - } /* free entry and writer lock */ @@ -206,7 +234,7 @@ bdb2_back_add( { DB_LOCK lock; struct ldbminfo *li = (struct ldbminfo *) be->be_private; - struct timeval time1; + struct timeval time1, time2; int ret; bdb2i_start_timing( be->bd_info, &time1 ); @@ -218,6 +246,8 @@ bdb2_back_add( } + bdb2i_start_timing( be->bd_info, &time2 ); + /* check, if a new default attribute index will be created, in which case we have to open the index file BEFORE TP */ switch ( slapMode ) { @@ -229,7 +259,8 @@ bdb2_back_add( } ret = bdb2i_back_add_internal( be, conn, op, e ); - (void) bdb2i_leave_backend( get_dbenv( be ), lock ); + bdb2i_stop_timing( be->bd_info, time2, "ADD-INTERN", conn, op ); + (void) bdb2i_leave_backend_w( get_dbenv( be ), lock ); bdb2i_stop_timing( be->bd_info, time1, "ADD", conn, op ); return( ret ); diff --git a/servers/slapd/back-bdb2/back-bdb2.h b/servers/slapd/back-bdb2/back-bdb2.h index a99efa7bca..f7d7e58905 100644 --- a/servers/slapd/back-bdb2/back-bdb2.h +++ b/servers/slapd/back-bdb2/back-bdb2.h @@ -79,6 +79,7 @@ struct cache { Avlnode *c_idtree; Entry *c_lruhead; /* lru - add accessed entries here */ Entry *c_lrutail; /* lru - rem lru entries from here */ + ldap_pvt_thread_mutex_t c_mutex; }; #define CACHE_READ_LOCK 1 diff --git a/servers/slapd/back-bdb2/bind.c b/servers/slapd/back-bdb2/bind.c index 8f0ae3c4a5..5110515455 100644 --- a/servers/slapd/back-bdb2/bind.c +++ b/servers/slapd/back-bdb2/bind.c @@ -242,7 +242,7 @@ bdb2_back_bind( ret = bdb2i_back_bind_internal( be, conn, op, dn, method, cred, edn ); - (void) bdb2i_leave_backend( get_dbenv( be ), lock ); + (void) bdb2i_leave_backend_r( get_dbenv( be ), lock ); bdb2i_stop_timing( be->bd_info, time1, "BIND", conn, op ); diff --git a/servers/slapd/back-bdb2/cache.c b/servers/slapd/back-bdb2/cache.c index 3374abfa57..f63d3297ad 100644 --- a/servers/slapd/back-bdb2/cache.c +++ b/servers/slapd/back-bdb2/cache.c @@ -71,6 +71,9 @@ cache_entry_private_destroy( Entry*e ) void bdb2i_cache_return_entry_rw( struct cache *cache, Entry *e, int rw ) { + /* set cache mutex */ + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); + #ifdef LDAP_DEBUG assert( e->e_private ); #endif @@ -104,6 +107,9 @@ bdb2i_cache_return_entry_rw( struct cache *cache, Entry *e, int rw ) "====> bdb2i_cache_return_entry_%s( %ld ): returned (%d)\n", rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt); } + + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); } #define LRU_DELETE( cache, e ) { \ @@ -147,6 +153,9 @@ bdb2i_cache_add_entry_rw( int i; Entry *ee; + /* set cache mutex */ + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); + #ifdef LDAP_DEBUG assert( e->e_private == NULL ); #endif @@ -167,6 +176,8 @@ bdb2i_cache_add_entry_rw( cache_entry_private_destroy(e); + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( 1 ); } @@ -188,6 +199,8 @@ bdb2i_cache_add_entry_rw( cache_entry_private_destroy(e); + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( -1 ); } @@ -233,6 +246,8 @@ bdb2i_cache_add_entry_rw( } } + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( 0 ); } @@ -251,6 +266,9 @@ bdb2i_cache_update_entry( int i; Entry *ee; + /* set cache mutex */ + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); + #ifdef LDAP_DEBUG assert( e->e_private ); #endif @@ -262,6 +280,8 @@ bdb2i_cache_update_entry( "====> bdb2i_cache_add_entry( %ld ): \"%s\": already in dn cache\n", e->e_id, e->e_dn, 0 ); + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( 1 ); } @@ -281,6 +301,8 @@ bdb2i_cache_update_entry( 0, 0, 0 ); } + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( -1 ); } @@ -325,11 +347,13 @@ bdb2i_cache_update_entry( } } + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( 0 ); } /* - * cache_find_entry_dn2id - find an entry in the cache, given dn + * bdb2i_cache_find_entry_dn2id - find an entry in the cache, given dn */ ID @@ -343,6 +367,9 @@ bdb2i_cache_find_entry_dn2id( Entry e, *ep; ID id; + /* set cache mutex */ + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); + e.e_dn = dn; e.e_ndn = dn_normalize_case( ch_strdup( dn ) ); @@ -371,6 +398,8 @@ bdb2i_cache_find_entry_dn2id( "====> bdb2i_cache_find_entry_dn2id(\"%s\"): %ld (not ready) %d\n", dn, ep->e_id, LEI(ep)->lei_state); + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( NOID ); } @@ -385,11 +414,17 @@ bdb2i_cache_find_entry_dn2id( /* save id */ id = ep->e_id; + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + return( id ); } free(e.e_ndn); + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + return( NOID ); } @@ -410,6 +445,9 @@ bdb2i_cache_find_entry_id( e.e_id = id; try_again: + /* set cache mutex */ + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); + if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e, entry_id_cmp )) != NULL ) { @@ -428,6 +466,8 @@ try_again: "====> bdb2i_cache_find_entry_id( %ld ): %ld (not ready) %d\n", id, ep->e_id, LEI(ep)->lei_state); + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( NULL ); } @@ -441,9 +481,15 @@ try_again: LEI(ep)->lei_refcnt++; + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + return( ep ); } + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); + return( NULL ); } @@ -466,6 +512,9 @@ bdb2i_cache_delete_entry( { int rc; + /* set cache mutex */ + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); + #ifdef LDAP_DEBUG assert( e->e_private ); #endif @@ -475,6 +524,8 @@ bdb2i_cache_delete_entry( rc = cache_delete_entry_internal( cache, e ); + /* free cache mutex */ + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( rc ); } diff --git a/servers/slapd/back-bdb2/compare.c b/servers/slapd/back-bdb2/compare.c index 00f37f1717..6ea93d5203 100644 --- a/servers/slapd/back-bdb2/compare.c +++ b/servers/slapd/back-bdb2/compare.c @@ -86,7 +86,7 @@ bdb2_back_compare( } ret = bdb2i_back_compare_internal( be, conn, op, dn, ava ); - (void) bdb2i_leave_backend( get_dbenv( be ), lock ); + (void) bdb2i_leave_backend_r( get_dbenv( be ), lock ); bdb2i_stop_timing( be->bd_info, time1, "CMP", conn, op ); return( ret ); diff --git a/servers/slapd/back-bdb2/dbcache.c b/servers/slapd/back-bdb2/dbcache.c index 1b13f48dbb..405e9e924d 100644 --- a/servers/slapd/back-bdb2/dbcache.c +++ b/servers/slapd/back-bdb2/dbcache.c @@ -139,6 +139,7 @@ bdb2i_cache_store( ) { int rc; + struct timeval time1; #ifdef LDBM_DEBUG Statslog( LDAP_DEBUG_STATS, @@ -158,8 +159,23 @@ bdb2i_cache_store( flags, 0, 0, 0, 0 ); #endif /* LDBM_DEBUG */ + if ( slapMode == SLAP_TIMEDSERVER_MODE ) + bdb2i_uncond_start_timing( &time1 ); + rc = ldbm_store( db->dbc_db, key, data, flags ); + if ( slapMode == SLAP_TIMEDSERVER_MODE ) { + char buf[BUFSIZ]; + char buf2[BUFSIZ]; + + *buf2 = '\0'; + if ( !( strcasecmp( db->dbc_name, "dn.bdb2" ))) + sprintf( buf2, " [%s]", key.dptr ); + sprintf( buf, "ADD-BDB2( %s%s )", db->dbc_name, buf2 ); + bdb2i_uncond_stop_timing( time1, buf, + NULL, NULL, LDAP_DEBUG_TRACE ); + } + return( rc ); } diff --git a/servers/slapd/back-bdb2/delete.c b/servers/slapd/back-bdb2/delete.c index 57e910e15f..2affa8db85 100644 --- a/servers/slapd/back-bdb2/delete.c +++ b/servers/slapd/back-bdb2/delete.c @@ -164,7 +164,7 @@ bdb2_back_delete( } ret = bdb2i_back_delete_internal( be, conn, op, dn ); - (void) bdb2i_leave_backend( get_dbenv( be ), lock ); + (void) bdb2i_leave_backend_w( get_dbenv( be ), lock ); bdb2i_stop_timing( be->bd_info, time1, "DEL", conn, op ); return( ret ); diff --git a/servers/slapd/back-bdb2/group.c b/servers/slapd/back-bdb2/group.c index aa89afa078..60a829e7d3 100644 --- a/servers/slapd/back-bdb2/group.c +++ b/servers/slapd/back-bdb2/group.c @@ -150,7 +150,7 @@ bdb2_back_group( ret = bdb2i_back_group_internal( be, target, gr_ndn, op_ndn, objectclassValue, groupattrName ); - (void) bdb2i_leave_backend( get_dbenv( be ), lock ); + (void) bdb2i_leave_backend_r( get_dbenv( be ), lock ); bdb2i_stop_timing( be->bd_info, time1, "GRP", NULL, NULL ); return( ret ); diff --git a/servers/slapd/back-bdb2/init.c b/servers/slapd/back-bdb2/init.c index 1892b7e286..e64eb998ea 100644 --- a/servers/slapd/back-bdb2/init.c +++ b/servers/slapd/back-bdb2/init.c @@ -172,6 +172,9 @@ bdb2i_back_db_init_internal( 1 ); free( argv[ 1 ] ); + /* initialize the cache mutex */ + ldap_pvt_thread_mutex_init( &li->li_cache.c_mutex ); + /* initialize the TP file head */ if ( bdb2i_txn_head_init( &li->li_txn_head ) != 0 ) return 1; diff --git a/servers/slapd/back-bdb2/modify.c b/servers/slapd/back-bdb2/modify.c index d0c0ebe86a..3178f66985 100644 --- a/servers/slapd/back-bdb2/modify.c +++ b/servers/slapd/back-bdb2/modify.c @@ -149,7 +149,7 @@ bdb2_back_modify( } ret = bdb2i_back_modify_internal( be, conn, op, dn, modlist ); - (void) bdb2i_leave_backend( get_dbenv( be ), lock ); + (void) bdb2i_leave_backend_w( get_dbenv( be ), lock ); bdb2i_stop_timing( be->bd_info, time1, "MOD", conn, op ); return( ret ); diff --git a/servers/slapd/back-bdb2/modrdn.c b/servers/slapd/back-bdb2/modrdn.c index 147bc09ca5..0dd5a01b6e 100644 --- a/servers/slapd/back-bdb2/modrdn.c +++ b/servers/slapd/back-bdb2/modrdn.c @@ -209,7 +209,7 @@ bdb2_back_modrdn( ret = bdb2i_back_modrdn_internal( be, conn, op, dn, newrdn, deleteoldrdn ); - (void) bdb2i_leave_backend( get_dbenv( be ), lock ); + (void) bdb2i_leave_backend_w( get_dbenv( be ), lock ); bdb2i_stop_timing( be->bd_info, time1, "MODRDN", conn, op ); return( ret ); diff --git a/servers/slapd/back-bdb2/porter.c b/servers/slapd/back-bdb2/porter.c index 4ee72b9977..96f0576d47 100644 --- a/servers/slapd/back-bdb2/porter.c +++ b/servers/slapd/back-bdb2/porter.c @@ -13,8 +13,8 @@ #define PORTER_OBJ "bdb2_backend" -static int -bdb2i_enter_backend( DB_ENV *dbEnv, DB_LOCK *lock, int writer ) +int +bdb2i_enter_backend_rw( DB_ENV *dbEnv, DB_LOCK *lock, int writer ) { u_int32_t locker; db_lockmode_t lock_type; @@ -76,21 +76,7 @@ bdb2i_enter_backend( DB_ENV *dbEnv, DB_LOCK *lock, int writer ) int -bdb2i_enter_backend_r( DB_ENV *dbEnv, DB_LOCK *lock ) -{ - return( bdb2i_enter_backend( dbEnv, lock, 0 )); -} - - -int -bdb2i_enter_backend_w( DB_ENV *dbEnv, DB_LOCK *lock ) -{ - return( bdb2i_enter_backend( dbEnv, lock, 1 )); -} - - -int -bdb2i_leave_backend( DB_ENV *dbEnv, DB_LOCK lock ) +bdb2i_leave_backend_rw( DB_ENV *dbEnv, DB_LOCK lock, int writer ) { int ret = 0; @@ -103,26 +89,26 @@ bdb2i_leave_backend( DB_ENV *dbEnv, DB_LOCK lock ) case 0: Debug( LDAP_DEBUG_TRACE, - "bdb2i_leave_backend() -- lock released\n", - 0, 0, 0 ); + "bdb2i_leave_backend() -- %s lock released\n", + writer ? "write" : "read", 0, 0 ); break; case DB_LOCK_NOTHELD: Debug( LDAP_DEBUG_ANY, - "bdb2i_leave_backend() -- lock NOT held\n", - 0, 0, 0 ); + "bdb2i_leave_backend() -- %s lock NOT held\n", + writer ? "write" : "read", 0, 0 ); break; case DB_LOCK_DEADLOCK: Debug( LDAP_DEBUG_ANY, - "bdb2i_leave_backend() -- lock returned DEADLOCK\n", - 0, 0, 0 ); + "bdb2i_leave_backend() -- %s lock returned DEADLOCK\n", + writer ? "write" : "read", 0, 0 ); break; default: Debug( LDAP_DEBUG_ANY, - "bdb2i_leave_backend() -- lock returned ERROR: %s\n", - strerror( errno ), 0, 0 ); + "bdb2i_leave_backend() -- %s lock returned ERROR: %s\n", + writer ? "write" : "read", strerror( errno ), 0 ); ret = errno; break; diff --git a/servers/slapd/back-bdb2/proto-back-bdb2.h b/servers/slapd/back-bdb2/proto-back-bdb2.h index d964894389..5020e531c0 100644 --- a/servers/slapd/back-bdb2/proto-back-bdb2.h +++ b/servers/slapd/back-bdb2/proto-back-bdb2.h @@ -153,19 +153,22 @@ int bdb2i_back_db_shutdown LDAP_P(( BackendDB *be )); * timing.c */ -char *bdb2i_elapsed LDAP_P(( struct timeval firsttime, - struct timeval secondtime )); -void bdb2i_start_timing LDAP_P(( BackendInfo *bi, struct timeval *time1 )); -void bdb2i_stop_timing LDAP_P(( BackendInfo *bi, struct timeval time1, - char *func, Connection *conn, Operation *op )); +void bdb2i_uncond_start_timing LDAP_P(( struct timeval *time1 )); +#define bdb2i_start_timing(bi,time1) if ( with_timing( bi )) bdb2i_uncond_start_timing( (time1) ) +void bdb2i_uncond_stop_timing LDAP_P(( struct timeval time1, + char *func, Connection *conn, Operation *op, int level )); +#define bdb2i_stop_timing(bi,time1,func,conn,op) if ( with_timing( bi )) bdb2i_uncond_stop_timing( (time1), (func), (conn), (op), LDAP_DEBUG_ANY ) /* * porter.c */ -int bdb2i_enter_backend_r LDAP_P(( DB_ENV *dbEnv, DB_LOCK *lock )); -int bdb2i_enter_backend_w LDAP_P(( DB_ENV *dbEnv, DB_LOCK *lock )); -int bdb2i_leave_backend LDAP_P(( DB_ENV *dbEnv, DB_LOCK lock )); +int bdb2i_enter_backend_rw LDAP_P(( DB_ENV *dbEnv, DB_LOCK *lock, int writer )); +#define bdb2i_enter_backend_r(dbEnv,lock) bdb2i_enter_backend_rw( (dbEnv), (lock), 0 ) +#define bdb2i_enter_backend_w(dbEnv,lock) bdb2i_enter_backend_rw( (dbEnv), (lock), 1 ) +int bdb2i_leave_backend_rw LDAP_P(( DB_ENV *dbEnv, DB_LOCK lock, int writer )); +#define bdb2i_leave_backend_r(dbEnv,lock) bdb2i_leave_backend_rw( (dbEnv), (lock), 0 ) +#define bdb2i_leave_backend_w(dbEnv,lock) bdb2i_leave_backend_rw( (dbEnv), (lock), 1 ) /* * txn.c diff --git a/servers/slapd/back-bdb2/search.c b/servers/slapd/back-bdb2/search.c index 60b9d417e6..04e68498d4 100644 --- a/servers/slapd/back-bdb2/search.c +++ b/servers/slapd/back-bdb2/search.c @@ -347,7 +347,7 @@ bdb2_back_search( ret = bdb2i_back_search_internal( be, conn, op, base, scope, deref, slimit, tlimit, filter, filterstr, attrs, attrsonly ); - (void) bdb2i_leave_backend( get_dbenv( be ), lock ); + (void) bdb2i_leave_backend_r( get_dbenv( be ), lock ); bdb2i_stop_timing( be->bd_info, time1, "SRCH", conn, op ); return( ret ); diff --git a/servers/slapd/back-bdb2/startup.c b/servers/slapd/back-bdb2/startup.c index 024d3e238c..6f6d73c814 100644 --- a/servers/slapd/back-bdb2/startup.c +++ b/servers/slapd/back-bdb2/startup.c @@ -43,7 +43,7 @@ bdb2i_back_startup_internal( (void) getcwd( cwd, MAXPATHLEN ); sprintf( cwd, "%s%s%s", cwd, DEFAULT_DIRSEP, lty->lty_dbhome ); free( lty->lty_dbhome ); - lty->lty_dbhome = strdup( cwd ); + lty->lty_dbhome = ch_strdup( cwd ); } home = lty->lty_dbhome; @@ -158,7 +158,7 @@ bdb2i_back_db_startup_internal( (void) getcwd( cwd, MAXPATHLEN ); sprintf( cwd, "%s%s%s", cwd, DEFAULT_DIRSEP, li->li_directory ); free( li->li_directory ); - li->li_directory = strdup( cwd ); + li->li_directory = ch_strdup( cwd ); } diff --git a/servers/slapd/back-bdb2/timing.c b/servers/slapd/back-bdb2/timing.c index fd08a4f63b..d1e757aaa0 100644 --- a/servers/slapd/back-bdb2/timing.c +++ b/servers/slapd/back-bdb2/timing.c @@ -12,7 +12,7 @@ #include "back-bdb2.h" -char * +static char * bdb2i_elapsed( struct timeval firsttime, struct timeval secondtime ) { long int elapsedmicrosec, elapsedsec; @@ -26,47 +26,44 @@ bdb2i_elapsed( struct timeval firsttime, struct timeval secondtime ) } sprintf( elapsed_string, "%ld.%.6ld", elapsedsec, elapsedmicrosec ); - return( strdup( elapsed_string )); + return( ch_strdup( elapsed_string )); } void -bdb2i_start_timing( - BackendInfo *bi, +bdb2i_uncond_start_timing( struct timeval *time1 ) { - if ( with_timing( bi )) gettimeofday( time1, NULL ); + gettimeofday( time1, NULL ); } void -bdb2i_stop_timing( - BackendInfo *bi, +bdb2i_uncond_stop_timing( struct timeval time1, char *func, Connection *conn, - Operation *op + Operation *op, + int level ) { - if ( with_timing( bi )) { - struct timeval time2; - char *elapsed_time; - char buf[BUFSIZ]; + struct timeval time2; + char *elapsed_time; + char buf[BUFSIZ]; - *buf = '\0'; + *buf = '\0'; - gettimeofday( &time2, NULL); - elapsed_time = bdb2i_elapsed( time1, time2 ); + gettimeofday( &time2, NULL); + elapsed_time = bdb2i_elapsed( time1, time2 ); - if ( conn != NULL ) sprintf( buf, "conn=%d ", conn->c_connid ); - if ( op != NULL ) sprintf( buf, "%sop=%d ", buf, op->o_opid ); + if ( conn != NULL ) sprintf( buf, "conn=%d ", conn->c_connid ); + if ( op != NULL ) sprintf( buf, "%sop=%d ", buf, op->o_opid ); - Debug( LDAP_DEBUG_ANY, "%s%s elapsed=%s\n", buf, func, elapsed_time ); + Debug( level, "%s%s elapsed=%s\n", buf, func, elapsed_time ); - free( elapsed_time ); + free( elapsed_time ); - } } diff --git a/servers/slapd/back-bdb2/txn.c b/servers/slapd/back-bdb2/txn.c index 9dc238c4f7..817678b5df 100644 --- a/servers/slapd/back-bdb2/txn.c +++ b/servers/slapd/back-bdb2/txn.c @@ -26,7 +26,7 @@ bdb2i_txn_head_init( BDB2_TXN_HEAD *head ) } sprintf( fileName, "%s%s", bdb2i_fixed_filenames[dbFile], BDB2_SUFFIX ); - (*fileNodeH)->dbc_name = strdup( fileName ); + (*fileNodeH)->dbc_name = ch_strdup( fileName ); fileNodeH = &(*fileNodeH)->next; @@ -119,7 +119,7 @@ bdb2i_txn_attr_config( } } - p->dbc_name = strdup( fileName ); + p->dbc_name = ch_strdup( fileName ); /* if requested for, we have to open the DB file */ /* BUT NOT "objectclass", 'cause that's a default index ! */ -- 2.39.5