mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-02-17 14:00:30 +08:00
Added ldbm flush on write code which uses slapd.conf option.
This commit is contained in:
parent
05c63ed421
commit
49d40a26f8
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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 );
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -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 );
|
||||
|
Loading…
Reference in New Issue
Block a user