Commit 6b46232a authored by Ondřej Kuzník's avatar Ondřej Kuzník Committed by Quanah Gibson-Mount
Browse files

ITS#8473 Implement ordering stable (de)registration

parent e5105e70
...@@ -1418,8 +1418,13 @@ config_generic(ConfigArgs *c) { ...@@ -1418,8 +1418,13 @@ config_generic(ConfigArgs *c) {
case CFG_SYNC_SUBENTRY: case CFG_SYNC_SUBENTRY:
break; break;
/* no-ops, requires slapd restart */ #ifdef LDAP_SLAPI
case CFG_PLUGIN: case CFG_PLUGIN:
slapi_int_unregister_plugins(c->be, c->valx);
break;
#endif
/* no-op, requires slapd restart */
case CFG_MODLOAD: case CFG_MODLOAD:
snprintf(c->log, sizeof( c->log ), "change requires slapd restart"); snprintf(c->log, sizeof( c->log ), "change requires slapd restart");
break; break;
...@@ -2409,7 +2414,7 @@ sortval_reject: ...@@ -2409,7 +2414,7 @@ sortval_reject:
#ifdef LDAP_SLAPI #ifdef LDAP_SLAPI
case CFG_PLUGIN: case CFG_PLUGIN:
if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv) != LDAP_SUCCESS) if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv, c->valx) != LDAP_SUCCESS)
return(1); return(1);
slapi_plugins_used++; slapi_plugins_used++;
break; break;
......
...@@ -129,7 +129,7 @@ done: ...@@ -129,7 +129,7 @@ done:
/********************************************************************* /*********************************************************************
* Function Name: slapi_int_register_plugin * Function Name: slapi_int_register_plugin
* *
* Description: insert the slapi_pblock structure to the end of the plugin * Description: insert the slapi_pblock structure to a given position the end of the plugin
* list * list
* *
* Input: a pointer to a plugin slapi_pblock structure to be added to * Input: a pointer to a plugin slapi_pblock structure to be added to
...@@ -143,21 +143,23 @@ done: ...@@ -143,21 +143,23 @@ done:
* Messages: None * Messages: None
*********************************************************************/ *********************************************************************/
int int
slapi_int_register_plugin( slapi_int_register_plugin_index(
Backend *be, Backend *be,
Slapi_PBlock *pPB ) Slapi_PBlock *pPB,
int index )
{ {
Slapi_PBlock *pTmpPB; Slapi_PBlock *pTmpPB;
Slapi_PBlock *pSavePB; Slapi_PBlock *pSavePB;
int rc = LDAP_SUCCESS; int pos = 0, rc = LDAP_SUCCESS;
assert( be != NULL ); assert( be != NULL );
pTmpPB = SLAPI_BACKEND_PBLOCK( be ); pTmpPB = SLAPI_BACKEND_PBLOCK( be );
if ( pTmpPB == NULL ) { if ( pTmpPB == NULL || index == 0 ) {
SLAPI_BACKEND_PBLOCK( be ) = pPB; SLAPI_BACKEND_PBLOCK( be ) = pPB;
} else { } else {
while ( pTmpPB != NULL && rc == LDAP_SUCCESS ) { while ( pTmpPB != NULL && rc == LDAP_SUCCESS &&
( index < 0 || pos++ < index ) ) {
pSavePB = pTmpPB; pSavePB = pTmpPB;
rc = slapi_pblock_get( pTmpPB, SLAPI_IBM_PBLOCK, &pTmpPB ); rc = slapi_pblock_get( pTmpPB, SLAPI_IBM_PBLOCK, &pTmpPB );
} }
...@@ -167,9 +169,21 @@ slapi_int_register_plugin( ...@@ -167,9 +169,21 @@ slapi_int_register_plugin(
} }
} }
if ( index >= 0 && rc == LDAP_SUCCESS ) {
rc = slapi_pblock_set( pPB, SLAPI_IBM_PBLOCK, (void *)pTmpPB );
}
return ( rc != LDAP_SUCCESS ) ? LDAP_OTHER : LDAP_SUCCESS; return ( rc != LDAP_SUCCESS ) ? LDAP_OTHER : LDAP_SUCCESS;
} }
int
slapi_int_register_plugin(
Backend *be,
Slapi_PBlock *pPB )
{
return slapi_int_register_plugin_index( be, pPB, -1 );
}
/********************************************************************* /*********************************************************************
* Function Name: slapi_int_get_plugins * Function Name: slapi_int_get_plugins
* *
...@@ -630,7 +644,8 @@ slapi_int_read_config( ...@@ -630,7 +644,8 @@ slapi_int_read_config(
const char *fname, const char *fname,
int lineno, int lineno,
int argc, int argc,
char **argv ) char **argv,
int index )
{ {
int iType = -1; int iType = -1;
int numPluginArgc = 0; int numPluginArgc = 0;
...@@ -690,7 +705,7 @@ slapi_int_read_config( ...@@ -690,7 +705,7 @@ slapi_int_read_config(
} }
} }
rc = slapi_int_register_plugin( be, pPlugin ); rc = slapi_int_register_plugin_index( be, pPlugin, index );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
if ( iType == SLAPI_PLUGIN_EXTENDEDOP ) { if ( iType == SLAPI_PLUGIN_EXTENDEDOP ) {
slapi_int_unregister_extop( be, &pGExtendedOps, pPlugin ); slapi_int_unregister_extop( be, &pGExtendedOps, pPlugin );
...@@ -703,6 +718,74 @@ slapi_int_read_config( ...@@ -703,6 +718,74 @@ slapi_int_read_config(
return 0; return 0;
} }
int
slapi_int_unregister_plugin(
Backend *be,
Slapi_PBlock *pPlugin,
Slapi_PBlock *pPrev
)
{
int type;
assert( pPlugin != NULL );
slapi_pblock_get( pPlugin, SLAPI_PLUGIN_TYPE, (void *)&type );
if ( type == SLAPI_PLUGIN_EXTENDEDOP ) {
slapi_int_unregister_extop( be, &pGExtendedOps, pPlugin );
}
if ( pPrev != NULL ) {
Slapi_PBlock *pNext = NULL;
slapi_pblock_get( pPlugin, SLAPI_IBM_PBLOCK, &pNext );
slapi_pblock_set( pPrev, SLAPI_IBM_PBLOCK, &pNext );
}
slapi_pblock_destroy( pPlugin );
return LDAP_SUCCESS;
}
int
slapi_int_unregister_plugins(
Backend *be,
int index
)
{
Slapi_PBlock *pTmpPB = NULL;
Slapi_PBlock *pSavePB = NULL;
int rc = LDAP_SUCCESS;
pTmpPB = SLAPI_BACKEND_PBLOCK( be );
if ( pTmpPB == NULL ) {
return ( index < 0 ) ? LDAP_SUCCESS : LDAP_OTHER;
}
if ( index < 0 ) {
/* All plugins must go */
while ( pTmpPB != NULL && rc == LDAP_SUCCESS ) {
pSavePB = pTmpPB;
rc = slapi_pblock_get( pTmpPB, SLAPI_IBM_PBLOCK, &pTmpPB );
if ( pSavePB != NULL ) {
slapi_int_unregister_plugin( be, pSavePB, NULL );
}
}
} else if ( index == 0 ) {
slapi_pblock_get( pTmpPB, SLAPI_IBM_PBLOCK, &pSavePB );
SLAPI_BACKEND_PBLOCK( be ) = pSavePB;
slapi_int_unregister_plugin( be, pTmpPB, NULL );
} else {
int pos = -1;
while ( pTmpPB != NULL && rc == LDAP_SUCCESS && ++pos < index ) {
pSavePB = pTmpPB;
rc = slapi_pblock_get( pTmpPB, SLAPI_IBM_PBLOCK, &pTmpPB );
}
if ( pos == index ) {
slapi_int_unregister_plugin( be, pTmpPB, pSavePB );
}
}
return rc;
}
void void
slapi_int_plugin_unparse( slapi_int_plugin_unparse(
Backend *be, Backend *be,
......
...@@ -65,13 +65,15 @@ LDAP_SLAPI_F (int) slapi_int_pblock_get_next LDAP_P(( Slapi_PBlock **pb )); ...@@ -65,13 +65,15 @@ LDAP_SLAPI_F (int) slapi_int_pblock_get_next LDAP_P(( Slapi_PBlock **pb ));
/* plugin.c */ /* plugin.c */
LDAP_SLAPI_F (int) slapi_int_register_plugin LDAP_P((Backend *be, Slapi_PBlock *pPB)); LDAP_SLAPI_F (int) slapi_int_register_plugin LDAP_P((Backend *be, Slapi_PBlock *pPB));
LDAP_SLAPI_F (int) slapi_int_register_plugin_index LDAP_P((Backend *be, Slapi_PBlock *pPB, int index));
LDAP_SLAPI_F (int) slapi_int_call_plugins LDAP_P((Backend *be, int funcType, Slapi_PBlock * pPB)); LDAP_SLAPI_F (int) slapi_int_call_plugins LDAP_P((Backend *be, int funcType, Slapi_PBlock * pPB));
LDAP_SLAPI_F (int) slapi_int_get_plugins LDAP_P((Backend *be, int functype, SLAPI_FUNC **ppFuncPtrs)); LDAP_SLAPI_F (int) slapi_int_get_plugins LDAP_P((Backend *be, int functype, SLAPI_FUNC **ppFuncPtrs));
LDAP_SLAPI_F (int) slapi_int_register_extop LDAP_P((Backend *pBE, ExtendedOp **opList, Slapi_PBlock *pPB)); LDAP_SLAPI_F (int) slapi_int_register_extop LDAP_P((Backend *pBE, ExtendedOp **opList, Slapi_PBlock *pPB));
LDAP_SLAPI_F (int) slapi_int_get_extop_plugin LDAP_P((struct berval *reqoid, SLAPI_FUNC *pFuncAddr )); LDAP_SLAPI_F (int) slapi_int_get_extop_plugin LDAP_P((struct berval *reqoid, SLAPI_FUNC *pFuncAddr ));
LDAP_SLAPI_F (struct berval *) slapi_int_get_supported_extop LDAP_P(( int )); LDAP_SLAPI_F (struct berval *) slapi_int_get_supported_extop LDAP_P(( int ));
LDAP_SLAPI_F (int) slapi_int_unregister_plugins LDAP_P((Backend *be, int index));
LDAP_SLAPI_F (int) slapi_int_read_config LDAP_P((Backend *be, const char *fname, int lineno, LDAP_SLAPI_F (int) slapi_int_read_config LDAP_P((Backend *be, const char *fname, int lineno,
int argc, char **argv )); int argc, char **argv, int index ));
LDAP_SLAPI_F (void) slapi_int_plugin_unparse LDAP_P((Backend *be, BerVarray *out )); LDAP_SLAPI_F (void) slapi_int_plugin_unparse LDAP_P((Backend *be, BerVarray *out ));
LDAP_SLAPI_F (int) slapi_int_initialize LDAP_P((void)); LDAP_SLAPI_F (int) slapi_int_initialize LDAP_P((void));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment