]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_sofia: Fix memleak and mwi event not generated on first register
authorMarc Olivier Chouinard <mochouinard@moctel.com>
Sun, 29 Aug 2010 03:16:00 +0000 (23:16 -0400)
committerMarc Olivier Chouinard <mochouinard@moctel.com>
Sun, 29 Aug 2010 03:16:00 +0000 (23:16 -0400)
src/mod/endpoints/mod_sofia/sofia_reg.c

index 1623d3d4e8574884677d0a33532c4ea913df9b21..18df1c439886d0b9330fb16c1e81ed45e8622149 100644 (file)
@@ -1315,6 +1315,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
        if (regtype == REG_REGISTER) {
                char exp_param[128] = "";
                char date[80] = "";
+               switch_event_t *s_mwi_event = NULL;
 
                s_event = NULL;
 
@@ -1324,10 +1325,10 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
 
                        if (sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER) ||
                                (reg_count == 1 && sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER))) {
-                               if (switch_event_create(&s_event, SWITCH_EVENT_MESSAGE_QUERY) == SWITCH_STATUS_SUCCESS) {
-                                       switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "Message-Account", "sip:%s@%s", mwi_user, mwi_host);
-                                       switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "VM-Sofia-Profile", profile->name);
-                                       switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "VM-Call-ID", call_id);
+                               if (switch_event_create(&s_mwi_event, SWITCH_EVENT_MESSAGE_QUERY) == SWITCH_STATUS_SUCCESS) {
+                                       switch_event_add_header(s_mwi_event, SWITCH_STACK_BOTTOM, "Message-Account", "sip:%s@%s", mwi_user, mwi_host);
+                                       switch_event_add_header_string(s_mwi_event, SWITCH_STACK_BOTTOM, "VM-Sofia-Profile", profile->name);
+                                       switch_event_add_header_string(s_mwi_event, SWITCH_STACK_BOTTOM, "VM-Call-ID", call_id);
                                }
                        }
 
@@ -1361,6 +1362,10 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
                        switch_event_fire(&s_event);
                }
 
+               if (s_mwi_event) {
+                       switch_event_fire(&s_mwi_event);
+               }
+
                if (*contact_str && sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE_SYLANTRO)) {
                        sofia_sla_handle_register(nua, profile, sip, exptime, contact_str);
                }