|
|
6b9042 |
From 3aaf4941fc17df388c43776eda6d41f62017a143 Mon Sep 17 00:00:00 2001
|
|
|
6b9042 |
From: Alexander Bokovoy <abokovoy@redhat.com>
|
|
|
6b9042 |
Date: Fri, 15 Jan 2016 17:17:23 +0200
|
|
|
6b9042 |
Subject: [PATCH 09/12] slapi-nis: serialize map cache initialization
|
|
|
6b9042 |
|
|
|
6b9042 |
Serialize process of initiliazing map cache to avoid locking the
|
|
|
6b9042 |
directory server backends.
|
|
|
6b9042 |
---
|
|
|
6b9042 |
src/back-shr.c | 55 +++++++++++++++++++++++++++++++++++++------------------
|
|
|
6b9042 |
1 file changed, 37 insertions(+), 18 deletions(-)
|
|
|
6b9042 |
|
|
|
6b9042 |
diff --git a/src/back-shr.c b/src/back-shr.c
|
|
|
6b9042 |
index 131365d..0157582 100644
|
|
|
6b9042 |
--- a/src/back-shr.c
|
|
|
6b9042 |
+++ b/src/back-shr.c
|
|
|
6b9042 |
@@ -678,49 +678,68 @@ backend_shr_data_initialize_thread_cb(void *arg)
|
|
|
6b9042 |
struct backend_shr_data_init_cbdata *cbdata = (struct backend_shr_data_init_cbdata *)arg;
|
|
|
6b9042 |
Slapi_PBlock *pb = NULL;
|
|
|
6b9042 |
struct backend_set_config_entry_add_cbdata set_cbdata;
|
|
|
6b9042 |
- int result = 0;
|
|
|
6b9042 |
+ int result = 0, i = 0;
|
|
|
6b9042 |
+ Slapi_Entry **entries = NULL;
|
|
|
6b9042 |
+ struct plugin_state *state = NULL;
|
|
|
6b9042 |
+
|
|
|
6b9042 |
if (cbdata == NULL) {
|
|
|
6b9042 |
return;
|
|
|
6b9042 |
}
|
|
|
6b9042 |
|
|
|
6b9042 |
+ state = cbdata->state;
|
|
|
6b9042 |
+
|
|
|
6b9042 |
/* Scan may require consulting SSSD for external identities
|
|
|
6b9042 |
* therefore, we need to make sure the scan starts after ns-slapd
|
|
|
6b9042 |
* started to serve LDAP clients. There is no a signal for this,
|
|
|
6b9042 |
* so we just wait some time. */
|
|
|
6b9042 |
DS_Sleep(PR_SecondsToInterval(PLUGIN_SCAN_DELAY));
|
|
|
6b9042 |
|
|
|
6b9042 |
- backend_update_params(cbdata->parent_pb, cbdata->state);
|
|
|
6b9042 |
+ backend_update_params(cbdata->parent_pb, state);
|
|
|
6b9042 |
|
|
|
6b9042 |
slapi_log_error(SLAPI_LOG_PLUGIN,
|
|
|
6b9042 |
- cbdata->state->plugin_desc->spd_id,
|
|
|
6b9042 |
+ state->plugin_desc->spd_id,
|
|
|
6b9042 |
"searching under \"%s\" for configuration\n",
|
|
|
6b9042 |
- cbdata->state->plugin_base);
|
|
|
6b9042 |
+ state->plugin_base);
|
|
|
6b9042 |
pb = wrap_pblock_new(cbdata->parent_pb);
|
|
|
6b9042 |
slapi_search_internal_set_pb(pb,
|
|
|
6b9042 |
- cbdata->state->plugin_base,
|
|
|
6b9042 |
+ state->plugin_base,
|
|
|
6b9042 |
LDAP_SCOPE_ONELEVEL,
|
|
|
6b9042 |
cbdata->filter,
|
|
|
6b9042 |
NULL, FALSE,
|
|
|
6b9042 |
NULL,
|
|
|
6b9042 |
NULL,
|
|
|
6b9042 |
- cbdata->state->plugin_identity,
|
|
|
6b9042 |
+ state->plugin_identity,
|
|
|
6b9042 |
0);
|
|
|
6b9042 |
- if (map_wrlock() != 0) {
|
|
|
6b9042 |
- slapi_log_error(SLAPI_LOG_PLUGIN,
|
|
|
6b9042 |
- cbdata->state->plugin_desc->spd_id,
|
|
|
6b9042 |
+ wrap_inc_call_level();
|
|
|
6b9042 |
+ set_cbdata.state = state;
|
|
|
6b9042 |
+ set_cbdata.pb = pb;
|
|
|
6b9042 |
+
|
|
|
6b9042 |
+ /* Do a search and collect found entries to avoid locking the backends */
|
|
|
6b9042 |
+ if (slapi_search_internal_pb(pb) == 0) {
|
|
|
6b9042 |
+ if (map_wrlock() != 0) {
|
|
|
6b9042 |
+ slapi_log_error(SLAPI_LOG_PLUGIN,
|
|
|
6b9042 |
+ state->plugin_desc->spd_id,
|
|
|
6b9042 |
"failed to search under \"%s\" for "
|
|
|
6b9042 |
"configuration: failed to acquire a lock\n",
|
|
|
6b9042 |
- cbdata->state->plugin_base);
|
|
|
6b9042 |
- goto done_with_lock;
|
|
|
6b9042 |
+ state->plugin_base);
|
|
|
6b9042 |
+ goto done_with_lock;
|
|
|
6b9042 |
+ }
|
|
|
6b9042 |
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
|
|
|
6b9042 |
+ if (result == 0) {
|
|
|
6b9042 |
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
|
|
|
6b9042 |
+ for (i = 0; entries[i] != NULL; i++) {
|
|
|
6b9042 |
+ backend_set_config_entry_add_cb(entries[i], &set_cbdata);
|
|
|
6b9042 |
+ }
|
|
|
6b9042 |
+ }
|
|
|
6b9042 |
+ map_unlock();
|
|
|
6b9042 |
+ slapi_free_search_results_internal(pb);
|
|
|
6b9042 |
}
|
|
|
6b9042 |
- set_cbdata.state = cbdata->state;
|
|
|
6b9042 |
- set_cbdata.pb = pb;
|
|
|
6b9042 |
- slapi_search_internal_callback_pb(pb, &set_cbdata,
|
|
|
6b9042 |
- NULL,
|
|
|
6b9042 |
- backend_set_config_entry_add_cb,
|
|
|
6b9042 |
- NULL);
|
|
|
6b9042 |
- map_unlock();
|
|
|
6b9042 |
+ slapi_log_error(SLAPI_LOG_FATAL,
|
|
|
6b9042 |
+ state->plugin_desc->spd_id,
|
|
|
6b9042 |
+ "Finished plugin initialization.\n");
|
|
|
6b9042 |
+
|
|
|
6b9042 |
done_with_lock:
|
|
|
6b9042 |
+ wrap_dec_call_level();
|
|
|
6b9042 |
slapi_pblock_destroy(pb);
|
|
|
6b9042 |
if (cbdata) {
|
|
|
6b9042 |
slapi_ch_free((void**)&cbdata);
|
|
|
6b9042 |
--
|
|
|
6b9042 |
2.5.0
|
|
|
6b9042 |
|