From 457cf54b708015520a8566088930c9c4f5bd6677 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Thu, 10 Jul 2008 15:15:18 -0400 Subject: - add a helper for checking if we've been called by ourselves - if a search was initiated by us, don't bother (and also don't deadlock) --- src/back-sch.c | 8 ++++++++ src/back-shr.c | 9 +++++++++ src/backend.h | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/src/back-sch.c b/src/back-sch.c index e11a7c6..3038978 100644 --- a/src/back-sch.c +++ b/src/back-sch.c @@ -730,6 +730,14 @@ backend_search_cb(Slapi_PBlock *pb) cbdata.matched = ""; cbdata.text = ""; cbdata.n_entries = 0; + if (backend_shr_is_caller(cbdata.state, cbdata.pb)) { + slapi_log_error(SLAPI_LOG_PLUGIN, + cbdata.state->plugin_desc->spd_id, + "ignoring self-started search from \"%s\" for " + "\"%s\" with scope %d\n", + cbdata.target, cbdata.strfilter, cbdata.scope); + return 0; + } slapi_log_error(SLAPI_LOG_PLUGIN, cbdata.state->plugin_desc->spd_id, "searching from \"%s\" for \"%s\" with scope %d\n", cbdata.target, cbdata.strfilter, cbdata.scope); diff --git a/src/back-shr.c b/src/back-shr.c index e21f5ee..0561e11 100644 --- a/src/back-shr.c +++ b/src/back-shr.c @@ -49,6 +49,15 @@ #include "plugin.h" #include "map.h" +/* Check if the caller for the current operation is *us*. */ +bool_t +backend_shr_is_caller(struct plugin_state *state, Slapi_PBlock *pb) +{ + Slapi_ComponentId *identity; + slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &identity); + return (identity == state->plugin_identity); +} + /* Read the name of this server. Used by the map module on behalf of the * NIS service logic. */ void diff --git a/src/backend.h b/src/backend.h index bd44fc7..bf7bb40 100644 --- a/src/backend.h +++ b/src/backend.h @@ -71,4 +71,9 @@ void backend_set_config_free_config(struct backend_shr_set_data *set_data); * requiring a restart. */ void backend_update_params(struct plugin_state *state); +/* Check if the operation which this pblock describes was initiated by the + * current plugin. */ +bool_t backend_shr_is_caller(struct plugin_state *state, + struct slapi_pblock *pb); + #endif -- cgit