Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32638
Modified Files:
slapi-private.h main.c task.c slapi-plugin.h mapping_tree.c
Log Message:
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
Index: slapi-private.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slapi-private.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- slapi-private.h 10 Nov 2006 23:45:40 -0000 1.14
+++ slapi-private.h 14 Dec 2006 23:16:54 -0000 1.15
@@ -744,6 +744,7 @@
/* 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 @@
* 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 @@
/***** 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 @@
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 */
Index: main.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/main.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- main.c 10 Nov 2006 23:45:40 -0000 1.16
+++ main.c 14 Dec 2006 23:16:54 -0000 1.17
@@ -1056,6 +1056,13 @@
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);
Index: task.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/task.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- task.c 10 Nov 2006 23:45:40 -0000 1.9
+++ task.c 14 Dec 2006 23:16:54 -0000 1.10
@@ -78,8 +78,9 @@
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 @@
}
/* 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 @@
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 @@
}
}
-
/* 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 @@
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);
Index: slapi-plugin.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slapi-plugin.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- slapi-plugin.h 10 Nov 2006 23:45:40 -0000 1.13
+++ slapi-plugin.h 14 Dec 2006 23:16:54 -0000 1.14
@@ -150,7 +150,9 @@
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 @@
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 */
/*
Index: mapping_tree.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/mapping_tree.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- mapping_tree.c 10 Nov 2006 23:45:40 -0000 1.7
+++ mapping_tree.c 14 Dec 2006 23:16:54 -0000 1.8
@@ -2445,7 +2445,8 @@
/* 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 @@
/* 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
*/