]> git.sur5r.net Git - openldap/commitdiff
Added ldbm flush on write code which uses slapd.conf option.
authorKurt Zeilenga <kurt@openldap.org>
Wed, 19 Aug 1998 00:10:02 +0000 (00:10 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 19 Aug 1998 00:10:02 +0000 (00:10 +0000)
servers/slapd/back-ldbm/back-ldbm.h
servers/slapd/back-ldbm/config.c
servers/slapd/back-ldbm/dn2id.c
servers/slapd/back-ldbm/id2entry.c
servers/slapd/back-ldbm/idl.c

index 28243301907197768cd7e076f56c776301ff8e73..4668e7554df5bc858f48766d06424f714ffb3feb 100644 (file)
@@ -102,6 +102,7 @@ struct ldbminfo {
        struct cache            li_cache;
        Avlnode                 *li_attrs;
        int                     li_dbcachesize;
+       int                     li_flush_wrt;
        struct dbcache          li_dbcache[MAXDBCACHE];
        pthread_mutex_t         li_dbcache_mutex;
        pthread_cond_t          li_dbcache_cv;
index d6aca2c413fcd20213bd8f75e8d04b630ee5868f..241303630c55d472b0515a058fcdb0b0322b9b61 100644 (file)
@@ -77,6 +77,10 @@ ldbm_back_config(
                }
                li->li_dbcachesize = atoi( argv[1] );
 
+       /* flush on writes */
+       } else if ( strcasecmp( argv[0], "flushwrites" ) == 0 ) {
+               li->li_flush_wrt = 1;
+
        /* anything else */
        } else {
                fprintf( stderr,
index 4ee592da0748a1909ecea750c47e93d617461a25..45eeec8f10fea9412a5771dc9c902314b8021719 100644 (file)
@@ -20,9 +20,10 @@ dn2id_add(
     ID         id
 )
 {
-       int             rc;
+       int             rc, flags;
        struct dbcache  *db;
        Datum           key, data;
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
 
        Debug( LDAP_DEBUG_TRACE, "=> dn2id_add( \"%s\", %ld )\n", dn, id, 0 );
 
@@ -41,11 +42,10 @@ dn2id_add(
        data.dptr = (char *) &id;
        data.dsize = sizeof(ID);
 
-#ifdef LDBM_PESSIMISTIC
-       rc = ldbm_cache_store( db, key, data, LDBM_INSERT | LDBM_SYNC );
-#else
-       rc = ldbm_cache_store( db, key, data, LDBM_INSERT );
-#endif
+       flags = LDBM_INSERT;
+       if ( li->li_flush_wrt ) flags |= LDBM_SYNC;
+
+       rc = ldbm_cache_store( db, key, data, flags );
 
        free( dn );
        ldbm_cache_close( be, db );
index fbda3c9952a9461766d2f4024e072054ca61530a..f5a51089d71dd6b5c20cc4bdb30843a4f4a3cdcd 100644 (file)
@@ -20,7 +20,7 @@ id2entry_add( Backend *be, Entry *e )
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
        struct dbcache  *db;
        Datum           key, data;
-       int             len, rc;
+       int             len, rc, flags;
 
        Debug( LDAP_DEBUG_TRACE, "=> id2entry_add( %d, \"%s\" )\n", e->e_id,
            e->e_dn, 0 );
@@ -39,8 +39,10 @@ id2entry_add( Backend *be, Entry *e )
        data.dptr = entry2str( e, &len, 1 );
        data.dsize = len + 1;
 
-       /* store it - LDBM_SYNC ensures id2entry is always consistent */
-       rc = ldbm_cache_store( db, key, data, LDBM_REPLACE|LDBM_SYNC );
+       /* store it */
+       flags = LDBM_REPLACE;
+       if ( li->li_flush_wrt ) flags != LDBM_SYNC;
+       rc = ldbm_cache_store( db, key, data, flags );
 
        pthread_mutex_unlock( &entry2str_mutex );
 
index 7646765a0287cdd8f9aac63212c3a0c0f7ac148f..82cf19f3acfcdd7d199d8f7def524e9c741174a5 100644 (file)
@@ -163,19 +163,19 @@ idl_store(
     IDList             *idl
 )
 {
-       int     rc;
+       int     rc, flags;
        Datum   data;
+       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
 
        /* Debug( LDAP_DEBUG_TRACE, "=> idl_store\n", 0, 0, 0 ); */
 
        data.dptr = (char *) idl;
        data.dsize = (2 + idl->b_nmax) * sizeof(ID);
+       
+       flags = LDBM_REPLACE;
+       if( li->li_flush_wrt ) flags |= LDBM_SYNC;
 
-#ifdef LDBM_PESSIMISTIC
-       rc = ldbm_cache_store( db, key, data, LDBM_REPLACE | LDBM_SYNC );
-#else
-       rc = ldbm_cache_store( db, key, data, LDBM_REPLACE );
-#endif
+       rc = ldbm_cache_store( db, key, data, flags );
 
        /* Debug( LDAP_DEBUG_TRACE, "<= idl_store %d\n", rc, 0, 0 ); */
        return( rc );