]> git.sur5r.net Git - openldap/commitdiff
Hide allocate of reentrant_database cond varible and reader count
authorKurt Zeilenga <kurt@openldap.org>
Tue, 26 Jan 1999 17:23:50 +0000 (17:23 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 26 Jan 1999 17:23:50 +0000 (17:23 +0000)
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.

servers/slapd/back-ldbm/back-ldbm.h
servers/slapd/back-ldbm/dbcache.c
servers/slapd/back-ldbm/init.c

index 5f46374c79f5517c6b65ac908905553dc8b39274..874f3514390efda0434193034a6f5cb6271f789c 100644 (file)
@@ -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;
index 143ed07e3ee6378fbe279c0304f663dddd07d570..bdebbbd1abe67a6955a26adae2840dcca2cdf892 100644 (file)
@@ -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 );
index eccc6d2266ec3ff4e65647457c96f5995ec3e04c..6ca09286e4bd8aba983ec08751fdcfd28f7f9ee7 100644 (file)
@@ -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 );