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
This commit is contained in:
Terry Wilson
2012-06-14 13:41:47 +00:00
parent 01307e4b7b
commit cfa0826c49
2 changed files with 16 additions and 4 deletions

View File

@@ -124,13 +124,20 @@ struct aco_type {
struct aco_type_internal *internal; 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 0 Success
* \retval non-zero Failure. Changes not applied * \retval non-zero Failure. Changes not applied
*/ */
typedef int (*aco_pre_apply_config)(void); 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 NULL error
* \retval non-NULL a config object container * \retval non-NULL a config object container
*/ */
@@ -145,12 +152,13 @@ struct aco_file {
}; };
struct aco_info { 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_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 */ 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 ao2_global_obj *global_obj; /*!< The global object array that holds the user-defined config object */
struct aco_info_internal *internal; 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 */ /*! \brief A helper macro to ensure that aco_info types always have a sentinel */

View File

@@ -480,6 +480,10 @@ try_alias:
goto end; goto end;
} }
if (info->post_apply_config) {
info->post_apply_config();
}
end: end:
ao2_cleanup(info->internal->pending); ao2_cleanup(info->internal->pending);
return res; return res;