From: Pierangelo Masarati Date: Mon, 2 Jul 2001 19:42:27 +0000 (+0000) Subject: separate ID return value form return status in dn2id (back-ldbm/dn2id.c) X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1272 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fdd45144ca443bb8c5650c0e0946b4354951629d;p=openldap separate ID return value form return status in dn2id (back-ldbm/dn2id.c) --- diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index 07eed6b582..65fa8748a9 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -28,7 +28,7 @@ ldbm_back_add( char *pdn; Entry *p = NULL; int rootlock = 0; - int rc; + int rc, rc_id; const char *text = NULL; AttributeDescription *children = slap_schema.si_ad_children; char textbuf[SLAP_TEXT_BUFLEN]; @@ -45,9 +45,11 @@ ldbm_back_add( /* nobody else can add until we lock our parent */ ldap_pvt_thread_mutex_lock(&li->li_add_mutex); - if ( ( dn2id( be, e->e_ndn ) ) != NOID ) { + if ( ( dn2id( be, e->e_ndn, &rc_id ) ) != NOID || rc_id ) { + /* if (rc_id) something bad happened to ldbm cache */ ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); - send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, + send_ldap_result( conn, op, + rc_id ? LDAP_OPERATIONS_ERROR : LDAP_ALREADY_EXISTS, NULL, NULL, NULL, NULL ); return( -1 ); } diff --git a/servers/slapd/back-ldbm/dn2id.c b/servers/slapd/back-ldbm/dn2id.c index 8841ef1435..0dc80f0710 100644 --- a/servers/slapd/back-ldbm/dn2id.c +++ b/servers/slapd/back-ldbm/dn2id.c @@ -116,7 +116,8 @@ dn2id_add( ID dn2id( Backend *be, - const char *dn + const char *dn, + int *rc ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; @@ -124,6 +125,8 @@ dn2id( ID id; Datum key, data; + *rc = 0; + #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, "dn2id: (%s)\n", dn )); @@ -154,7 +157,11 @@ dn2id( Debug( LDAP_DEBUG_ANY, "<= dn2id could not open dn2id%s\n", LDBM_SUFFIX, 0, 0 ); #endif - + /* + * return code !0 if ldbm cache open failed; + * callers should handle this + */ + *rc = -1; return( NOID ); } @@ -356,6 +363,7 @@ dn2entry_rw( ID id; Entry *e = NULL; char *pdn; + int rc_id = 0; #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, @@ -372,7 +380,7 @@ dn2entry_rw( *matched = NULL; } - if ( (id = dn2id( be, dn )) != NOID && + if ( (id = dn2id( be, dn, &rc_id )) != NOID && (e = id2entry_rw( be, id, rw )) != NULL ) { return( e ); @@ -391,6 +399,9 @@ dn2entry_rw( /* 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 */ diff --git a/servers/slapd/back-ldbm/idl.c b/servers/slapd/back-ldbm/idl.c index 9603cd4b79..a0491cbca7 100644 --- a/servers/slapd/back-ldbm/idl.c +++ b/servers/slapd/back-ldbm/idl.c @@ -80,7 +80,7 @@ idl_free( ID_BLOCK *idl ) if ( idl == NULL ) { #ifdef NEW_LOGGING LDAP_LOG(( "cache", LDAP_LEVEL_INFO, - "idl_freee: called with NULL pointer\n" )); + "idl_free: called with NULL pointer\n" )); #else Debug( LDAP_DEBUG_TRACE, "idl_free: called with NULL pointer\n", diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index bee7da9f94..01661991e0 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -51,7 +51,7 @@ ldbm_back_modrdn( Entry *e, *p = NULL; Entry *matched; int rootlock = 0; - int rc = -1; + int rc = -1, rc_id = 0; const char *text = NULL; char textbuf[SLAP_TEXT_BUFLEN]; size_t textlen = sizeof textbuf; @@ -380,8 +380,10 @@ ldbm_back_modrdn( } ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); - if (dn2id ( be, new_ndn ) != NOID) { - send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, + if (dn2id ( be, new_ndn, &rc_id ) != NOID || rc_id ) { + /* if (rc_id) something bad happened to ldbm cache */ + send_ldap_result( conn, op, + rc_id ? LDAP_OPERATIONS_ERROR : LDAP_ALREADY_EXISTS, NULL, NULL, NULL, NULL ); goto return_results; } diff --git a/servers/slapd/back-ldbm/proto-back-ldbm.h b/servers/slapd/back-ldbm/proto-back-ldbm.h index a6798ce513..ccefe6d583 100644 --- a/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -77,7 +77,7 @@ void *ldbm_cache_sync_daemon LDAP_P(( void *)); */ int dn2id_add LDAP_P(( Backend *be, const char *dn, ID id )); -ID dn2id LDAP_P(( Backend *be, const char *dn )); +ID dn2id LDAP_P(( Backend *be, const char *dn, int *rc )); ID_BLOCK *dn2idl LDAP_P(( Backend *be, const char *dn, int prefix )); int dn2id_delete LDAP_P(( Backend *be, const char *dn, ID id )); diff --git a/servers/slapd/back-ldbm/tools.c b/servers/slapd/back-ldbm/tools.c index 5327af5a05..6bbbfc6166 100644 --- a/servers/slapd/back-ldbm/tools.c +++ b/servers/slapd/back-ldbm/tools.c @@ -156,7 +156,7 @@ ID ldbm_tool_entry_put( { struct ldbminfo *li = (struct ldbminfo *) be->be_private; Datum key, data; - int rc, len; + int rc, len, rc_id; ID id; assert( slapMode & SLAP_TOOL_MODE ); @@ -176,7 +176,7 @@ ID ldbm_tool_entry_put( e->e_id, e->e_dn, 0 ); #endif - id = dn2id( be, e->e_ndn ); + id = dn2id( be, e->e_ndn, &rc_id ); if( id != NOID ) { #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, @@ -188,9 +188,11 @@ ID ldbm_tool_entry_put( e->e_ndn, id, 0 ); #endif return NOID; + } else if ( rc_id ) { + /* something bad happened to ldbm cache */ + return NOID; } - rc = index_entry_add( be, e, e->e_attrs ); if( rc != 0 ) { return NOID;