Ticket 47451 - add/enable/disable/remove plugins without server restart
Previous Design: All plugins were only loaded at startup. A global plugin list,
a shutdown list, and plugin DN hash are created.
New Design: The lists/hash are now all protected by a r/w lock. The read lock
is only used when calling plugin_call_func(), the write lock is used
for adding and removing plugins. Since plugins can call plugins,
etc, the locking in the plugin_call_* functions is determined by
the use of local thread storage: is locked, or is not locked.
This mechanism prevents deadlocks.
Plugin updates(add, mod, delete) happen in the pre op stage of a
dse update, so that we can reject the update before the config is
updated, otherwise at the next server restart the server might
unexpectedly fail to start.
Plugins can now be added/enabled and deleted/disabled dynamically.
All plugin configuration (libpath, type, precedence, etc) is now
updated dynamically, unless that change breaks something. Then it
is not dynamically applied, but it is still written to the dse.ldif.
A new internal reference counter has been added to plugin_call_func().
These are used to keep track of the active number of concurrent
operations being performed by the plugin. This is used when disabling
a plugin or server shutdown - so that we do not free global locks and
config while there are still operations using them. Since tasks do not
have access to the slapd plugin structure(for the plugin operation count),
they have their own ref counter where needed. This task counter is
implemented when the task is created using slapi_plugin_task_new(),
instead of slapi_task_new(). Also, slapi_task_register_handler, needs
to be replaced with slapi_plugin_task_register_handler().
Plugins that register callbacks shouldi not use slapi_config_register_callback(),
and now use slapi_config_register_callback_plugin() - which takes
the pblock so the reference counters can be updated.
Plugins that create object extensions must also unregister those
extensions in the CLOSE function, as same goes for config callbacks.
This feature can also be turned on/off via "nsslapd-dynamic-pluings: on|off"
https://fedorahosted.org/389/ticket/47451
Jenkins: Passed.
Coverity: Passed.
Valgrind: Passed.
Reviewed by: rmeggins(Thanks!!)