ldap/servers/slapd/plugin.c | 47 +++++++++++++++++++++++++++++-----------
ldap/servers/slapd/proto-slap.h | 1
3 files changed, 37 insertions(+), 12 deletions(-)
New commits:
commit 5f7bcdca7a56f017e4cf021be7d07284fa1709e7
Author: Thierry Bordaz <tbordaz@redhat.com>
Date: Thu Jun 23 15:48:58 2016 +0200
Ticket 48891 ns-slapd crashes during the shutdown after adding attribute with a matching rule
Bug Description:
This is a followup of a previous fix of the same ticket
During shutdown, plugin close callback is called AND plugins
structures are freed (plugin_closeall).
Free of these structure in plugin_closeall was done to avoid
noise from valgrind (https://fedorahosted.org/389/ticket/47645).
Later, freeing backends (be_cleanupall) calls the plugins cleanup
callback.
The problem is that plugin structure have already been freed and
cleanup callback can be an invalid pointer.
Fix Description:
The free of plugins structure is postponed after plugin_closeall
and be_cleanup with a new function plugin_dependency_freeall.
The fix also fixes a leak in plugin_dependency_startall.
https://fedorahosted.org/389/ticket/48891
Reviewed by: Mark Reynolds and Noriko Hosoi (thanks to you !!)
Platforms tested: F23
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index bee2fc0..81a54cf 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1349,6 +1349,7 @@ void slapd_daemon( daemon_ports_t *ports )
the_connection_table= NULL;
be_cleanupall ();
+ plugin_dependency_freeall();
connection_post_shutdown_cleanup();
LDAPDebug( LDAP_DEBUG_TRACE, "slapd shutting down - backends closed down\n",
0, 0, 0 );
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index d377b33..c801bf4 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -1863,6 +1863,16 @@ plugin_dependency_startall(int argc, char** argv, char *errmsg, int operation, c
*/
plugin_free_plugin_dep_config(&config);
+ if(plugin_head){
+ plugin_dep_type next;
+ while(plugin_head){
+ next = plugin_head->next;
+ slapi_ch_free_string(&plugin_head->type);
+ slapi_ch_free((void *)&plugin_head);
+ plugin_head = next;
+ }
+ }
+
/* Finally enable registered plugin functions */
global_plugin_callbacks_enabled = 1;
@@ -1914,6 +1924,31 @@ plugin_dependency_closeall()
}
}
+/*
+ * Function: plugin_dependency_freeall
+ *
+ * Description: Free the plugin dependency list.
+ * It need to be called after be_cleanupall so that the
+ * ldbm_database plugin is not freed when be_cleanupall calls the cleanup
+ * callback of the backend
+ */
+void
+plugin_dependency_freeall()
+{
+ entry_and_plugin_t *iterp, *nextp;
+
+ /* free the plugin dependency entry list */
+ iterp = dep_plugin_entries;
+ while (iterp) {
+ nextp = iterp->next;
+ slapi_entry_free(iterp->e);
+ plugin_free(iterp->plugin);
+ slapi_ch_free((void **)&iterp);
+ iterp = nextp;
+ }
+ dep_plugin_entries = NULL;
+}
+
/***********************************************************
end of plugin dependency code
************************************************************/
@@ -1948,19 +1983,7 @@ plugin_startall(int argc, char** argv, char **plugin_list)
void
plugin_closeall(int close_backends, int close_globals)
{
- entry_and_plugin_t *iterp, *nextp;
-
plugin_dependency_closeall();
- /* free the plugin dependency entry list */
- iterp = dep_plugin_entries;
- while (iterp) {
- nextp = iterp->next;
- slapi_entry_free(iterp->e);
- plugin_free(iterp->plugin);
- slapi_ch_free((void **)&iterp);
- iterp = nextp;
- }
- dep_plugin_entries = NULL;
}
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 555d15d..6bc1065 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -884,6 +884,7 @@ int plugin_call_exop_plugins( Slapi_PBlock *pb, struct slapdplugin *p );
Slapi_Backend * plugin_extended_op_getbackend( Slapi_PBlock *pb, struct slapdplugin *p);
const char *plugin_extended_op_oid2string( const char *oid );
void plugin_closeall(int close_backends, int close_globals);
+void plugin_dependency_freeall();
void plugin_startall(int argc, char **argv, char **plugin_list);
void plugin_get_plugin_dependencies(char *plugin_name, char ***names);
struct slapdplugin *get_plugin_list(int plugin_list_index);
--
389-commits mailing list
389-commits@lists.fedoraproject.org
https://lists.fedoraproject.org/admin/lists/389-commits@lists.fedoraproject.org
No comments:
Post a Comment