]> git.sur5r.net Git - openldap/commitdiff
Keep from ldbm_sync'ing a DBCache unless it has been changed.
authorMark Valence <mrv@openldap.org>
Mon, 5 Jun 2000 05:10:30 +0000 (05:10 +0000)
committerMark Valence <mrv@openldap.org>
Mon, 5 Jun 2000 05:10:30 +0000 (05:10 +0000)
servers/slapd/back-ldbm/back-ldbm.h
servers/slapd/back-ldbm/dbcache.c

index efb524cda5073a2cfdb54d23be138f0fdecd96ee..911140d003fe90fac7aeaab3075fafac8ddc3fe8 100644 (file)
@@ -93,6 +93,7 @@ typedef struct ldbm_dbcache {
        int             dbc_refcnt;
        int             dbc_maxids;
        int             dbc_maxindirect;
+       int             dbc_dirty;
        time_t  dbc_lastref;
        long    dbc_blksize;
        char    *dbc_name;
index 797af5370b2422ebc37632975d735a14f6a1cf17..ad65ddc73e2c945dcce3be9f623294a3ee48469b 100644 (file)
@@ -115,6 +115,7 @@ ldbm_cache_open(
        li->li_dbcache[i].dbc_name = ch_strdup( buf );
        li->li_dbcache[i].dbc_refcnt = 1;
        li->li_dbcache[i].dbc_lastref = curtime;
+       li->li_dbcache[i].dbc_dirty = 0;
 #ifdef HAVE_ST_BLKSIZE
        if ( stat( buf, &st ) == 0 ) {
                li->li_dbcache[i].dbc_blksize = st.st_blksize;
@@ -144,8 +145,9 @@ ldbm_cache_close( Backend *be, DBCache *db )
 {
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
 
-       if( li->li_dbwritesync ) {
+       if( li->li_dbwritesync && db->dbc_dirty ) {
                ldbm_sync( db->dbc_db );
+               db->dbc_dirty = 0;
        }
 
        ldap_pvt_thread_mutex_lock( &li->li_dbcache_mutex );
@@ -182,6 +184,7 @@ ldbm_cache_flush_all( Backend *be )
                        Debug( LDAP_DEBUG_TRACE, "ldbm flushing db (%s)\n",
                            li->li_dbcache[i].dbc_name, 0, 0 );
                        ldbm_sync( li->li_dbcache[i].dbc_db );
+                       li->li_dbcache[i].dbc_dirty = 0;
                        if ( li->li_dbcache[i].dbc_refcnt != 0 ) {
                                Debug( LDAP_DEBUG_TRACE,
                                       "refcnt = %d, couldn't close db (%s)\n",
@@ -242,6 +245,7 @@ ldbm_cache_store(
                flags, 0, 0, 0, 0 );
 #endif /* LDBM_DEBUG */
 
+       db->dbc_dirty = 1;
        rc = ldbm_store( db->dbc_db, key, data, flags );
 
        return( rc );
@@ -255,6 +259,7 @@ ldbm_cache_delete(
 {
        int     rc;
 
+       db->dbc_dirty = 1;
        rc = ldbm_delete( db->dbc_db, key );
 
        return( rc );