X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-ldbm%2Fid2entry.c;h=e42c1f0e511e8d704204c4f71b8fef202f98c8a3;hb=bd756bff354c1a4033144049ac3d4a11427bf2de;hp=c458ca503ffe8f1dc1d49826a3e80cc7b0498181;hpb=0c3899577f5000e25cfa2248b8dcc3aec5af2b56;p=openldap diff --git a/servers/slapd/back-ldbm/id2entry.c b/servers/slapd/back-ldbm/id2entry.c index c458ca503f..e42c1f0e51 100644 --- a/servers/slapd/back-ldbm/id2entry.c +++ b/servers/slapd/back-ldbm/id2entry.c @@ -9,13 +9,6 @@ #include "slap.h" #include "back-ldbm.h" -extern struct dbcache *ldbm_cache_open(); -extern Datum ldbm_cache_fetch(); -extern char *dn_parent(); -extern Entry *str2entry(); -extern char *entry2str(); -extern pthread_mutex_t entry2str_mutex; - int id2entry_add( Backend *be, Entry *e ) { @@ -24,12 +17,10 @@ id2entry_add( Backend *be, Entry *e ) Datum key, data; int len, rc, flags; -#ifdef HAVE_BERKELEY_DB2 - memset( &key, 0, sizeof( key ) ); - memset( &data, 0, sizeof( data ) ); -#endif + ldbm_datum_init( key ); + ldbm_datum_init( data ); - Debug( LDAP_DEBUG_TRACE, "=> id2entry_add( %d, \"%s\" )\n", e->e_id, + Debug( LDAP_DEBUG_TRACE, "=> id2entry_add( %lu, \"%s\" )\n", e->e_id, e->e_dn, 0 ); if ( (db = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, LDBM_WRCREAT )) @@ -48,7 +39,7 @@ id2entry_add( Backend *be, Entry *e ) /* store it */ flags = LDBM_REPLACE; - if ( li->li_flush_wrt ) flags |= LDBM_SYNC; + if ( li->li_dbcachewsync ) flags |= LDBM_SYNC; rc = ldbm_cache_store( db, key, data, flags ); pthread_mutex_unlock( &entry2str_mutex ); @@ -70,7 +61,7 @@ id2entry_delete( Backend *be, Entry *e ) Datum key; int rc; - Debug( LDAP_DEBUG_TRACE, "=> id2entry_delete( %d, \"%s\" )\n", e->e_id, + Debug(LDAP_DEBUG_TRACE, "=> id2entry_delete( %lu, \"%s\" )\n", e->e_id, e->e_dn, 0 ); /* XXX - check for writer lock - should also check no reader pending */ @@ -78,9 +69,7 @@ id2entry_delete( Backend *be, Entry *e ) assert(pthread_rdwr_wchk_np(&e->e_rdwr)); #endif -#ifdef HAVE_BERKELEY_DB2 - memset( &key, 0, sizeof( key ) ); -#endif + ldbm_datum_init( key ); /* XXX - check for writer lock - should also check no reader pending */ Debug (LDAP_DEBUG_TRACE, @@ -95,7 +84,7 @@ id2entry_delete( Backend *be, Entry *e ) } if ( cache_delete_entry( &li->li_cache, e ) != 0 ) { - Debug( LDAP_DEBUG_ANY, "could not delete %d (%s) from cache\n", + Debug(LDAP_DEBUG_ANY, "could not delete %lu (%s) from cache\n", e->e_id, e->e_dn, 0 ); } @@ -119,17 +108,15 @@ id2entry( Backend *be, ID id, int rw ) Datum key, data; Entry *e; -#ifdef HAVE_BERKELEY_DB2 - memset( &key, 0, sizeof( key ) ); - memset( &data, 0, sizeof( data ) ); -#endif + ldbm_datum_init( key ); + ldbm_datum_init( data ); Debug( LDAP_DEBUG_TRACE, "=> id2entry_%s( %ld )\n", rw ? "w" : "r", id, 0 ); if ( (e = cache_find_entry_id( &li->li_cache, id, rw )) != NULL ) { - Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s 0x%x (cache)\n", - rw ? "w" : "r", e, 0 ); + Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s 0x%lx (cache)\n", + rw ? "w" : "r", (unsigned long)e, 0 ); return( e ); } @@ -185,7 +172,7 @@ id2entry_r( Backend *be, ID id ) } Entry * -id2entry_2( Backend *be, ID id ) +id2entry_w( Backend *be, ID id ) { return( id2entry( be, id, 1 ) ); }