From: Howard Chu Date: Sat, 15 Oct 2005 20:08:56 +0000 (+0000) Subject: ITS#4089 use slapcat -n XX to specify just the superior of a glued tree X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~233 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=10a696bd1522c384be2188bb49f20ad06f4fab11;p=openldap ITS#4089 use slapcat -n XX to specify just the superior of a glued tree --- diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index bc17618b36..71a1884dfe 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -919,6 +919,51 @@ glue_sub_add( BackendDB *be, int advert, int online ) return rc; } +/* Detach all glued subordinates from the superior. Only + * called in tool mode. + */ +void +glue_sub_detach( BackendDB *be ) +{ + slap_overinfo *oi = (slap_overinfo *)be->bd_info; + slap_overinst *on, **oprev; + + /* If glue is the only overlay, just remove the overlay framework */ + if ( oi->oi_list->on_bi.bi_type == glue.on_bi.bi_type && + oi->oi_list->on_next == NULL ) { + /* We don't do any cleanup. Doesn't matter in tool mode. */ + be->bd_info = oi->oi_orig; + return; + } + + /* There are multiple overlays, just drop ours from the list */ + for ( on=oi->oi_list, oprev = &oi->oi_list; on; on=on->on_next ) { + if ( on->on_bi.bi_type == glue.on_bi.bi_type ) { + *oprev = on->on_next; + break; + } + oprev = &on->on_next; + + /* Undo the glue_db_init() changes in oi */ + oi->oi_bi.bi_open = oi->oi_orig->bi_open; + oi->oi_bi.bi_close = oi->oi_orig->bi_close; + + oi->oi_bi.bi_entry_release_rw = oi->oi_orig->bi_entry_release_rw; + + oi->oi_bi.bi_tool_entry_open = oi->oi_orig->bi_tool_entry_open; + oi->oi_bi.bi_tool_entry_close = oi->oi_orig->bi_tool_entry_close; + oi->oi_bi.bi_tool_entry_first = oi->oi_orig->bi_tool_entry_first; + oi->oi_bi.bi_tool_entry_get = oi->oi_orig->bi_tool_entry_get; + oi->oi_bi.bi_tool_entry_put = oi->oi_orig->bi_tool_entry_put; + oi->oi_bi.bi_tool_entry_reindex = oi->oi_orig->bi_tool_entry_reindex; + oi->oi_bi.bi_tool_sync = oi->oi_orig->bi_tool_sync; + oi->oi_bi.bi_tool_dn2id_get = oi->oi_orig->bi_tool_dn2id_get; + oi->oi_bi.bi_tool_id2entry_get = oi->oi_orig->bi_tool_id2entry_get; + oi->oi_bi.bi_tool_entry_modify = oi->oi_orig->bi_tool_entry_modify; + } + return; +} + int glue_sub_init() { diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index d9c0ab2436..41fed65294 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -404,6 +404,7 @@ LDAP_SLAPD_F (int) glue_sub_init( void ); LDAP_SLAPD_F (int) glue_sub_attach( void ); LDAP_SLAPD_F (int) glue_sub_add( BackendDB *be, int advert, int online ); LDAP_SLAPD_F (int) glue_sub_del( BackendDB *be ); +LDAP_SLAPD_F (void) glue_sub_detach( BackendDB *be ); /* * backover.c diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index eb82e2da38..ddec1a2447 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -560,6 +560,12 @@ slap_tool_init( if ( dbnum == 0 ) break; dbnum--; } + /* If a glued database is specified by number, just operate + * on the single database. + */ + if ( SLAP_GLUE_INSTANCE( be ) ) { + glue_sub_detach( be ); + } } startup:;