ldap/servers/slapd/back-ldbm/import.c | 12 ++++++++++++ ldap/servers/slapd/task.c | 8 ++++++-- 2 files changed, 18 insertions(+), 2 deletions(-)
New commits: commit 02514d67c9929406b2b57792f0954c934f7d8464 Author: Noriko Hosoi nhosoi@redhat.com Date: Fri Mar 19 10:24:32 2010 -0700
515805 - Stop "initialize Database" crashes the server
https://bugzilla.redhat.com/show_bug.cgi?id=515805
Fix Description: SLAPI_TASK_CANCELLED could be set in task_modify any time by users' modifying nsTaskCancel value to TRUE. Then the following slapi_task_status_changed destroys the task, which is called even via a simple logging call slapi_task_log_status. After the task is destroyed, any task related calls such as another slapi_task_log_status or slapi_task_finish crashes the server.
This fix changes the behaviour to destroy the task only when task_state is SLAPI_TASK_FINISHED. Once SLAPI_TASK_CANCELLED is set to task_state, changing the state to SLAPI_TASK_FINISHED by calling slapi_task_finish is the responsibility of the task application (e.g., import). Until then, it is guranteed that the task is available.
diff --git a/ldap/servers/slapd/back-ldbm/import.c b/ldap/servers/slapd/back-ldbm/import.c index 7606739..df0fa5d 100644 --- a/ldap/servers/slapd/back-ldbm/import.c +++ b/ldap/servers/slapd/back-ldbm/import.c @@ -1075,6 +1075,7 @@ int import_main_offline(void *arg) int finished = 0; int status = 0; int verbose = 1; + int aborted = 0; ImportWorkerInfo *producer = NULL;
if (job->task) @@ -1193,6 +1194,7 @@ int import_main_offline(void *arg) */ import_set_abort_flag_all(job, 1); import_log_notice(job, "Import threads aborted."); + aborted = 1; goto error; }
@@ -1294,6 +1296,16 @@ error: /* If we fail, the database is now in a mess, so we delete it */ import_log_notice(job, "Closing files..."); cache_clear(&job->inst->inst_cache); + if (aborted) { + /* If aborted, it's safer to rebuild the cache. */ + cache_destroy_please(&job->inst->inst_cache); + /* initialize the entry cache */ + if (! cache_init(&(inst->inst_cache), DEFAULT_CACHE_SIZE, + DEFAULT_CACHE_ENTRIES)) { + LDAPDebug0Args(LDAP_DEBUG_ANY, "import_main_offline: " + "cache_init failed. Server should be restarted.\n"); + } + } if (0 != ret) { dblayer_delete_instance_dir(be); dblayer_instance_close(job->inst->inst_be); diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c index 67109b2..733618f 100644 --- a/ldap/servers/slapd/task.c +++ b/ldap/servers/slapd/task.c @@ -309,8 +309,11 @@ void slapi_task_status_changed(Slapi_Task *task) for (i = 0; i < cur; i++) slapi_ch_free((void **)&modlist[i].mod_values);
- if (((task->task_state == SLAPI_TASK_FINISHED) || - (task->task_state == SLAPI_TASK_CANCELLED)) && + /* + * Removed (task->task_state == SLAPI_TASK_CANCELLED) from + * task_state checking to fix bz 515805. + */ + if ((task->task_state == SLAPI_TASK_FINISHED) && !(task->task_flags & SLAPI_TASK_DESTROYING)) { Slapi_PBlock *pb = slapi_pblock_new(); Slapi_Entry *e; @@ -664,6 +667,7 @@ static void task_generic_destructor(Slapi_Task *task) } if (task->task_log_lock) { PR_DestroyLock(task->task_log_lock); + task->task_log_lock = NULL; } task->task_log = task->task_status = NULL; }
389-commits@lists.fedoraproject.org