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;
}
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,
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 );
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 );
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 );
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 );
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 );