summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2006-12-14 23:16:54 +0000
committerNoriko Hosoi <nhosoi@redhat.com>2006-12-14 23:16:54 +0000
commitb05e86a1004cccbe0573b3268b7c8a428323967e (patch)
tree425070b153f9d8da59c6fa6f82474c6655a9de92
parentb956c18caff3237a9cdb562139184cdd9595a0c6 (diff)
downloadds-b05e86a1004cccbe0573b3268b7c8a428323967e.tar.gz
ds-b05e86a1004cccbe0573b3268b7c8a428323967e.tar.xz
ds-b05e86a1004cccbe0573b3268b7c8a428323967e.zip
Resolves: #195305, #195307
Summary: [195305] make new_task() non-static Changes: provide slapi_new_task and slapi_destroy_task as slapi APIs Summary: [195307] task registration by plugins is wiped by task_init() Changes: clean up old tasks before plugin_startall
-rw-r--r--ldap/servers/slapd/main.c7
-rw-r--r--ldap/servers/slapd/mapping_tree.c5
-rw-r--r--ldap/servers/slapd/slapi-plugin.h56
-rw-r--r--ldap/servers/slapd/slapi-private.h37
-rw-r--r--ldap/servers/slapd/task.c38
5 files changed, 97 insertions, 46 deletions
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 5a6aa111..e0f0203d 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -1056,6 +1056,13 @@ main( int argc, char **argv)
LDAPDebug( LDAP_DEBUG_PLUGIN,
"Password Modify plugin registered.\n", 0, 0, 0 );
+ /* Cleanup old tasks that may still be in the DSE from a previous
+ session. Call before plugin_startall since cleanup needs to be
+ done before plugin_startall where user defined task plugins could
+ be started.
+ */
+ task_cleanup();
+
plugin_startall(argc, argv, 1 /* Start Backends */, 1 /* Start Globals */);
if (housekeeping_start((time_t)0, NULL) == NULL) {
exit (1);
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
index 39c971dc..5667b0b4 100644
--- a/ldap/servers/slapd/mapping_tree.c
+++ b/ldap/servers/slapd/mapping_tree.c
@@ -2445,7 +2445,8 @@ static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb,
/* return next backend, increment index */
*be = target_node->mtn_be[*index];
if(*be==NULL) {
- if (target_node->mtn_be_states[*index] == SLAPI_BE_STATE_DELETE) {
+ if (NULL != target_node->mtn_be_states &&
+ target_node->mtn_be_states[*index] == SLAPI_BE_STATE_DELETE) {
/* This MTN is being deleted */
*be = defbackend_get_backend();
} else {
@@ -2816,7 +2817,7 @@ slapi_on_internal_backends(const Slapi_DN *sdn)
/* Some of the operations are not allowed from the plugins
* but default to specialized use of those operations
- * e.g rootDse search, NetscapeRoot searches
+ * e.g rootDse search, ConfigRoot searches
* cn=config, cn=schema etc
*/
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index e5ff2bba..0149556a 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -150,7 +150,9 @@ typedef struct slapi_rdn Slapi_RDN;
typedef struct slapi_mod Slapi_Mod;
typedef struct slapi_mods Slapi_Mods;
typedef struct slapi_componentid Slapi_ComponentId;
-
+/* Online tasks interface (to support import, export, etc) */
+typedef struct _slapi_task Slapi_Task;
+typedef int (*TaskCallbackFn)(Slapi_Task *task);
/*
* The default thread stacksize for nspr21 is 64k (except on IRIX! It's 32k!).
@@ -1187,7 +1189,59 @@ typedef int (*roles_check_fn_type)(Slapi_Entry *entry_to_check, Slapi_DN *role_d
int slapi_role_check(Slapi_Entry *entry_to_check, Slapi_DN *role_dn, int *present);
void slapi_register_role_check(roles_check_fn_type check_fn);
+/* DSE */
+/* Front end configuration */
+typedef int (*dseCallbackFn)(Slapi_PBlock *, Slapi_Entry *, Slapi_Entry *,
+ int *, char*, void *);
+
+/******************************************************************************
+ * Online tasks interface (to support import, export, etc)
+ * After some cleanup, we could consider making these public.
+ */
+
+/* task states */
+#define SLAPI_TASK_SETUP 0
+#define SLAPI_TASK_RUNNING 1
+#define SLAPI_TASK_FINISHED 2
+#define SLAPI_TASK_CANCELLED 3
+
+/* task flags (set by the task-control code) */
+#define SLAPI_TASK_DESTROYING 0x01 /* queued event for destruction */
+
+int slapi_task_register_handler(const char *name, dseCallbackFn func);
+void slapi_task_status_changed(Slapi_Task *task);
+void slapi_task_log_status(Slapi_Task *task, char *format, ...)
+#ifdef __GNUC__
+ __attribute__ ((format (printf, 2, 3)));
+#else
+ ;
+#endif
+void slapi_task_log_notice(Slapi_Task *task, char *format, ...)
+#ifdef __GNUC__
+ __attribute__ ((format (printf, 2, 3)));
+#else
+ ;
+#endif
+
+/*
+ * slapi_new_task: create new task, fill in DN, and setup modify callback
+ * argument:
+ * dn: task dn
+ * result:
+ * Success: Slapi_Task object
+ * Failure: NULL
+ */
+Slapi_Task *slapi_new_task(const char *dn);
+
+/* slapi_destroy_task: destroy a task
+ * argument:
+ * task: task to destroy
+ * result:
+ * none
+ */
+void slapi_destroy_task(void *arg);
+/* End of interface to support online tasks **********************************/
/* Binder-based (connection centric) resource limits */
/*
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index ba6dfc37..848f1019 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -744,6 +744,7 @@ int slapi_lookup_instance_name_by_suffix(char *suffix,
/* begin and end the task subsystem */
void task_init(void);
void task_shutdown(void);
+void task_cleanup(void);
/* for reversible encyrption */
#define SLAPI_MB_CREDENTIALS "nsmultiplexorcredentials"
@@ -1033,11 +1034,6 @@ int slapi_uniqueIDGenerateFromNameString(char **uId,
* JCMREPL - Added for the replication plugin.
*/
-/* Front end configuration */
-
-typedef int (*dseCallbackFn)(Slapi_PBlock *, Slapi_Entry *, Slapi_Entry *,
- int *, char*, void *);
-
/*
* Note: DSE callback functions MUST return one of these three values:
*
@@ -1177,23 +1173,10 @@ int slapd_re_init( void );
/***** End of items added for the replication plugin. ***********************/
-
/******************************************************************************
* Online tasks interface (to support import, export, etc)
* After some cleanup, we could consider making these public.
*/
-typedef struct _slapi_task Slapi_Task;
-typedef int (*TaskCallbackFn)(Slapi_Task *task);
-
-/* task states */
-#define SLAPI_TASK_SETUP 0
-#define SLAPI_TASK_RUNNING 1
-#define SLAPI_TASK_FINISHED 2
-#define SLAPI_TASK_CANCELLED 3
-
-/* task flags (set by the task-control code) */
-#define SLAPI_TASK_DESTROYING 0x01 /* queued event for destruction */
-
struct _slapi_task {
struct _slapi_task *next;
char *task_dn;
@@ -1212,26 +1195,8 @@ struct _slapi_task {
TaskCallbackFn destructor; /* task entry is being destroyed */
int task_refcount;
};
-
-int slapi_task_register_handler(const char *name, dseCallbackFn func);
-void slapi_task_status_changed(Slapi_Task *task);
-void slapi_task_log_status(Slapi_Task *task, char *format, ...)
-#ifdef __GNUC__
- __attribute__ ((format (printf, 2, 3)));
-#else
- ;
-#endif
-
-void slapi_task_log_notice(Slapi_Task *task, char *format, ...)
-#ifdef __GNUC__
- __attribute__ ((format (printf, 2, 3)));
-#else
- ;
-#endif
-
/* End of interface to support online tasks **********************************/
-
void DS_Sleep(PRIntervalTime ticks);
/* macro to specify the behavior of upgradedb */
diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c
index 13ff1565..629933b3 100644
--- a/ldap/servers/slapd/task.c
+++ b/ldap/servers/slapd/task.c
@@ -78,8 +78,9 @@ static int task_deny(Slapi_PBlock *pb, Slapi_Entry *e,
Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg);
static int task_generic_destructor(Slapi_Task *task);
-/* create new task, fill in DN, and setup modify callback */
-static Slapi_Task *new_task(const char *dn)
+/* create a new task, fill in DN, and setup modify callback */
+static Slapi_Task *
+new_task(const char *dn)
{
Slapi_Task *task = (Slapi_Task *)slapi_ch_calloc(1, sizeof(Slapi_Task));
@@ -109,7 +110,8 @@ static Slapi_Task *new_task(const char *dn)
}
/* called by the event queue to destroy a task */
-static void destroy_task(time_t when, void *arg)
+static void
+destroy_task(time_t when, void *arg)
{
Slapi_Task *task = (Slapi_Task *)arg;
Slapi_Task *t1;
@@ -150,6 +152,31 @@ static void destroy_task(time_t when, void *arg)
slapi_ch_free((void **)&task);
}
+/*
+ * slapi_new_task: create a new task, fill in DN, and setup modify callback
+ * argument:
+ * dn: task dn
+ * result:
+ * Success: Slapi_Task object
+ * Failure: NULL
+ */
+Slapi_Task *
+slapi_new_task(const char *dn)
+{
+ return new_task(dn);
+}
+
+/* slapi_destroy_task: destroy a task
+ * argument:
+ * task: task to destroy
+ * result:
+ * none
+ */
+void
+slapi_destroy_task(void *arg)
+{
+ destroy_task(1, arg);
+}
/********** some useful helper functions **********/
@@ -1539,12 +1566,11 @@ void slapi_task_status_changed(Slapi_Task *task)
}
}
-
/* cleanup old tasks that may still be in the DSE from a previous session
* (this can happen if the server crashes [no matter how unlikely we like
* to think that is].)
*/
-static void cleanup_old_tasks(void)
+void task_cleanup(void)
{
Slapi_PBlock *pb = slapi_pblock_new();
Slapi_Entry **entries = NULL;
@@ -1691,8 +1717,6 @@ void task_init(void)
return;
}
- cleanup_old_tasks();
-
slapi_task_register_handler("import", task_import_add);
slapi_task_register_handler("export", task_export_add);
slapi_task_register_handler("backup", task_backup_add);