[PATCH] Update the slapi-plugin documentation on new slapi functions, and added a slapi function for checking on shutdowns

Mark Reynolds mreynolds at redhat.com
Wed May 30 17:30:44 UTC 2012


Fix Description:  removed the g_get_shutdown() functions from the plugins, and replaced them with the slapi verison

Reviewed by:
---
 ldap/servers/plugins/linkedattrs/fixup_task.c      |    2 +-
 ldap/servers/plugins/linkedattrs/linked_attrs.h    |    2 -
 ldap/servers/plugins/memberof/memberof.c           |    2 +-
 ldap/servers/plugins/memberof/memberof.h           |    2 -
 ldap/servers/plugins/replication/cl5_api.c         |    4 +--
 ldap/servers/plugins/replication/repl5_replica.c   |    5 +---
 .../plugins/replication/repl5_replica_config.c     |    3 +-
 ldap/servers/plugins/usn/usn_cleanup.c             |    2 +-
 ldap/servers/slapd/libglobs.c                      |    5 ++++
 ldap/servers/slapd/slapi-plugin.h                  |   22 +++++++++++++++++++-
 10 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/ldap/servers/plugins/linkedattrs/fixup_task.c b/ldap/servers/plugins/linkedattrs/fixup_task.c
index b19d3ab..9fa7f6f 100644
--- a/ldap/servers/plugins/linkedattrs/fixup_task.c
+++ b/ldap/servers/plugins/linkedattrs/fixup_task.c
@@ -355,7 +355,7 @@ linked_attrs_add_backlinks_callback(Slapi_Entry *e, void *callback_data)
         int perform_update = 0;
         Slapi_DN *targetsdn = NULL;
 
