diff options
author | Thierry Bordaz <tbordaz@redhat.com> | 2016-04-26 13:17:46 +0300 |
---|---|---|
committer | Alexander Bokovoy <abokovoy@redhat.com> | 2016-05-30 13:59:45 +0300 |
commit | c2dfe9836596565edea1fe7c2bffca3efc6839e2 (patch) | |
tree | 903c75d30f034af9909e055eae5fcfe4a93de79d | |
parent | 2faf2fe1b7724f8ae636d639ece45f63ed98d9f8 (diff) | |
download | slapi-nis-c2dfe9836596565edea1fe7c2bffca3efc6839e2.tar.gz slapi-nis-c2dfe9836596565edea1fe7c2bffca3efc6839e2.tar.xz slapi-nis-c2dfe9836596565edea1fe7c2bffca3efc6839e2.zip |
schema-compat: add backend shutdown support for priming thread
Resolves: rhbz#1327197
-rw-r--r-- | src/back-sch.c | 6 | ||||
-rw-r--r-- | src/plug-sch.c | 34 |
2 files changed, 33 insertions, 7 deletions
diff --git a/src/back-sch.c b/src/back-sch.c index 9a0e96b..32b1d9e 100644 --- a/src/back-sch.c +++ b/src/back-sch.c @@ -2280,6 +2280,12 @@ backend_startup(Slapi_PBlock *pb, struct plugin_state *state) backend_shr_startup(state, pb, SCH_CONTAINER_CONFIGURATION_FILTER); } +void +backend_shutdown(struct plugin_state *state) +{ + backend_shr_shutdown(state); +} + int backend_init_preop(Slapi_PBlock *pb, struct plugin_state *state) { diff --git a/src/plug-sch.c b/src/plug-sch.c index 95a4fd8..7af8480 100644 --- a/src/plug-sch.c +++ b/src/plug-sch.c @@ -102,13 +102,26 @@ plugin_startup(Slapi_PBlock *pb) /* Populate the maps and data. */ struct plugin_state *state; Slapi_Entry *plugin_entry = NULL; + Slapi_DN *pluginsdn = NULL; + slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &state); - slapi_pblock_get(pb, SLAPI_TARGET_DN, &state->plugin_base); - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, - "configuration entry is %s%s%s\n", - state->plugin_base ? "\"" : "", - state->plugin_base ? state->plugin_base : "NULL", - state->plugin_base ? "\"" : ""); + slapi_pblock_get(pb, SLAPI_TARGET_SDN, &pluginsdn); + /* plugin base need to be duplicated because it will be destroyed + * when pblock is destroyed but we need to use it in a separate thread */ + if (NULL == pluginsdn || 0 == slapi_sdn_get_ndn_len(pluginsdn)) { + slapi_log_error(SLAPI_LOG_FATAL, state->plugin_desc->spd_id, + "scheman compat plugin_startup: unable to retrieve plugin DN\n"); + return -1; + + } else { + state->plugin_base = slapi_ch_strdup(slapi_sdn_get_dn(pluginsdn)); + slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + "configuration entry is %s%s%s\n", + state->plugin_base ? "\"" : "", + state->plugin_base ? state->plugin_base : "NULL", + state->plugin_base ? "\"" : ""); + } + state->pam_lock = wrap_new_rwlock(); backend_nss_init_context((struct nss_ops_ctx**) &state->nss_context); if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) && @@ -122,6 +135,10 @@ plugin_startup(Slapi_PBlock *pb) state->cached_entries = PL_NewHashTable(0, PL_HashString, PL_CompareStrings, PL_CompareValues, 0, 0); wrap_rwlock_unlock(state->cached_entries_lock); /* Populate the tree of fake entries. */ + if (state->priming_mutex == NULL) { + state->priming_mutex = wrap_new_mutex(); + state->start_priming_thread = 1; + } backend_startup(pb, state); /* Note that the plugin is ready to go. */ slapi_log_error(SLAPI_LOG_PLUGIN, plugin_description.spd_id, @@ -147,6 +164,7 @@ plugin_shutdown(Slapi_PBlock *pb) { struct plugin_state *state; slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &state); + backend_shutdown(state); map_done(state); wrap_free_rwlock(state->pam_lock); state->pam_lock = NULL; @@ -160,7 +178,9 @@ plugin_shutdown(Slapi_PBlock *pb) wrap_free_rwlock(state->cached_entries_lock); state->cached_entries_lock = NULL; } - state->plugin_base = NULL; + if (state->plugin_base != NULL) { + slapi_ch_free((void **)&state->plugin_base); + } slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "plugin shutdown completed\n"); return 0; |