From 715b03d5abe2cde94507ff2a717fe2471bb06366 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 3 Mar 2009 00:07:17 +0000 Subject: [PATCH] make sure sequence progresses correctly (ITS#5986) --- servers/slapd/backglue.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index 4e8e094891..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; -- 2.39.5