int
bdb2_back_abandon(
BackendDB *be,
- Connection *c,
- Operation *o,
+ Connection *conn,
+ Operation *op,
int msgid )
{
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
-
- gettimeofday( &time1, NULL );
-
- ret = bdb2i_back_abandon_internal( be, c, o, msgid );
+ struct timeval time1;
+ int ret;
- if ( bdb2i_do_timing ) {
+ bdb2i_start_timing( be->be_private, &time1 );
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "ABND elapsed=%s\n",
- elapsed_time, 0, 0 );
- free( elapsed_time );
+ ret = bdb2i_back_abandon_internal( be, conn, op, msgid );
- }
+ bdb2i_stop_timing( be->be_private, time1, "ABND", conn, op );
return( ret );
}
Entry *e
)
{
- DB_LOCK lock;
+ DB_LOCK lock;
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+ struct timeval time1;
+ int ret;
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
-
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
if ( bdb2i_enter_backend_w( get_dbenv( be ), &lock ) != 0 ) {
/* check, if a new default attribute index will be created,
in which case we have to open the index file BEFORE TP */
- if ( ( slapMode == SLAP_SERVER_MODE ) || ( slapMode == SLAP_TOOL_MODE ) )
- bdb2i_check_default_attr_index_add( li, e );
+ switch ( slapMode ) {
+ case SLAP_SERVER_MODE:
+ case SLAP_TIMEDSERVER_MODE:
+ case SLAP_TOOL_MODE:
+ bdb2i_check_default_attr_index_add( li, e );
+ break;
+ }
ret = bdb2i_back_add_internal( be, conn, op, e );
-
(void) bdb2i_leave_backend( get_dbenv( be ), lock );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "conn=%d op=%d ADD elapsed=%s\n",
- conn->c_connid, op->o_opid, elapsed_time );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "ADD", conn, op );
return( ret );
}
struct ldbtype {
char *lty_dbhome;
size_t lty_mpsize;
+ int lty_betiming;
/* XXX do we need a private DB_ENV for all DB2 backend types ? */
DB_ENV *lty_dbenv;
};
#define get_dbenv(be) ((struct ldbtype *) (be)->bd_info->bi_private)->lty_dbenv
+#define with_timing(bi) (((struct ldbtype *) \
+ (bi)->bi_private)->lty_betiming == 1)
/* the private description of a database */
char** edn
)
{
- DB_LOCK lock;
+ DB_LOCK lock;
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+ struct timeval time1;
+ int ret;
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
-
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
if ( bdb2i_enter_backend_r( get_dbenv( be ), &lock ) != 0 ) {
(void) bdb2i_leave_backend( get_dbenv( be ), lock );
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "conn=%d op=%d BIND elapsed=%s\n",
- conn->c_connid, op->o_opid, elapsed_time );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "BIND", conn, op );
return( ret );
}
int
bdb2_back_db_close( BackendDB *be )
{
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
+ struct timeval time1;
+ int ret;
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
ret = bdb2i_back_db_close_internal( be );
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "CLOSE elapsed=%s\n",
- elapsed_time, 0, 0 );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "CLOSE", NULL, NULL );
return( ret );
}
Ava *ava
)
{
- DB_LOCK lock;
+ DB_LOCK lock;
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+ struct timeval time1;
+ int ret;
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
-
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
if ( bdb2i_enter_backend_r( get_dbenv( be ), &lock ) != 0 ) {
}
ret = bdb2i_back_compare_internal( be, conn, op, dn, ava );
-
(void) bdb2i_leave_backend( get_dbenv( be ), lock );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "conn=%d op=%d CMP elapsed=%s\n",
- conn->c_connid, op->o_opid, elapsed_time );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "CMP", conn, op );
return( ret );
}
char **argv
)
{
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
+ struct timeval time1;
+ int ret;
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( bi, &time1 );
ret = bdb2i_back_config_internal( bi, fname, lineno, argc, argv );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_TRACE, "BE-CONFIG elapsed=%s\n",
- elapsed_time, 0, 0 );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( bi, time1, "BE-CONFIG", NULL, NULL );
return( ret );
}
char **argv
)
{
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
+ struct timeval time1;
+ int ret;
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
ret = bdb2i_back_db_config_internal( be, fname, lineno, argc, argv );
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "DB-CONFIG elapsed=%s\n",
- elapsed_time, 0, 0 );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "DB-CONFIG", NULL, NULL );
return( ret );
}
)
{
/* all files are open, so return handle from file cache */
- if ( ( slapMode == SLAP_SERVER_MODE ) || ( slapMode == SLAP_TOOL_MODE ) ) {
- struct ldbminfo *li = (struct ldbminfo *) be->be_private;
- char buf[MAXPATHLEN];
+ switch ( slapMode ) {
- /* use short name */
- sprintf( buf, "%s%s", name, suffix );
- return( bdb2i_get_db_file_cache( li, buf ));
+ case SLAP_SERVER_MODE:
+ case SLAP_TIMEDSERVER_MODE:
+ case SLAP_TOOL_MODE:
+ {
+ struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+ char buf[MAXPATHLEN];
- }
+ /* use short name */
+ sprintf( buf, "%s%s", name, suffix );
+ return( bdb2i_get_db_file_cache( li, buf ));
- /* if not SERVER or TOOL, who else would ask?
- NO ONE, so return error */
+ }
+ break;
- Debug( LDAP_DEBUG_ANY,
- "bdb2i_cache_open: database user (%d) unknown -- cannot open \"%s%s\".\n",
- slapMode, name, suffix );
+ default:
+ /* if not SERVER or TOOL, who else would ask?
+ NO ONE, so return error */
- return( NULL );
+ Debug( LDAP_DEBUG_ANY,
+ "bdb2i_cache_open: database user (%d) unknown -- cannot open \"%s%s\".\n",
+ slapMode, name, suffix );
+ return( NULL );
+ }
}
void
bdb2i_cache_close( BackendDB *be, struct dbcache *db )
{
/* all files stay open until SERVER or TOOL shut down */
- if ( ( slapMode == SLAP_SERVER_MODE ) || ( slapMode == SLAP_TOOL_MODE ) )
- return;
+ switch ( slapMode ) {
- /* if unknown user, complain */
- Debug( LDAP_DEBUG_ANY,
- "bdb2i_cache_close: database user (%d) unknown -- ignored.\n",
- slapMode, 0, 0 );
+ case SLAP_SERVER_MODE:
+ case SLAP_TIMEDSERVER_MODE:
+ case SLAP_TOOL_MODE:
+ return;
- return;
+ default:
+ /* if unknown user, complain */
+ Debug( LDAP_DEBUG_ANY,
+ "bdb2i_cache_close: database user (%d) unknown -- ignored.\n",
+ slapMode, 0, 0 );
+ return;
+ }
}
void
bdb2i_cache_really_close( BackendDB *be, struct dbcache *db )
{
- struct ldbminfo *li = (struct ldbminfo *) be->be_private;
-
/* all files stay open until SERVER or TOOL shut down */
- if ( ( slapMode == SLAP_SERVER_MODE ) || ( slapMode == SLAP_TOOL_MODE ) )
+ switch ( slapMode ) {
+
+ case SLAP_SERVER_MODE:
+ case SLAP_TIMEDSERVER_MODE:
+ case SLAP_TOOL_MODE:
return;
- /* if unknown user, complain */
- Debug( LDAP_DEBUG_ANY,
+ default:
+ /* if unknown user, complain */
+ Debug( LDAP_DEBUG_ANY,
"bdb2i_cache_really_close: database user (%d) unknown -- ignored.\n",
- slapMode, 0, 0 );
-
- return;
+ slapMode, 0, 0 );
+ return;
+ }
}
void
bdb2i_cache_flush_all( BackendDB *be )
{
- struct ldbminfo *li = (struct ldbminfo *) be->be_private;
- int i;
-
/* if SERVER or TOOL, syncing is done by TP, or during shutdown */
- if ( ( slapMode == SLAP_SERVER_MODE ) || ( slapMode == SLAP_TOOL_MODE ) )
- return;
+ switch ( slapMode ) {
- /* if unknown user, complain */
- Debug( LDAP_DEBUG_ANY,
- "bdb2i_cache_really_close: database user (%d) unknown -- ignored.\n",
- slapMode, 0, 0 );
+ case SLAP_SERVER_MODE:
+ case SLAP_TIMEDSERVER_MODE:
+ case SLAP_TOOL_MODE:
+ return;
- return;
+ default:
+ /* if unknown user, complain */
+ Debug( LDAP_DEBUG_ANY,
+ "bdb2i_cache_flush_all: database user (%d) unknown -- ignored.\n",
+ slapMode, 0, 0 );
+ return;
+ }
}
Datum
char *dn
)
{
- DB_LOCK lock;
+ DB_LOCK lock;
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+ struct timeval time1;
+ int ret;
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
-
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
if ( bdb2i_enter_backend_w( get_dbenv( be ), &lock ) != 0 ) {
}
ret = bdb2i_back_delete_internal( be, conn, op, dn );
-
(void) bdb2i_leave_backend( get_dbenv( be ), lock );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "conn=%d op=%d DEL elapsed=%s\n",
- conn->c_connid, op->o_opid, elapsed_time );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "DEL", conn, op );
return( ret );
}
char *groupattrName
)
{
- DB_LOCK lock;
+ DB_LOCK lock;
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+ struct timeval time1;
+ int ret;
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
-
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
if ( bdb2i_enter_backend_r( get_dbenv( be ), &lock ) != 0 ) {
objectclassValue, groupattrName );
(void) bdb2i_leave_backend( get_dbenv( be ), lock );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "GRP elapsed=%s\n",
- elapsed_time, 0, 0 );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "GRP", NULL, NULL );
return( ret );
}
bt->lty_mpsize = DEFAULT_DBCACHE_SIZE;
bt->lty_dbenv = &ldbm_Env;
+ if ( slapMode == SLAP_TIMEDSERVER_MODE )
+ bt->lty_betiming = 1;
+
bi->bi_private = bt;
return 0;
BackendDB *be
)
{
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
+ struct timeval time1;
+ int ret;
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
ret = bdb2i_back_db_init_internal( be );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "DB-INIT elapsed=%s\n",
- elapsed_time, 0, 0 );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "DB-INIT", NULL, NULL );
return( ret );
}
LDAPModList *modlist
)
{
- DB_LOCK lock;
+ DB_LOCK lock;
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+ struct timeval time1;
+ int ret;
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
-
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
if ( bdb2i_enter_backend_w( get_dbenv( be ), &lock ) != 0 ) {
/* check, if a new default attribute index will be created,
in which case we have to open the index file BEFORE TP */
- if ( ( slapMode == SLAP_SERVER_MODE ) || ( slapMode == SLAP_TOOL_MODE ) )
- bdb2i_check_default_attr_index_mod( li, modlist );
+ switch ( slapMode ) {
+ case SLAP_SERVER_MODE:
+ case SLAP_TIMEDSERVER_MODE:
+ case SLAP_TOOL_MODE:
+ bdb2i_check_default_attr_index_mod( li, modlist );
+ break;
+ }
ret = bdb2i_back_modify_internal( be, conn, op, dn, modlist );
-
(void) bdb2i_leave_backend( get_dbenv( be ), lock );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "conn=%d op=%d MOD elapsed=%s\n",
- conn->c_connid, op->o_opid, elapsed_time );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "MOD", conn, op );
return( ret );
}
int deleteoldrdn
)
{
- DB_LOCK lock;
+ DB_LOCK lock;
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+ struct timeval time1;
+ int ret;
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
-
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
if ( bdb2i_enter_backend_w( get_dbenv( be ), &lock ) != 0 ) {
newrdn, deleteoldrdn );
(void) bdb2i_leave_backend( get_dbenv( be ), lock );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "conn=%d op=%d MODRDN elapsed=%s\n",
- conn->c_connid, op->o_opid, elapsed_time );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "MODRDN", conn, op );
return( ret );
}
u_int32_t locker;
db_lockmode_t lock_type;
DBT lock_dbt;
- int ret;
+ int ret = 0;
- if ( ( slapMode != SLAP_SERVER_MODE ) && ( slapMode != SLAP_TOOL_MODE ) )
- return( 0 );
+ switch ( slapMode ) {
- if ( ( ret = lock_id( dbEnv->lk_info, &locker )) != 0 ) {
+ case SLAP_SERVER_MODE:
+ case SLAP_TIMEDSERVER_MODE:
+ case SLAP_TOOL_MODE:
+ if ( ( ret = lock_id( dbEnv->lk_info, &locker )) != 0 ) {
- Debug( LDAP_DEBUG_ANY,
- "bdb2i_enter_backend(): unable to get locker id -- %s\n",
- strerror( ret ), 0, 0 );
- return( ret );
+ Debug( LDAP_DEBUG_ANY,
+ "bdb2i_enter_backend(): unable to get locker id -- %s\n",
+ strerror( ret ), 0, 0 );
+ return( ret );
- }
+ }
- lock_type = writer ? DB_LOCK_WRITE : DB_LOCK_READ;
- lock_dbt.data = PORTER_OBJ;
- lock_dbt.size = strlen( PORTER_OBJ );
+ lock_type = writer ? DB_LOCK_WRITE : DB_LOCK_READ;
+ lock_dbt.data = PORTER_OBJ;
+ lock_dbt.size = strlen( PORTER_OBJ );
- switch ( ( ret = lock_get( dbEnv->lk_info, locker, 0, &lock_dbt,
- lock_type, lock ))) {
+ switch ( ( ret = lock_get( dbEnv->lk_info, locker, 0, &lock_dbt,
+ lock_type, lock ))) {
- case 0:
- Debug( LDAP_DEBUG_TRACE, "bdb2i_enter_backend() -- %s lock granted\n",
+ case 0:
+ Debug( LDAP_DEBUG_TRACE,
+ "bdb2i_enter_backend() -- %s lock granted\n",
writer ? "write" : "read", 0, 0 );
- break;
+ break;
- case DB_LOCK_NOTGRANTED:
- Debug( LDAP_DEBUG_ANY,
+ case DB_LOCK_NOTGRANTED:
+ Debug( LDAP_DEBUG_ANY,
"bdb2i_enter_backend() -- %s lock NOT granted\n",
writer ? "write" : "read", 0, 0 );
- break;
+ break;
- case DB_LOCK_DEADLOCK:
- Debug( LDAP_DEBUG_ANY,
+ case DB_LOCK_DEADLOCK:
+ Debug( LDAP_DEBUG_ANY,
"bdb2i_enter_backend() -- %s lock returned DEADLOCK\n",
writer ? "write" : "read", 0, 0 );
- break;
+ break;
- default:
- Debug( LDAP_DEBUG_ANY,
+ default:
+ Debug( LDAP_DEBUG_ANY,
"bdb2i_enter_backend() -- %s lock returned ERROR: %s\n",
writer ? "write" : "read", strerror( errno ), 0 );
- ret = errno;
+ ret = errno;
+ break;
+
+ }
break;
-
}
return( ret );
int
bdb2i_leave_backend( DB_ENV *dbEnv, DB_LOCK lock )
{
- int ret;
+ int ret = 0;
- if ( ( slapMode != SLAP_SERVER_MODE ) && ( slapMode != SLAP_TOOL_MODE ) )
- return( 0 );
+ switch ( slapMode ) {
- switch( ( ret = lock_put( dbEnv->lk_info, lock ))) {
+ case SLAP_SERVER_MODE:
+ case SLAP_TIMEDSERVER_MODE:
+ case SLAP_TOOL_MODE:
+ switch( ( ret = lock_put( dbEnv->lk_info, lock ))) {
- case 0:
- Debug( LDAP_DEBUG_TRACE, "bdb2i_leave_backend() -- lock released\n",
+ case 0:
+ Debug( LDAP_DEBUG_TRACE,
+ "bdb2i_leave_backend() -- lock released\n",
0, 0, 0 );
- break;
+ break;
- case DB_LOCK_NOTHELD:
- Debug( LDAP_DEBUG_ANY,
+ case DB_LOCK_NOTHELD:
+ Debug( LDAP_DEBUG_ANY,
"bdb2i_leave_backend() -- lock NOT held\n",
0, 0, 0 );
- break;
+ break;
- case DB_LOCK_DEADLOCK:
- Debug( LDAP_DEBUG_ANY,
+ case DB_LOCK_DEADLOCK:
+ Debug( LDAP_DEBUG_ANY,
"bdb2i_leave_backend() -- lock returned DEADLOCK\n",
0, 0, 0 );
- break;
+ break;
- default:
- Debug( LDAP_DEBUG_ANY,
+ default:
+ Debug( LDAP_DEBUG_ANY,
"bdb2i_leave_backend() -- lock returned ERROR: %s\n",
strerror( errno ), 0, 0 );
- ret = errno;
- break;
+ ret = errno;
+ break;
+ }
+ break;
}
return( ret );
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 ));
/*
* porter.c
int attrsonly
)
{
- DB_LOCK lock;
+ DB_LOCK lock;
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+ struct timeval time1;
+ int ret;
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
-
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
if ( bdb2i_enter_backend_r( get_dbenv( be ), &lock ) != 0 ) {
slimit, tlimit, filter, filterstr, attrs, attrsonly );
(void) bdb2i_leave_backend( get_dbenv( be ), lock );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "conn=%d op=%d SRCH elapsed=%s\n",
- conn->c_connid, op->o_opid, elapsed_time );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "SRCH", conn, op );
return( ret );
}
BackendInfo *bi
)
{
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
+ struct timeval time1;
+ int ret;
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( bi, &time1 );
ret = bdb2i_back_startup_internal( bi );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "BE-START elapsed=%s\n",
- elapsed_time, 0, 0 );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( bi, time1, "BE-START", NULL, NULL );
return( ret );
}
BackendInfo *bi
)
{
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
+ struct timeval time1;
+ int ret;
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( bi, &time1 );
ret = bdb2i_back_shutdown_internal( bi );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "BE-SHUTDOWN elapsed=%s\n",
- elapsed_time, 0, 0 );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( bi, time1, "BE-SHUTDOWN", NULL, NULL );
return( ret );
}
BackendDB *be
)
{
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
+ struct timeval time1;
+ int ret;
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
ret = bdb2i_back_db_startup_internal( be );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "DB-START elapsed=%s\n",
- elapsed_time, 0, 0 );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "DB-START", NULL, NULL );
return( ret );
}
BackendDB *be
)
{
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
+ struct timeval time1;
+ int ret;
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
ret = bdb2i_back_db_shutdown_internal( be );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "DB-SHUTDOWN elapsed=%s\n",
- elapsed_time, 0, 0 );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "DB-SHUTDOWN", NULL, NULL );
return( ret );
}
#include "back-bdb2.h"
-int bdb2i_do_timing = 0;
-
-
char *
bdb2i_elapsed( struct timeval firsttime, struct timeval secondtime )
{
}
+void
+bdb2i_start_timing(
+ BackendInfo *bi,
+ struct timeval *time1
+)
+{
+ if ( with_timing( bi )) gettimeofday( time1, NULL );
+}
+
+
+void
+bdb2i_stop_timing(
+ BackendInfo *bi,
+ struct timeval time1,
+ char *func,
+ Connection *conn,
+ Operation *op
+)
+{
+ if ( with_timing( bi )) {
+ struct timeval time2;
+ char *elapsed_time;
+ char buf[BUFSIZ];
+
+ *buf = '\0';
+
+ 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 );
+
+ Debug( LDAP_DEBUG_ANY, "%s%s elapsed=%s\n", buf, func, elapsed_time );
+
+ free( elapsed_time );
+
+ }
+}
+
+
Operation *op
)
{
- struct timeval time1, time2;
- char *elapsed_time;
- int ret;
+ struct timeval time1;
+ int ret;
- gettimeofday( &time1, NULL );
+ bdb2i_start_timing( be->be_private, &time1 );
ret = bdb2i_back_unbind_internal( be, conn, op );
-
- if ( bdb2i_do_timing ) {
-
- gettimeofday( &time2, NULL);
- elapsed_time = bdb2i_elapsed( time1, time2 );
- Debug( LDAP_DEBUG_ANY, "conn=%d op=%d UNBIND elapsed=%s\n",
- conn->c_connid, op->o_opid, elapsed_time );
- free( elapsed_time );
-
- }
+ bdb2i_stop_timing( be->be_private, time1, "UNBIND", conn, op );
return( ret );
}
slapMode = mode;
- if( ( slapMode != SLAP_SERVER_MODE ) && ( slapMode != SLAP_TOOL_MODE ) ) {
- Debug( LDAP_DEBUG_ANY,
- "%s init: undefined mode (%d).\n",
- name, mode, 0 );
- return 1;
- }
+ switch ( slapMode ) {
- Debug( LDAP_DEBUG_TRACE,
- "%s init: initiated %s.\n",
- name,
- mode == SLAP_SERVER_MODE ? "server" : "tool",
- 0 );
+ case SLAP_SERVER_MODE:
+ case SLAP_TOOL_MODE:
+#ifdef SLAPD_BDB2
+ case SLAP_TIMEDSERVER_MODE:
+#endif
+
+ Debug( LDAP_DEBUG_TRACE,
+ "%s init: initiated %s.\n",
+ name, mode == SLAP_TOOL_MODE ? "tool" : "server", 0 );
- slap_name = name;
+ slap_name = name;
- (void) ldap_pvt_thread_initialize();
+ (void) ldap_pvt_thread_initialize();
- ldap_pvt_thread_mutex_init( &active_threads_mutex );
- ldap_pvt_thread_cond_init( &active_threads_cond );
+ ldap_pvt_thread_mutex_init( &active_threads_mutex );
+ ldap_pvt_thread_cond_init( &active_threads_cond );
- ldap_pvt_thread_mutex_init( &new_conn_mutex );
- ldap_pvt_thread_mutex_init( ¤ttime_mutex );
- ldap_pvt_thread_mutex_init( &entry2str_mutex );
- ldap_pvt_thread_mutex_init( &replog_mutex );
- ldap_pvt_thread_mutex_init( &ops_mutex );
- ldap_pvt_thread_mutex_init( &num_sent_mutex );
+ ldap_pvt_thread_mutex_init( &new_conn_mutex );
+ ldap_pvt_thread_mutex_init( ¤ttime_mutex );
+ ldap_pvt_thread_mutex_init( &entry2str_mutex );
+ ldap_pvt_thread_mutex_init( &replog_mutex );
+ ldap_pvt_thread_mutex_init( &ops_mutex );
+ ldap_pvt_thread_mutex_init( &num_sent_mutex );
#ifdef SLAPD_CRYPT
- ldap_pvt_thread_mutex_init( &crypt_mutex );
+ ldap_pvt_thread_mutex_init( &crypt_mutex );
#endif
- rc = backend_init();
+ rc = backend_init();
+ break;
+
+ default:
+ Debug( LDAP_DEBUG_ANY,
+ "%s init: undefined mode (%d).\n", name, mode, 0 );
+ rc = 1;
+ break;
+ }
return rc;
}
#endif
char *configfile;
char *serverName;
+ int serverMode = SLAP_SERVER_MODE;
configfile = SLAPD_DEFAULT_CONFIGFILE;
port = LDAP_PORT;
g_argc = argc;
g_argv = argv;
+#ifdef SLAPD_BDB2
+ while ( (i = getopt( argc, argv, "d:f:ip:s:ut" )) != EOF ) {
+#else
while ( (i = getopt( argc, argv, "d:f:ip:s:u" )) != EOF ) {
+#endif
switch ( i ) {
#ifdef LDAP_DEBUG
case 'd': /* turn on debugging */
udp = 1;
break;
+#ifdef SLAPD_BDB2
+ case 't': /* timed server */
+ serverMode = SLAP_TIMEDSERVER_MODE;
+ break;
+#endif
+
default:
usage( argv[0] );
exit( 1 );
openlog( serverName, OPENLOG_OPTIONS );
#endif
-#ifdef SLAPD_BDB2
- bdb2i_do_timing = 1;
-#endif
-
- if ( slap_init( SLAP_SERVER_MODE, serverName ) != 0 ) {
+ if ( slap_init( serverMode, serverName ) != 0 ) {
rc = 1;
goto destroy;
}
#define ldap_debug slap_debug
#endif
-#ifdef SLAPD_BDB2
-extern int bdb2i_do_timing;
-#endif
-
#include "ldap_log.h"
#define SLAP_UNDEFINED_MODE 0
#define SLAP_SERVER_MODE 1
#define SLAP_TOOL_MODE 2
+#ifdef SLAPD_BDB2
+# define SLAP_TIMEDSERVER_MODE 3
+#endif
/* temporary aliases */
typedef BackendDB Backend;