-        if (g_get_shutdown()) {
+        if (slapi_is_shutting_down()) {
             rc = -1;
             goto done;
         }
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.h b/ldap/servers/plugins/linkedattrs/linked_attrs.h
index 2eba62f..d0909ca 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.h
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.h
@@ -138,8 +138,6 @@ int linked_attrs_fixup_task_add(Slapi_PBlock *pb, Slapi_Entry *e,
                            Slapi_Entry *eAfter, int *returncode,
                            char *returntext, void *arg);
 
-int g_get_shutdown();		/* declared in proto-slap.h */
-
 /*
  * misc
  */
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index c98d8ad..fc4529d 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -1670,7 +1670,7 @@ int memberof_get_groups_callback(Slapi_Entry *e, void *callback_data)
 	Slapi_ValueSet *groupvals = *((memberof_get_groups_data*)callback_data)->groupvals;
 	int rc = 0;
 
-	if(g_get_shutdown()){
+	if(slapi_is_shutting_down()){
 		rc = -1;
 		goto bail;
 	}
diff --git a/ldap/servers/plugins/memberof/memberof.h b/ldap/servers/plugins/memberof/memberof.h
index 36901e3..65398aa 100644
--- a/ldap/servers/plugins/memberof/memberof.h
+++ b/ldap/servers/plugins/memberof/memberof.h
@@ -96,6 +96,4 @@ void memberof_wlock_config();
 void memberof_unlock_config();
 int memberof_config_get_all_backends();
 
-int g_get_shutdown();		/* declared in proto-slap.h */
-
 #endif	/* _MEMBEROF_H_ */
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index eac76a8..08bf771 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -265,8 +265,6 @@ typedef struct cl5desc
 
 typedef void (*VFP)(void *);
 
-int g_get_shutdown();		/* declared in proto-slap.h */
-
 /***** Global Variables *****/
 static CL5Desc s_cl5Desc;
 
@@ -3472,7 +3470,7 @@ static void _cl5TrimFile (Object *obj, long *numToTrim)
 
 	entry.op = &op;
 
-	while ( !finished && !g_get_shutdown() )
+	while ( !finished && !slapi_is_shutting_down() )
 	{
 		it = NULL;
 		count = 0;
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 6434dbd..ccaa29d 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -50,9 +50,6 @@
 #include "csnpl.h"
 #include "cl5_api.h"
 
-/* from proto-slap.h */
-int g_get_shutdown();
-
 #define RUV_SAVE_INTERVAL (30 * 1000) /* 30 seconds */
 #define START_UPDATE_DELAY 2 /* 2 second */
 
@@ -2506,7 +2503,7 @@ process_reap_entry (Slapi_Entry *entry, void *cb_data)
 	int rc = -1;
 
 	/* abort reaping if we've been told to stop or we're shutting down */
-	if (*tombstone_reap_stop || g_get_shutdown()) {
+	if (*tombstone_reap_stop || slapi_is_shutting_down()) {
 		slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
 						"process_reap_entry: the tombstone reap process "
 						" has been stopped\n");
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index ca646e9..8d338c0 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -86,7 +86,6 @@ static struct berval *create_ruv_payload(char *value);
 static int replica_cleanup_task (Object *r, const char *task_name, char *returntext, int apply_mods);
 static int replica_task_done(Replica *replica);
 static multimaster_mtnode_extension * _replica_config_get_mtnode_ext (const Slapi_Entry *e);
-int g_get_shutdown();
 
 /*
  * Note: internal add/modify/delete operations should not be run while
@@ -1326,7 +1325,7 @@ replica_cleanallruv_monitor_thread(void *arg)
 
 	slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "cleanAllRUV_task: Waiting for all the replicas to get cleaned...\n");
 
-	while(!g_get_shutdown())
+	while(!slapi_is_shutting_down())
 	{
 		DS_Sleep(PR_SecondsToInterval(10));
 		found = 0;
diff --git a/ldap/servers/plugins/usn/usn_cleanup.c b/ldap/servers/plugins/usn/usn_cleanup.c
index 6f9410e..ab6362f 100644
--- a/ldap/servers/plugins/usn/usn_cleanup.c
+++ b/ldap/servers/plugins/usn/usn_cleanup.c
@@ -148,7 +148,7 @@ usn_cleanup_thread(void *arg)
         int opflags = OP_FLAG_TOMBSTONE_ENTRY;
 
         /* check for shutdown */
-        if(g_get_shutdown()){
+        if(slapi_is_shutting_down()){
             slapi_task_log_notice(task, "USN tombstone cleanup task aborted due to shutdown.");
             slapi_task_log_status(task, "USN tombstone cleanup task aborted due to shutdown.");
             slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 2540e25..c1e4051 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -890,6 +890,11 @@ int g_get_shutdown()
     return slapd_shutdown;
 }
 
+int slapi_is_shutting_down()
+{
+	return slapd_shutdown;
+}
+
 
 static int cmd_shutdown;
 
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 63c37f0..bad97f8 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -5301,6 +5301,13 @@ void slapi_ch_array_add( char ***array, char *string );
  */
 int slapi_ch_array_utf8_inlist(char **array, char *string);
 
+/**
+ * Check if the server has started shutting down
+ *
+ * \return 1 if the server is shutting down
+ */
+int slapi_is_shutting_down();
+
 /*
  * checking routines for allocating and freeing memory
  */
@@ -6742,7 +6749,20 @@ int slapi_re_exec( Slapi_Regex *re_handle, const char *subject, time_t time_up )
  * \warning The regex handler should be released by slapi_re_free().
  */
 int slapi_re_subs( Slapi_Regex *re_handle, const char *subject, const char *src, char **dst, unsigned long dstlen );
-/* extension to handle search filters properly */
+/**
+ * Substitutes '&' or '\#' in the param src with the matched string.  If the 'src' is a search filter
+ * do not remove & if it is part of a compound filter.
+ *
+ * \param re_handle The regex handler returned from slapi_re_comp.
+ * \param subject A string checked against the compiled pattern.
+ * \param src A given string which could contain the substitution symbols.
+ * \param dst A pointer pointing to the memory which stores the output string.
+ * \param dstlen Size of the memory dst.
+ * \param filter Set to 1 if the src is a ldap search filter
+ * \return This function returns 1 if the substitution was successful.
+ * \return This function returns 0 if the substitution failed.
+ * \warning The regex handler should be released by slapi_re_free().
+ */
 int slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject, const char *src, char **dst, unsigned long dstlen, int filter );
 /**
  * Releases the regex handler which was returned from slapi_re_comp.
-- 
1.7.1


--------------030604010004030206060003--


More information about the 389-devel mailing list