]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
refactor
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 3 Sep 2010 17:46:21 +0000 (12:46 -0500)
committerBrian West <brian@freeswitch.org>
Fri, 3 Sep 2010 17:46:49 +0000 (12:46 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index 0168a33187ada4e5b66b3ddd3ca3746eedcc0f19..aa2149503aaa5335d1de36183259ed5aaa75c3d3 100644 (file)
@@ -1007,3 +1007,4 @@ switch_t38_options_t *sofia_glue_extract_t38_options(switch_core_session_t *sess
 char *sofia_glue_get_multipart(switch_core_session_t *session, const char *prefix, const char *sdp, char **mp_type);
 void sofia_glue_tech_simplify(private_object_t *tech_pvt);
 switch_console_callback_match_t *sofia_reg_find_reg_url_multi(sofia_profile_t *profile, const char *user, const char *host);
+switch_bool_t sofia_glue_profile_exists(const char *key);
index 580b5e70b69ab155b58ce158efd973f25594ebea..15efc1a3e40d7d7f111534a152f3033e485a7289 100644 (file)
@@ -4174,6 +4174,19 @@ switch_status_t sofia_glue_profile_rdlock__(const char *file, const char *func,
        return status;
 }
 
+switch_bool_t sofia_glue_profile_exists(const char *key)
+{
+       switch_bool_t tf = SWITCH_FALSE;
+       
+       switch_mutex_lock(mod_sofia_globals.hash_mutex);
+       if (switch_core_hash_find(mod_sofia_globals.profile_hash, key)) {
+               tf = SWITCH_TRUE;
+       }
+       switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+
+       return tf;
+}
+
 sofia_profile_t *sofia_glue_find_profile__(const char *file, const char *func, int line, const char *key)
 {
        sofia_profile_t *profile;
index 6b90b775fc6b6ae38ee0c3dd1fa27249b9340bbf..d22c79a9e4bf26434b576d37648b0e7873f567d7 100644 (file)
@@ -1179,20 +1179,13 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
                switch_find_local_ip(guess_ip4, sizeof(guess_ip4), NULL, AF_INET);
 
                if (profile->reg_db_domain) {
-                       sofia_profile_t *xprofile;
-
-                       if ((xprofile = sofia_glue_find_profile(to_host))) {
-                               sofia_glue_release_profile(xprofile);
-                       } else {
-
+                       if (!sofia_glue_profile_exists(to_host)) {                              
                                if (sofia_glue_add_profile(switch_core_strdup(profile->pool, to_host), profile) == SWITCH_STATUS_SUCCESS) {
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Auto-Adding Alias [%s] for profile [%s]\n", to_host, profile->name);
                                } else {
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Alias [%s] for profile [%s] (already exists)\n",
                                                                          to_host, profile->name);
                                }
-                               
-                               
                        }
                }