]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
remove sub_hash in favor of using a lookup directly into the sip stack
authorMichael Jerris <mike@jerris.com>
Tue, 6 May 2008 23:49:35 +0000 (23:49 +0000)
committerMichael Jerris <mike@jerris.com>
Tue, 6 May 2008 23:49:35 +0000 (23:49 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8283 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/sofia-sip/.update
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_presence.c

index 925fba06078886e4fed613d597995c095a2f7a01..9dc1e4db81dc33861912d889517eaf8210efc878 100644 (file)
@@ -1 +1 @@
-Wed Apr 23 14:38:18 EDT 2008
+Tue May  6 18:44:34 CDT 2008
index 3d06027f3100d674038afefb1f94624bdd053d52..4273896327e5c3241c34444a5765ba3c818d28a7 100644 (file)
@@ -309,7 +309,6 @@ struct sofia_profile {
        switch_mutex_t *gateway_mutex;
        sofia_gateway_t *gateways;
        su_home_t *home;
-       switch_hash_t *sub_hash;
        switch_hash_t *chat_hash;
        switch_core_db_t *master_db;
        switch_thread_rwlock_t *rwlock;
index 2165d49b8dfac0fb25d677efbf733dcc1bc825dc..ffe97ff8aa90c9dd89f632e4f306aa7be49c98da 100644 (file)
@@ -69,12 +69,10 @@ void sofia_handle_sip_r_notify(switch_core_session_t *session, int status,
                                                           char const *phrase,
                                                           nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
 {
-       if (status >= 300 && sip) {
-               const char *call_id = sip->sip_call_id->i_id;
+       if (status >= 300 && sip && sip->sip_call_id) {
                char *sql;
-               switch_core_hash_delete(profile->sub_hash, call_id);
                
-               sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", call_id);
+               sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", sip->sip_call_id->i_id);
                switch_assert(sql != NULL);
                sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
                nua_handle_destroy(nh);
@@ -689,7 +687,6 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
 
        sofia_glue_del_profile(profile);
        switch_core_hash_destroy(&profile->chat_hash);
-       switch_core_hash_destroy(&profile->sub_hash);
 
        switch_thread_rwlock_unlock(profile->rwlock);
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write unlock %s\n", profile->name);
@@ -1068,7 +1065,6 @@ switch_status_t config_sofia(int reload, char *profile_name)
 
                                profile->dbname = switch_core_strdup(profile->pool, url);
                                switch_core_hash_init(&profile->chat_hash, profile->pool);
-                               switch_core_hash_init(&profile->sub_hash, profile->pool);
                                switch_thread_rwlock_create(&profile->rwlock, profile->pool);
                                switch_mutex_init(&profile->flag_mutex, SWITCH_MUTEX_NESTED, profile->pool);
                                profile->dtmf_duration = 100;
index de08c1591b66a0842e7959337f283d0b9d88c9e7..de87e4142d7acd6b0e3d123ca7e0b0074a0a9262 100644 (file)
@@ -782,8 +782,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
                }
        }
        
-       //if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) {
-       if (!(nh = (nua_handle_t *) switch_core_hash_find(profile->sub_hash, call_id))) {
+       if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find handle for %s\n", call_id);
                return 0;
        }
@@ -1046,14 +1045,9 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
        switch_snprintf(exp, sizeof(exp), "active;expires=%ld", (long) exptime); 
 
        nua_notify(nh,
-                          //NUTAG_NEWSUB(1),
                           SIPTAG_SUBSCRIPTION_STATE_STR(exp),
                           SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(pl), TAG_END());
 
-       if (done) {
-               switch_core_hash_delete(profile->sub_hash, call_id);
-       }
-
  end:
 
        switch_safe_free(id);
@@ -1091,8 +1085,7 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
                return 0;
        }
        
-       //if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) {
-       if (!(nh = (nua_handle_t *) switch_core_hash_find(profile->sub_hash, call_id))) {
+       if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find handle for %s\n", call_id);
                return 0;
        }
@@ -1105,7 +1098,6 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
        exp = switch_mprintf("active;expires=%ld", expire_sec);
 
        nua_notify(nh,
-                          //NUTAG_NEWSUB(1),
                           SIPTAG_SUBSCRIPTION_STATE_STR(exp),
                           SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END());
        
@@ -1313,7 +1305,6 @@ void sofia_presence_handle_sip_i_subscribe(int status,
 
                if (sub_state == nua_substate_terminated) {
                        sstr = switch_mprintf("terminated");
-                       switch_core_hash_delete(profile->sub_hash, call_id);
                } else {
                        sip_accept_t *ap = sip->sip_accept;
                        char accept[256] = "";
@@ -1330,9 +1321,6 @@ void sofia_presence_handle_sip_i_subscribe(int status,
                        sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
 
                        sstr = switch_mprintf("active;expires=%ld", exp_raw);
-                       if (status < 200) {
-                               switch_core_hash_insert(profile->sub_hash, call_id, nh);
-                       }
                }
        
                switch_mutex_unlock(profile->ireg_mutex);