[Asterisk-code-review] res statsd.c: Fix returned reload status. (asterisk[13])
George Joseph
asteriskteam at digium.com
Mon Oct 15 10:31:19 CDT 2018
George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/10453 )
Change subject: res_statsd.c: Fix returned reload status.
......................................................................
res_statsd.c: Fix returned reload status.
The return status when there was no change in statsd.conf was incorrect.
This resulted in the wrong status message on the CLI when reloading the
module.
* Fixed cleanup on initial load if initializing statsd failed.
Change-Id: Id24fae75f1a7ff584a444a5680e867d989792481
---
M res/res_statsd.c
1 file changed, 21 insertions(+), 13 deletions(-)
Approvals:
Corey Farrell: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
diff --git a/res/res_statsd.c b/res/res_statsd.c
index 67166e8..f94876e 100644
--- a/res/res_statsd.c
+++ b/res/res_statsd.c
@@ -318,6 +318,14 @@
}
}
+static int unload_module(void)
+{
+ statsd_shutdown();
+ aco_info_destroy(&cfg_info);
+ ao2_global_obj_release(confs);
+ return 0;
+}
+
static int load_module(void)
{
if (aco_info_init(&cfg_info)) {
@@ -350,8 +358,8 @@
return AST_MODULE_LOAD_SUCCESS;
}
- if (statsd_init() != 0) {
- aco_info_destroy(&cfg_info);
+ if (statsd_init()) {
+ unload_module();
return AST_MODULE_LOAD_DECLINE;
}
@@ -361,26 +369,26 @@
return AST_MODULE_LOAD_SUCCESS;
}
-static int unload_module(void)
-{
- statsd_shutdown();
- aco_info_destroy(&cfg_info);
- ao2_global_obj_release(confs);
- return 0;
-}
-
static int reload_module(void)
{
- if (aco_process_config(&cfg_info, 1)) {
+ switch (aco_process_config(&cfg_info, 1)) {
+ case ACO_PROCESS_OK:
+ break;
+ case ACO_PROCESS_UNCHANGED:
+ return AST_MODULE_LOAD_SUCCESS;
+ case ACO_PROCESS_ERROR:
+ default:
return AST_MODULE_LOAD_DECLINE;
}
if (is_enabled()) {
- return statsd_init();
+ if (statsd_init()) {
+ return AST_MODULE_LOAD_DECLINE;
+ }
} else {
statsd_shutdown();
- return AST_MODULE_LOAD_SUCCESS;
}
+ return AST_MODULE_LOAD_SUCCESS;
}
/* The priority of this module is set to be as low as possible, since it could
--
To view, visit https://gerrit.asterisk.org/10453
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: Id24fae75f1a7ff584a444a5680e867d989792481
Gerrit-Change-Number: 10453
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2 (1000185)
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181015/2a801a36/attachment-0001.html>
More information about the asterisk-code-review
mailing list