char *pdn;
Entry *p = NULL;
int rootlock = 0;
- int rc, rc_id;
+ int rc;
+ ID id = NOID;
const char *text = NULL;
AttributeDescription *children = slap_schema.si_ad_children;
char textbuf[SLAP_TEXT_BUFLEN];
/* nobody else can add until we lock our parent */
ldap_pvt_thread_mutex_lock(&li->li_add_mutex);
- if ( ( dn2id( be, e->e_ndn, &rc_id ) ) != NOID || rc_id ) {
- /* if (rc_id) something bad happened to ldbm cache */
+ if ( ( rc = dn2id( be, e->e_ndn, &id ) ) || id != NOID ) {
+ /* if (rc) something bad happened to ldbm cache */
ldap_pvt_thread_mutex_unlock(&li->li_add_mutex);
send_ldap_result( conn, op,
- rc_id ? LDAP_OPERATIONS_ERROR : LDAP_ALREADY_EXISTS,
+ rc ? LDAP_OPERATIONS_ERROR : LDAP_ALREADY_EXISTS,
NULL, NULL, NULL, NULL );
return( -1 );
}
return( rc );
}
-ID
+int
dn2id(
Backend *be,
const char *dn,
- int *rc
+ ID *idp
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
DBCache *db;
- ID id;
Datum key, data;
- *rc = 0;
-
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
"dn2id: (%s)\n", dn ));
Debug( LDAP_DEBUG_TRACE, "=> dn2id( \"%s\" )\n", dn, 0, 0 );
#endif
+ assert( idp );
/* first check the cache */
- if ( (id = cache_find_entry_dn2id( be, &li->li_cache, dn )) != NOID ) {
+ if ( (*idp = cache_find_entry_dn2id( be, &li->li_cache, dn )) != NOID ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
- "dn2id: (%s)%ld in cache.\n", dn, id ));
+ "dn2id: (%s)%ld in cache.\n", dn, *idp ));
#else
- Debug( LDAP_DEBUG_TRACE, "<= dn2id %ld (in cache)\n", id,
+ Debug( LDAP_DEBUG_TRACE, "<= dn2id %ld (in cache)\n", *idp,
0, 0 );
#endif
- return( id );
+ return( 0 );
}
if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT ))
* return code !0 if ldbm cache open failed;
* callers should handle this
*/
- *rc = -1;
- return( NOID );
+ *idp = NOID;
+ return( -1 );
}
ldbm_datum_init( key );
Debug( LDAP_DEBUG_TRACE, "<= dn2id NOID\n", 0, 0, 0 );
#endif
- return( NOID );
+ *idp = NOID;
+ return( 0 );
}
- AC_MEMCPY( (char *) &id, data.dptr, sizeof(ID) );
+ AC_MEMCPY( (char *) idp, data.dptr, sizeof(ID) );
- assert( id != NOID );
+ assert( *idp != NOID );
ldbm_datum_free( db->dbc_db, data );
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
- "dn2id: %ld\n", id ));
+ "dn2id: %ld\n", *idp ));
#else
- Debug( LDAP_DEBUG_TRACE, "<= dn2id %ld\n", id, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "<= dn2id %ld\n", *idp, 0, 0 );
#endif
- return( id );
+ return( 0 );
}
ID_BLOCK *
ID id;
Entry *e = NULL;
char *pdn;
- int rc_id = 0;
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
*matched = NULL;
}
- if ( (id = dn2id( be, dn, &rc_id )) != NOID &&
- (e = id2entry_rw( be, id, rw )) != NULL )
- {
- return( e );
- }
+ if ( dn2id( be, dn, &id ) ) {
+ /* something bad happened to ldbm cache */
+ return( NULL );
+
+ } else if ( id != NOID ) {
+ /* try to return the entry */
+ if ((e = id2entry_rw( be, id, rw )) != NULL ) {
+ return( e );
+ }
- if ( id != NOID ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
"dn2entry_rw: no entry for valid id (%ld), dn (%s)\n",
/* must have been deleted from underneath us */
/* treat as if NOID was found */
- } else if ( rc_id ) {
- /* something bad happened to ldbm cache */
- return NULL;
}
/* caller doesn't care about match */