Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv18174/ldap/servers/slapd/back-ldbm
Modified Files: archive.c back-ldbm.h dblayer.c import.c ldif2ldbm.c Log Message: Resolves: 439907 Summary: Enhanced SLAPI task API and ported existing tasks to use new API.
Index: archive.c =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/archive.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- archive.c 4 Dec 2007 17:52:56 -0000 1.15 +++ archive.c 3 Apr 2008 16:52:47 -0000 1.16 @@ -61,7 +61,7 @@ slapi_pblock_get( pb, SLAPI_BACKEND_INSTANCE_NAME, &backendname); slapi_pblock_get( pb, SLAPI_BACKEND_TASK, &task ); slapi_pblock_get( pb, SLAPI_TASK_FLAGS, &task_flags ); - li->li_flags = run_from_cmdline = (task_flags & TASK_RUNNING_FROM_COMMANDLINE); + li->li_flags = run_from_cmdline = (task_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE);
if ( !rawdirectory || !*rawdirectory ) { LDAPDebug( LDAP_DEBUG_ANY, "archive2db: no archive name\n", @@ -273,7 +273,7 @@ slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li ); slapi_pblock_get( pb, SLAPI_SEQ_VAL, &rawdirectory ); slapi_pblock_get( pb, SLAPI_TASK_FLAGS, &task_flags ); - li->li_flags = run_from_cmdline = (task_flags & TASK_RUNNING_FROM_COMMANDLINE); + li->li_flags = run_from_cmdline = (task_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE);
slapi_pblock_get( pb, SLAPI_BACKEND_TASK, &task );
Index: back-ldbm.h =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/back-ldbm.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- back-ldbm.h 19 Oct 2007 02:09:24 -0000 1.12 +++ back-ldbm.h 3 Apr 2008 16:52:47 -0000 1.13 @@ -513,10 +513,10 @@ int li_legacy_errcode; /* 615428 -- in case legacy err code is expected */ };
-/* li_flags could store these bits defined in ../slap.h +/* li_flags could store these bits defined in ../slapi-plugin.h * task flag (pb_task_flags) * - * #define TASK_RUNNING_AS_TASK 0x0 - * #define TASK_RUNNING_FROM_COMMANDLINE 0x1 + * SLAPI_TASK_RUNNING_AS_TASK + * SLAPI_TASK_RUNNING_FROM_COMMANDLINE */ /* allow conf w/o CONFIG_FLAG_ALLOW_RUNNING_CHANGE to be updated */ #define LI_FORCE_MOD_CONFIG 0x10
Index: dblayer.c =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/dblayer.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- dblayer.c 4 Dec 2007 00:50:19 -0000 1.26 +++ dblayer.c 3 Apr 2008 16:52:47 -0000 1.27 @@ -1954,7 +1954,7 @@ oflags |= DB_PRIVATE; } PR_Lock(li->li_config_mutex); - if ((li->li_flags & TASK_RUNNING_FROM_COMMANDLINE) && + if ((li->li_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE) && (li->li_import_cache_autosize)) /* Autosizing importCache * Need to re-eval every time * to guarantee the memory is @@ -5678,7 +5678,7 @@ * dse_conf_verify may need to have db started, as well. */ /* If no logfiles were stored, then fatal recovery isn't required */
- if (li->li_flags & TASK_RUNNING_FROM_COMMANDLINE) + if (li->li_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE) { /* command line mode; no need to run db threads */ dbmode |= DBLAYER_NO_DBTHREADS_MODE; @@ -5707,7 +5707,7 @@ "Warning: Unable to verify the index configuration\n", 0, 0, 0); }
- if (li->li_flags & TASK_RUNNING_FROM_COMMANDLINE) { + if (li->li_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE) { /* command line: close the database down again */ tmp_rval = dblayer_close(li, dbmode); if (0 != tmp_rval) {
Index: import.c =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- import.c 18 Oct 2007 00:08:34 -0000 1.10 +++ import.c 3 Apr 2008 16:52:47 -0000 1.11 @@ -197,29 +197,19 @@ buffer, 0); }
-static int import_task_destroy(Slapi_Task *task) +static void import_task_destroy(Slapi_Task *task) { - ImportJob *job = (ImportJob *)task->task_private; - - if (task->task_log) { - slapi_ch_free((void **)&task->task_log); - } - - if (task->task_status) { - slapi_ch_free((void **)&task->task_status); - } - + ImportJob *job = (ImportJob *)slapi_task_get_data(task);
if (job && job->task_status) { slapi_ch_free((void **)&job->task_status); job->task_status = NULL; } FREE(job); - task->task_private = NULL; - return 0; + slapi_task_set_data(task, NULL); }
-static int import_task_abort(Slapi_Task *task) +static void import_task_abort(Slapi_Task *task) { ImportJob *job;
@@ -227,9 +217,8 @@ * DSE lock for modify... */
- if (task->task_state == SLAPI_TASK_FINISHED) { + if (slapi_task_get_state(task) == SLAPI_TASK_FINISHED) { /* too late */ - return 0; }
/* @@ -238,14 +227,12 @@ * because it will free the job. */
- job = (ImportJob *)task->task_private; + job = (ImportJob *)slapi_task_get_data(task);
import_abort_all(job, 0); - while (task->task_state != SLAPI_TASK_FINISHED) + while (slapi_task_get_state(task) != SLAPI_TASK_FINISHED) DS_Sleep(PR_MillisecondsToInterval(100));
- - return 0; }
@@ -1042,13 +1029,8 @@ slapi_ch_free_string(&inst_dirp); }
- if (job->task != NULL && 0 == job->task->task_refcount) { - /* exit code */ - job->task->task_exitcode = ret; - job->task->task_state = SLAPI_TASK_FINISHED; - job->task->task_progress = job->task->task_work; - job->task->task_private = NULL; - slapi_task_status_changed(job->task); + if ((job->task != NULL) && (0 == slapi_task_get_refcount(job->task))) { + slapi_task_finish(job->task, ret); }
if (job->flags & FLAG_ONLINE) { @@ -1093,7 +1075,7 @@ ImportWorkerInfo *producer = NULL;
if (job->task) - job->task->task_refcount++; + slapi_task_inc_refcount(job->task);
PR_ASSERT(inst != NULL); time(&beginning); @@ -1364,13 +1346,11 @@ if (0 != ret) { import_log_notice(job, "Import failed."); if (job->task != NULL) { - job->task->task_state = SLAPI_TASK_FINISHED; - job->task->task_exitcode = ret; - slapi_task_status_changed(job->task); + slapi_task_finish(job->task, ret); } } else { if (job->task) - job->task->task_refcount--; + slapi_task_dec_refcount(job->task);
import_all_done(job, ret); } @@ -1471,15 +1451,17 @@ /* add 1 to account for post-import cleanup (which can take a * significant amount of time) */ + /* NGK - This should eventually be cleaned up to use the public + * task API. */ if (0 == total_files) /* reindexing */ job->task->task_work = 2; else job->task->task_work = total_files + 1; job->task->task_progress = 0; job->task->task_state = SLAPI_TASK_RUNNING; - job->task->task_private = job; - job->task->destructor = import_task_destroy; - job->task->cancel = import_task_abort; + slapi_task_set_data(job->task, job); + slapi_task_set_destructor_fn(job->task, import_task_destroy); + slapi_task_set_cancel_fn(job->task, import_task_abort); job->flags |= FLAG_ONLINE;
/* create thread for import_main, so we can return */
Index: ldif2ldbm.c =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldif2ldbm.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- ldif2ldbm.c 13 Oct 2007 01:49:32 -0000 1.15 +++ ldif2ldbm.c 3 Apr 2008 16:52:47 -0000 1.16 @@ -568,7 +568,7 @@ /* hopefully this will go away once import is not run standalone... */
slapi_pblock_get(pb, SLAPI_TASK_FLAGS, &task_flags); - if (task_flags & TASK_RUNNING_FROM_COMMANDLINE) { + if (task_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE) { /* initialize UniqueID generator - must be done once backends are started and event queue is initialized but before plugins are started */ Slapi_DN *sdn = slapi_sdn_new_dn_byval ("cn=uniqueid generator,cn=config"); @@ -581,7 +581,7 @@ return -1; }
- li->li_flags |= TASK_RUNNING_FROM_COMMANDLINE; + li->li_flags |= SLAPI_TASK_RUNNING_FROM_COMMANDLINE; ldbm_config_load_dse_info(li); autosize_import_cache(li); } @@ -604,7 +604,7 @@
/***** prepare & init libdb and dblayer *****/
- if (! (task_flags & TASK_RUNNING_FROM_COMMANDLINE)) { + if (! (task_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE)) { /* shutdown this instance of the db */ LDAPDebug(LDAP_DEBUG_ANY, "Bringing %s offline...\n", instance_name, 0, 0); @@ -778,11 +778,11 @@ slapi_pblock_get( pb, SLAPI_TASK_FLAGS, &task_flags ); slapi_pblock_get( pb, SLAPI_DB2LDIF_DECRYPT, &decrypt ); slapi_pblock_get( pb, SLAPI_DB2LDIF_SERVER_RUNNING, &server_running ); - run_from_cmdline = (task_flags & TASK_RUNNING_FROM_COMMANDLINE); + run_from_cmdline = (task_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE);
dump_replica = pb->pb_ldif_dump_replica; if (run_from_cmdline) { - li->li_flags |= TASK_RUNNING_FROM_COMMANDLINE; + li->li_flags |= SLAPI_TASK_RUNNING_FROM_COMMANDLINE; if (!dump_replica) { we_start_the_backends = 1; } @@ -1298,12 +1298,12 @@ slapi_pblock_get(pb, SLAPI_BACKEND_INSTANCE_NAME, &instance_name); slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &li); slapi_pblock_get(pb, SLAPI_TASK_FLAGS, &task_flags); - run_from_cmdline = (task_flags & TASK_RUNNING_FROM_COMMANDLINE); + run_from_cmdline = (task_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE); slapi_pblock_get(pb, SLAPI_BACKEND_TASK, &task);
if (run_from_cmdline) { /* No ldbm backend exists until we process the config info. */ - li->li_flags |= TASK_RUNNING_FROM_COMMANDLINE; + li->li_flags |= SLAPI_TASK_RUNNING_FROM_COMMANDLINE; ldbm_config_load_dse_info(li); txn.back_txn_txn = NULL; /* no transaction */ } @@ -1764,6 +1764,8 @@ percent = (ep->ep_id*100 / (lastid ? lastid : 1)); } if (task) { + /* NGK - This should eventually be cleaned up to use the + * public task API */ task->task_progress = (idl ? idindex : ep->ep_id); task->task_work = (idl ? idl->b_nids : lastid); slapi_task_status_changed(task); @@ -1970,7 +1972,7 @@ slapi_pblock_get(pb, SLAPI_BACKEND_TASK, &task); slapi_pblock_get(pb, SLAPI_DB2LDIF_SERVER_RUNNING, &server_running);
- run_from_cmdline = (task_flags & TASK_RUNNING_FROM_COMMANDLINE); + run_from_cmdline = (task_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE); slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &li); if (run_from_cmdline) { @@ -2435,7 +2437,7 @@ int run_from_cmdline = 0;
slapi_pblock_get(pb, SLAPI_TASK_FLAGS, &task_flags); - run_from_cmdline = (task_flags & TASK_RUNNING_FROM_COMMANDLINE); + run_from_cmdline = (task_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE);
be = inst->inst_be; slapi_log_error(SLAPI_LOG_FATAL, "upgrade DB",