static void *sidgen_task_thread(void *arg) { Slapi_Task *task = (Slapi_Task *)arg; struct worker_ctx *worker_ctx; int ret; if (task == NULL) { LOG_FATAL("Missing task data!\n"); ret =SLAPI_DSE_CALLBACK_OK; goto done; } worker_ctx = slapi_task_get_data(task); if (worker_ctx == NULL) { LOG_FATAL("Missing context!\n"); ret =SLAPI_DSE_CALLBACK_OK; goto done; } slapi_task_begin(task, 1); LOG_FATAL("Sidgen task starts ...\n"); ret = do_work(worker_ctx); done: LOG_FATAL("Sidgen task finished [%d].\n", ret); slapi_task_inc_progress(task); slapi_task_finish(task, ret); return NULL; }
/* * Task thread * Not necessary be a thread, but it'd not disturb the server's other jobs. */ static void task_sampletask_thread(void *arg) { Slapi_Task *task = (Slapi_Task *)arg; char *myarg = NULL; int i, rv = 0; int total_work = 3; /* fetch our argument from the task */ myarg = (char *)slapi_task_get_data(task); /* update task state to show it's running */ slapi_task_begin(task, total_work); slapi_task_log_notice(task, "Sample task starts (arg: %s) ...\n", myarg); slapi_log_err(SLAPI_LOG_ERR, "sampletask", "Sample task starts (arg: %s) ...\n", myarg); /* real work would be done here */ for (i = 0; i < total_work; i++) { PR_Sleep(10000); slapi_task_inc_progress(task); } /* update task state to say we're finished */ slapi_task_log_notice(task, "Sample task finished."); slapi_task_log_status(task, "Sample task finished."); slapi_log_err(SLAPI_LOG_ERR, "sampletask", "Sample task finished.\n"); /* this will queue the destruction of the task */ slapi_task_finish(task, rv); }
static void 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; /* Fetch our task data from the task */ td = (task_data *)slapi_task_get_data(task); /* init and set the bind dn in the thread data */ slapi_td_set_dn(slapi_ch_strdup(td->bind_dn)); /* Log started message. */ slapi_task_begin(task, 1); slapi_task_log_notice(task, "Linked attributes fixup task starting (link dn: \"%s\") ...\n", td->linkdn ? td->linkdn : ""); slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM, "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); break; } } 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); } list = PR_NEXT_LINK(list); } } /* 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"); slapi_task_log_status(task, "Linked attributes fixup task complete.\n"); slapi_log_error(SLAPI_LOG_FATAL, LINK_PLUGIN_SUBSYSTEM, "Linked attributes fixup task complete.\n"); slapi_task_inc_progress(task); /* this will queue the destruction of the task */ slapi_task_finish(task, rc); }