From 3aabc4ed4314855fe52810e780d6eecc34dcddf1 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 14 Apr 2003 00:07:48 +0000 Subject: [PATCH] doPlugins return code fix --- servers/slapd/add.c | 4 ++-- servers/slapd/backend.c | 4 ++-- servers/slapd/bind.c | 4 ++-- servers/slapd/compare.c | 4 ++-- servers/slapd/modify.c | 18 ++++++++++-------- servers/slapd/modrdn.c | 4 ++-- servers/slapd/search.c | 4 ++-- servers/slapd/slapi/plugin.c | 2 ++ 8 files changed, 24 insertions(+), 20 deletions(-) diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 208f882e66..3deabac3d6 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -523,7 +523,7 @@ static int doPreAddPluginFNs( Operation *op ) int rc; rc = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_ADD_FN, op->o_pb ); - if ( rc != 0 ) { + if ( rc < 0 ) { /* * A preoperation plugin failure will abort the * entire operation. @@ -549,7 +549,7 @@ static void doPostAddPluginFNs( Operation *op ) int rc; rc = doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_ADD_FN, op->o_pb ); - if ( rc != 0 ) { + if ( rc < 0 ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, "do_add: add postoperation plugin failed\n", 0, 0, 0); diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 3ee3331675..752dcf41a9 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -694,7 +694,7 @@ backend_unbind( Operation *op, SlapReply *rs ) slapi_pblock_set( pb, SLAPI_BACKEND, (void *)&backends[i] ); rc = doPluginFNs( &backends[i], SLAPI_PLUGIN_PRE_UNBIND_FN, (Slapi_PBlock *)pb ); - if ( rc != 0 ) { + if ( rc < 0 ) { /* * A preoperation plugin failure will abort the * entire operation. @@ -717,7 +717,7 @@ backend_unbind( Operation *op, SlapReply *rs ) #if defined( LDAP_SLAPI ) if ( doPluginFNs( &backends[i], SLAPI_PLUGIN_POST_UNBIND_FN, - (Slapi_PBlock *)pb ) != 0 ) { + (Slapi_PBlock *)pb ) < 0 ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, "do_unbind: Unbind postoperation plugins " "failed\n", 0, 0, 0); diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index b4c1cf72b1..112f099e05 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -528,7 +528,7 @@ do_bind( slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) ); rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_BIND_FN, pb ); - if ( rs->sr_err != SLAPI_BIND_SUCCESS ) { + if ( rs->sr_err < 0 ) { /* * Binding is a special case for SLAPI plugins. It is * possible for a bind plugin to be successful *and* @@ -641,7 +641,7 @@ do_bind( } #if defined( LDAP_SLAPI ) - if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb ) != 0 ) { + if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb ) < 0 ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, "do_bind: Bind postoperation plugins failed\n", 0, 0, 0); diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index d999b7c20f..fac29baddd 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -260,7 +260,7 @@ do_compare( slapi_pblock_set( pb, SLAPI_COMPARE_VALUE, (void *)&value ); rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_COMPARE_FN, pb ); - if ( rs->sr_err != 0 ) { + if ( rs->sr_err < 0 ) { /* * A preoperation plugin failure will abort the * entire operation. @@ -287,7 +287,7 @@ do_compare( } #if defined( LDAP_SLAPI ) - if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_COMPARE_FN, pb ) != 0 ) { + if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_COMPARE_FN, pb ) < 0 ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, "do_compare: compare postoperation plugins " "failed\n", 0, 0, 0 ); diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 40529e4a81..2ffa3767b0 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -327,7 +327,7 @@ do_modify( slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv ); rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODIFY_FN, pb ); - if ( rs->sr_err != 0 ) { + if ( rs->sr_err < 0 ) { /* * A preoperation plugin failure will abort the * entire operation. @@ -355,8 +355,9 @@ do_modify( * Calling slapi_x_modifications2ldapmods() destroyed modlist so * we don't need to free it. */ - slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv ); - modlist = slapi_x_ldapmods2modifications( modv ); + if ( rs->sr_err == 0 ) { + slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv ); + modlist = slapi_x_ldapmods2modifications( modv ); /* * NB: it is valid for the plugin to return no modifications @@ -366,10 +367,11 @@ do_modify( * then slapi_x_ldapmods2modifications() above will return * NULL). */ - if ( modlist == NULL ) { - rs->sr_err = LDAP_SUCCESS; - send_ldap_result( op, rs ); - goto cleanup; + if ( modlist == NULL ) { + rs->sr_err = LDAP_SUCCESS; + send_ldap_result( op, rs ); + goto cleanup; + } } #endif /* defined( LDAP_SLAPI ) */ @@ -447,7 +449,7 @@ do_modify( } #if defined( LDAP_SLAPI ) - if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) != 0 ) { + if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, "do_modify: modify postoperation plugins " "failed\n", 0, 0, 0 ); diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 8c5566375e..90651da75d 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -319,7 +319,7 @@ do_modrdn( slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit ); rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODRDN_FN, pb ); - if ( rs->sr_err != 0 ) { + if ( rs->sr_err < 0 ) { /* * A preoperation plugin failure will abort the * entire operation. @@ -378,7 +378,7 @@ do_modrdn( } #if defined( LDAP_SLAPI ) - if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODRDN_FN, pb ) != 0 ) { + if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODRDN_FN, pb ) < 0 ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, "do_modrdn: modrdn postoperation plugins " "failed\n", 0, 0, 0 ); diff --git a/servers/slapd/search.c b/servers/slapd/search.c index f94198b2fd..607bf02662 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -448,7 +448,7 @@ static int doPreSearchPluginFNs( Operation *op ) int rc; rc = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_SEARCH_FN, op->o_pb ); - if ( rc != 0 ) { + if ( rc < 0 ) { /* * A preoperation plugin failure will abort the * entire operation. @@ -494,7 +494,7 @@ static int doSearchRewriteFNs( Operation *op ) static void doPostSearchPluginFNs( Operation *op ) { - if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_SEARCH_FN, op->o_pb ) != 0 ) { + if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_SEARCH_FN, op->o_pb ) < 0 ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, "doPostSearchPluginFNs: search postoperation plugins " "failed\n", 0, 0, 0 ); diff --git a/servers/slapd/slapi/plugin.c b/servers/slapd/slapi/plugin.c index dbe02554b8..5deb326147 100644 --- a/servers/slapd/slapi/plugin.c +++ b/servers/slapd/slapi/plugin.c @@ -637,6 +637,8 @@ doPluginFNs( * failure (confirmed with SLAPI specification). */ if ( !SLAPI_PLUGIN_IS_POST_FN( funcType ) && rc != 0 ) { + /* make sure errors are negative */ + if ( rc > 0 ) rc = 0 - rc; break; } } -- 2.39.5