X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fbackglue.c;h=b3ca5d48322e997f3a384d0736eb455339b88b80;hb=eb3e92481bfbc655164e5c66aa3499a4315ac6ea;hp=cf53b0b5e35976c97a20631ba599933693e1884a;hpb=84374348e5fe44b43db3acf7dc7b1ae3ffb351b1;p=openldap diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index cf53b0b5e3..b3ca5d4832 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -52,6 +52,8 @@ static slap_overinst glue; static int glueMode; static BackendDB *glueBack; +static BackendDB glueBackDone; +#define GLUEBACK_DONE (&glueBackDone) static slap_response glue_op_response; @@ -591,7 +593,7 @@ glue_tool_entry_close ( { int rc = 0; - if (glueBack) { + if (glueBack && glueBack != GLUEBACK_DONE) { if (!glueBack->be_entry_close) return 0; rc = glueBack->be_entry_close (glueBack); @@ -740,6 +742,7 @@ glue_tool_entry_first ( slap_overinst *on = glue_tool_inst( b0->bd_info ); glueinfo *gi = on->on_bi.bi_private; int i; + ID rc; /* If we're starting from scratch, start at the most general */ if (!glueBack) { @@ -759,7 +762,26 @@ glue_tool_entry_first ( glueBack->be_entry_open (glueBack, glueMode) != 0) return NOID; - return glueBack->be_entry_first (glueBack); + rc = glueBack->be_entry_first (glueBack); + while ( rc == NOID ) { + if ( glueBack && glueBack->be_entry_close ) + glueBack->be_entry_close (glueBack); + for (i=0; igi_nodes; i++) { + if (gi->gi_n[i].gn_be == glueBack) + break; + } + if (i == 0) { + glueBack = GLUEBACK_DONE; + break; + } else { + glueBack = gi->gi_n[i-1].gn_be; + rc = glue_tool_entry_first (b0); + if ( glueBack == GLUEBACK_DONE ) { + break; + } + } + } + return rc; } static ID @@ -786,11 +808,14 @@ glue_tool_entry_next ( break; } if (i == 0) { - glueBack = NULL; + glueBack = GLUEBACK_DONE; break; } else { glueBack = gi->gi_n[i-1].gn_be; rc = glue_tool_entry_first (b0); + if ( glueBack == GLUEBACK_DONE ) { + break; + } } } return rc; @@ -949,6 +974,7 @@ typedef struct glue_Addrec { /* List of added subordinates */ static glue_Addrec *ga_list; +static int ga_adding; static int glue_db_init( @@ -1002,8 +1028,10 @@ glue_db_init( SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_INSTANCE; - if ( ga_list ) + if ( ga_list ) { + be->bd_info = (BackendInfo *)oi; glue_sub_attach( 1 ); + } return 0; } @@ -1087,6 +1115,11 @@ glue_sub_attach( int online ) glue_Addrec *ga, *gnext = NULL; int rc = 0; + if ( ga_adding ) + return 0; + + ga_adding = 1; + /* For all the subordinate backends */ for ( ga=ga_list; ga != NULL; ga = gnext ) { BackendDB *be; @@ -1135,8 +1168,11 @@ glue_sub_attach( int online ) /* allow this for now, assume a superior will * be added later */ - if ( online ) - return 0; + if ( online ) { + rc = 0; + gnext = ga_list; + break; + } rc = LDAP_NO_SUCH_OBJECT; } ch_free( ga ); @@ -1145,6 +1181,8 @@ glue_sub_attach( int online ) ga_list = gnext; + ga_adding = 0; + return rc; }