[Asterisk-code-review] res stun monitor: Don't fail to load if DNS resolution fails (asterisk[master])

George Joseph asteriskteam at digium.com
Thu Apr 20 07:19:46 CDT 2017


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/5489 )

Change subject: res_stun_monitor: Don't fail to load if DNS resolution fails
......................................................................


res_stun_monitor: Don't fail to load if DNS resolution fails

res_stun_monitor will fail to load if DNS resolution of the STUN server
fails. Instead, we continue without the STUN server being resolved and
we will re-attempt the resolution on the STUN refresh interval.

ASTERISK-21856 #close
Reported by: Jeremy Kister

Change-Id: I6334c54a1cc798f8a836b4b47948e0bb4ef59254
---
M res/res_stun_monitor.c
1 file changed, 8 insertions(+), 4 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  George Joseph: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/res/res_stun_monitor.c b/res/res_stun_monitor.c
index 46deaff..08d1d66 100644
--- a/res/res_stun_monitor.c
+++ b/res/res_stun_monitor.c
@@ -269,7 +269,7 @@
  * \retval 0 on success.
  * \retval -1 on error.
  */
-static int setup_stunaddr(const char *value)
+static int setup_stunaddr(const char *value, int reload)
 {
 	char *val;
 	char *host_str;
@@ -305,8 +305,12 @@
 	stun_addr.ss.ss_family = AF_INET;
 	if (ast_get_ip(&stun_addr, host_str)) {
 		ast_log(LOG_WARNING, "Unable to lookup STUN server '%s'\n", host_str);
-		ast_free(host_str);
-		return -1;
+
+		/* Only treat this as fatal if we are reloading */
+		if (reload) {
+			ast_free(host_str);
+			return -1;
+		}
 	}
 
 	/* Save STUN server information. */
@@ -348,7 +352,7 @@
 
 	for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
 		if (!strcasecmp(v->name, "stunaddr")) {
-			if (setup_stunaddr(v->value)) {
+			if (setup_stunaddr(v->value, !startup)) {
 				ast_log(LOG_WARNING, "Invalid STUN server address: %s at line %d\n",
 					v->value, v->lineno);
 			}

-- 
To view, visit https://gerrit.asterisk.org/5489
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6334c54a1cc798f8a836b4b47948e0bb4ef59254
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>



More information about the asterisk-code-review mailing list