summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTerry Wilson <twilson@digium.com>2012-06-14 13:41:47 +0000
committerTerry Wilson <twilson@digium.com>2012-06-14 13:41:47 +0000
commitcfa0826c492951b2c57f1350a7ed1bc3a97d6f9b (patch)
tree5704d80dc276db3a17f3d1c25a3849bf8f1c9c2e
parent01307e4b7bbf01f2ff7e5a0a9e9047e7b5cd789f (diff)
Add a post_apply callback to the Config Options API
This adds a callback that only fires when changes have been successfully applied via the Config Options API. Review: https://reviewboard.asterisk.org/r/1980/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368921 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--include/asterisk/config_options.h16
-rw-r--r--main/config_options.c4
2 files changed, 16 insertions, 4 deletions
diff --git a/include/asterisk/config_options.h b/include/asterisk/config_options.h
index 3e4c4a5ca..1bbf27025 100644
--- a/include/asterisk/config_options.h
+++ b/include/asterisk/config_options.h
@@ -124,13 +124,20 @@ struct aco_type {
struct aco_type_internal *internal;
};
-/*! \brief A callback function for applying the config changes
+/*! \brief A callback function to run just prior to applying config changes
* \retval 0 Success
* \retval non-zero Failure. Changes not applied
*/
typedef int (*aco_pre_apply_config)(void);
-/*! \brief A callback functino for allocating an object to hold all config objects
+/*! \brief A callback function called only if config changes have been applied
+ *
+ * \note If a config file has not been edited prior to performing a reload, this
+ * callback will not be called.
+ */
+typedef void (*aco_post_apply_config)(void);
+
+/*! \brief A callback function for allocating an object to hold all config objects
* \retval NULL error
* \retval non-NULL a config object container
*/
@@ -145,12 +152,13 @@ struct aco_file {
};
struct aco_info {
- const char *module; /*!< The name of the module whose config is being processed */
+ const char *module; /*!< The name of the module whose config is being processed */
aco_pre_apply_config pre_apply_config; /*!< A callback called after processing, but before changes are applied */
+ aco_post_apply_config post_apply_config;/*!< A callback called after changes are applied */
aco_snapshot_alloc snapshot_alloc; /*!< Allocate an object to hold all global configs and item containers */
struct ao2_global_obj *global_obj; /*!< The global object array that holds the user-defined config object */
struct aco_info_internal *internal;
- struct aco_file *files[]; /*!< The config filename */
+ struct aco_file *files[]; /*!< An array of aco_files to process */
};
/*! \brief A helper macro to ensure that aco_info types always have a sentinel */
diff --git a/main/config_options.c b/main/config_options.c
index 7baf67836..3d15991ac 100644
--- a/main/config_options.c
+++ b/main/config_options.c
@@ -480,6 +480,10 @@ try_alias:
goto end;
}
+ if (info->post_apply_config) {
+ info->post_apply_config();
+ }
+
end:
ao2_cleanup(info->internal->pending);
return res;