From: Kurt Zeilenga Date: Tue, 26 Jan 1999 17:23:50 +0000 (+0000) Subject: Hide allocate of reentrant_database cond varible and reader count X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~694 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f1e934effb637abf2b4a6d633ca4be162c1ead9f;p=openldap Hide allocate of reentrant_database cond varible and reader count behind REENTRANT_DATABASE. rename reentrant_database -> REENTRANT_DATABASE. When REENTRANT_DATABASE is defined, the simple lock is replaced with a simple reader/writer lock. This functionality should be removed from back-ldbm to libldbm. --- diff --git a/servers/slapd/back-ldbm/back-ldbm.h b/servers/slapd/back-ldbm/back-ldbm.h index 5f46374c79..874f351439 100644 --- a/servers/slapd/back-ldbm/back-ldbm.h +++ b/servers/slapd/back-ldbm/back-ldbm.h @@ -75,8 +75,10 @@ struct dbcache { int dbc_refcnt; time_t dbc_lastref; pthread_mutex_t dbc_mutex; +#ifdef REENTRANT_DATBASE pthread_cond_t dbc_cv; int dbc_readers; +#endif long dbc_blksize; int dbc_maxids; int dbc_maxindirect; diff --git a/servers/slapd/back-ldbm/dbcache.c b/servers/slapd/back-ldbm/dbcache.c index 143ed07e3e..bdebbbd1ab 100644 --- a/servers/slapd/back-ldbm/dbcache.c +++ b/servers/slapd/back-ldbm/dbcache.c @@ -179,7 +179,7 @@ ldbm_cache_fetch( ldbm_datum_init( data ); pthread_mutex_lock( &db->dbc_mutex ); -#ifdef reentrant_database +#ifdef REENTRANT_DATABASE /* increment reader count */ db->dbc_readers++ pthread_mutex_unlock( &db->dbc_mutex ); @@ -187,7 +187,7 @@ ldbm_cache_fetch( data = ldbm_fetch( db->dbc_db, key ); -#ifdef reentrant_database +#ifdef REENTRANT_DATABASE pthread_mutex_lock( &db->dbc_mutex ); /* decrement reader count & signal any waiting writers */ if ( --db->dbc_readers == 0 ) { @@ -210,7 +210,7 @@ ldbm_cache_store( int rc; pthread_mutex_lock( &db->dbc_mutex ); -#ifdef reentrant_database +#ifdef REENTRANT_DATABASE /* wait for reader count to drop to zero */ while ( db->dbc_readers > 0 ) { pthread_cond_wait( &db->dbc_cv, &db->dbc_mutex ); @@ -251,7 +251,7 @@ ldbm_cache_delete( int rc; pthread_mutex_lock( &db->dbc_mutex ); -#ifdef reentrant_database +#ifdef REENTRANT_DATABASE /* wait for reader count to drop to zero - then write */ while ( db->dbc_readers > 0 ) { pthread_cond_wait( &db->dbc_cv, &db->dbc_mutex ); diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index eccc6d2266..6ca09286e4 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -80,8 +80,10 @@ ldbm_back_init( for ( i = 0; i < MAXDBCACHE; i++ ) { pthread_mutex_init( &li->li_dbcache[i].dbc_mutex, pthread_mutexattr_default ); +#ifdef reentrant_database pthread_cond_init( &li->li_dbcache[i].dbc_cv, pthread_condattr_default ); +#endif } #ifdef HAVE_BERKELEY_DB2 pthread_mutex_init( &dbEnvInit_mutex, pthread_mutexattr_default );