From: Howard Chu Date: Thu, 25 Jan 2007 12:00:40 +0000 (+0000) Subject: Free main-thread keys in db_close, can't do it later because the env X-Git-Tag: OPENLDAP_REL_ENG_2_4_4ALPHA~8^2~136 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ea8a2894c4c64d3b32009ae4def2d79b54371b6e;p=openldap Free main-thread keys in db_close, can't do it later because the env will be gone. --- diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index bfe95749d4..7f93b3bad1 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -1371,6 +1371,19 @@ bdb_locker_id_free( void *key, void *data ) } } +/* free up any keys used by the main thread */ +void +bdb_locker_flush( DB_ENV *env ) +{ + void *data; + void *ctx = ldap_pvt_thread_pool_context(); + + if ( !ldap_pvt_thread_pool_getkey( ctx, env, &data, NULL ) ) { + ldap_pvt_thread_pool_setkey( ctx, env, NULL, NULL ); + bdb_locker_id_free( env, data ); + } +} + int bdb_locker_id( Operation *op, DB_ENV *env, u_int32_t *locker ) { diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index f89f2db850..ce41a5cf6b 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -494,7 +494,9 @@ bdb_db_close( BackendDB *be ) XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker); bdb->bi_cache.c_locker = 0; } - +#ifdef BDB_REUSE_LOCKERS + bdb_locker_flush( bdb->bi_dbenv ); +#endif /* force a checkpoint, but not if we were ReadOnly, * and not in Quick mode since there are no transactions there. */