ldap/servers/plugins/linkedattrs/fixup_task.c | 79 +++++++++++++-------------
ldap/servers/plugins/memberof/memberof.c | 15 ++++
ldap/servers/plugins/usn/usn_cleanup.c | 10 ++-
3 files changed, 63 insertions(+), 41 deletions(-)
New commits:
commit 1bde54db66bef3c392206f343f904d32c19dabc6
Author: Mark Reynolds <mareynol(a)redhat.com>
Date: Thu Jan 19 09:55:28 2012 -0500
Ticket #49 - better handling for server shutdown while long running tasks are active
https://fedorahosted.org/389/ticket/49
Bug Description: tasks like memberOf fix-up do not check for shutdown events. In my
test this causes a shutdown
to hang until the task is complete. I did not get crash in my
tests.
Fix Description: The only plugins that appear to have lengthy tasks are: usn,
linkedattrtrs, and memberOf. Added checks for g_get_shutdown.
Also cleaned up some code & fixed some indentation issues.
diff --git a/ldap/servers/plugins/linkedattrs/fixup_task.c
b/ldap/servers/plugins/linkedattrs/fixup_task.c
index ef2c7e0..ee64d71 100644
--- a/ldap/servers/plugins/linkedattrs/fixup_task.c
+++ b/ldap/servers/plugins/linkedattrs/fixup_task.c
@@ -130,8 +130,8 @@ linked_attrs_fixup_task_thread(void *arg)
int rc = 0;
Slapi_Task *task = (Slapi_Task *)arg;
task_data *td = NULL;
- PRCList *main_config = NULL;
- int found_config = 0;
+ PRCList *main_config = NULL;
+ int found_config = 0;
/* Fetch our task data from the task */
td = (task_data *)slapi_task_get_data(task);
@@ -144,51 +144,50 @@ linked_attrs_fixup_task_thread(void *arg)
"Syntax validate task starting (link dn: \"%s\")
...\n",
td->linkdn ? td->linkdn : "");
- linked_attrs_read_lock();
- main_config = linked_attrs_get_config();
- if (!PR_CLIST_IS_EMPTY(main_config)) {
- struct configEntry *config_entry = NULL;
- PRCList *list = PR_LIST_HEAD(main_config);
-
- while (list != main_config) {
- config_entry = (struct configEntry *) list;
-
- /* See if this is the requested config and fix up if so. */
- if (td->linkdn) {
- if (strcasecmp(td->linkdn, config_entry->dn) == 0) {
- found_config = 1;
- slapi_task_log_notice(task, "Fixing up linked attribute pair
(%s)\n",
- config_entry->dn);
- slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
- "Fixing up linked attribute pair (%s)\n",
- config_entry->dn);
-
- linked_attrs_fixup_links(config_entry, NULL);
- break;
- }
- } else {
- /* No config DN was supplied, so fix up all configured links. */
+ linked_attrs_read_lock();
+ main_config = linked_attrs_get_config();
+ if (!PR_CLIST_IS_EMPTY(main_config)) {
+ struct configEntry *config_entry = NULL;
+ PRCList *list = PR_LIST_HEAD(main_config);
+
+ while (list != main_config) {
+ config_entry = (struct configEntry *) list;
+
+ /* See if this is the requested config and fix up if so. */
+ if (td->linkdn) {
+ if (strcasecmp(td->linkdn, config_entry->dn) == 0) {
+ found_config = 1;
slapi_task_log_notice(task, "Fixing up linked attribute pair
(%s)\n",
- config_entry->dn);
+ config_entry->dn);
slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
- "Fixing up linked attribute pair (%s)\n",
config_entry->dn);
+ "Fixing up linked attribute pair (%s)\n",
config_entry->dn);
linked_attrs_fixup_links(config_entry, NULL);
+ break;
}
-
- list = PR_NEXT_LINK(list);
+ } else {
+ /* No config DN was supplied, so fix up all configured links. */
+ slapi_task_log_notice(task, "Fixing up linked attribute pair
(%s)\n",
+ config_entry->dn);
+ slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
+ "Fixing up linked attribute pair (%s)\n",
config_entry->dn);
+
+ linked_attrs_fixup_links(config_entry, NULL);
}
- }
- /* Log a message if we didn't find the requested attribute pair. */
- if (td->linkdn && !found_config) {
- slapi_task_log_notice(task, "Requested link config DN not found
(%s)\n",
- td->linkdn);
- slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
- "Requested link config DN not found (%s)\n",
td->linkdn);
+ list = PR_NEXT_LINK(list);
}
+ }
- linked_attrs_unlock();
+ /* Log a message if we didn't find the requested attribute pair. */
+ if (td->linkdn && !found_config) {
+ slapi_task_log_notice(task, "Requested link config DN not found
(%s)\n",
+ td->linkdn);
+ slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM,
+ "Requested link config DN not found (%s)\n", td->linkdn);
+ }
+
+ linked_attrs_unlock();
/* Log finished message. */
slapi_task_log_notice(task, "Linked attributes fixup task complete.\n");
@@ -364,6 +363,10 @@ linked_attrs_add_backlinks_callback(Slapi_Entry *e, void
*callback_data)
int perform_update = 0;
Slapi_DN *targetsdn = slapi_sdn_new_dn_byref(targetdn);
+ if (g_get_shutdown()) {
+ return -1;
+ }
+
if (config->scope) {
/* Check if the target is within the scope. */
perform_update = slapi_dn_issuffix(targetdn, config->scope);
diff --git a/ldap/servers/plugins/memberof/memberof.c
b/ldap/servers/plugins/memberof/memberof.c
index 9956dfe..db6cd3e 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -667,7 +667,9 @@ int memberof_postop_modrdn(Slapi_PBlock *pb)
{
if(0 == slapi_entry_attr_find(post_e, configCopy.groupattrs[i], &attr))
{
- memberof_moddn_attr_list(pb, &configCopy, pre_dn, post_dn, attr, txn);
+ if(memberof_moddn_attr_list(pb, &configCopy, pre_dn, post_dn, attr, txn) != 0){
+ break;
+ }
}
}
}
@@ -1266,7 +1268,10 @@ int memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig
*config,
slapi_entry_attr_find( e, config->groupattrs[i], &members );
if(members)
{
- memberof_mod_attr_list_r(pb, config, mod_op, group_dn, op_this, members, ll, txn);
+ if(memberof_mod_attr_list_r(pb, config, mod_op, group_dn, op_this, members, ll, txn)
!= 0){
+ rc = -1;
+ goto bail;
+ }
}
}
@@ -1668,6 +1673,11 @@ int memberof_get_groups_callback(Slapi_Entry *e, void
*callback_data)
Slapi_ValueSet *groupvals = *((memberof_get_groups_data*)callback_data)->groupvals;
int rc = 0;
+ if(g_get_shutdown()){
+ rc = -1;
+ goto bail;
+ }
+
if (!groupvals)
{
slapi_log_error( SLAPI_LOG_PLUGIN, MEMBEROF_PLUGIN_SUBSYSTEM,
@@ -2441,6 +2451,7 @@ int memberof_fix_memberof_callback(Slapi_Entry *e, void
*callback_data)
memberof_del_dn_type_callback(e, &del_data);
}
+bail:
slapi_valueset_free(groups);
return rc;
diff --git a/ldap/servers/plugins/usn/usn_cleanup.c
b/ldap/servers/plugins/usn/usn_cleanup.c
index 3152975..16e6a95 100644
--- a/ldap/servers/plugins/usn/usn_cleanup.c
+++ b/ldap/servers/plugins/usn/usn_cleanup.c
@@ -46,7 +46,6 @@ struct usn_cleanup_data {
char *maxusn_to_delete;
};
-
static int usn_cleanup_add(Slapi_PBlock *pb, Slapi_Entry *e,
Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg);
@@ -143,6 +142,15 @@ usn_cleanup_thread(void *arg)
int delrv = 0;
const Slapi_DN *sdn = slapi_entry_get_sdn_const(*ep);
+ /* check for shutdown */
+ if(g_get_shutdown()){
+ slapi_task_log_notice(task, "USN tombstone cleanup task aborted due to
shutdown.");
+ slapi_task_log_status(task, "USN tombstone cleanup task aborted due to
shutdown.");
+ slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
+ "USN tombstone cleanup task aborted due to
shutdown.\n");
+ goto bail;
+ }
+
slapi_delete_internal_set_pb(delete_pb, slapi_sdn_get_dn(sdn),
NULL, NULL, usn_get_identity(), 0);
slapi_delete_internal_pb(delete_pb);