]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_sofia] release nat mapping when nua create failed 1178/head
authorClarence <xjh.azzbcc@gmail.com>
Wed, 28 Apr 2021 11:59:52 +0000 (19:59 +0800)
committerClarence <xjh.azzbcc@gmail.com>
Wed, 28 Apr 2021 12:10:35 +0000 (20:10 +0800)
src/mod/endpoints/mod_sofia/sofia.c

index dd46fb4c0f247843aca7aea25352e574f7acffef..d152a128106c6cd2faf6ce091a84a10ad33b6b94 100644 (file)
@@ -3188,7 +3188,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
        if (!sofia_glue_init_sql(profile)) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open SQL Database [%s]!\n", profile->name);
                sofia_profile_start_failure(profile, profile->name);
-               goto end;
+               goto db_fail;
        }
 
        supported = switch_core_sprintf(profile->pool, "%s%s%spath, replaces", use_100rel ? "100rel, " : "", use_timer ? "timer, " : "", use_rfc_5626 ? "outbound, " : "");
@@ -3339,7 +3339,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
                }
 
                sofia_profile_start_failure(profile, profile->name);
-               goto end;
+               goto nua_fail;
        }
 
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created agent for %s\n", profile->name);
@@ -3570,6 +3570,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
                switch_event_fire(&s_event);
        }
 
+  nua_fail:
        if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && switch_nat_get_type()) {
                if (switch_nat_del_mapping(profile->sip_port, SWITCH_NAT_UDP) == SWITCH_STATUS_SUCCESS) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Deleted UDP nat mapping for %s port %d\n", profile->name, profile->sip_port);
@@ -3582,7 +3583,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
                }
        }
 
-  end:
+  db_fail:
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock %s\n", profile->name);
        switch_thread_rwlock_wrlock(profile->rwlock);