Skip to content

Commit d7c83cd

Browse files
committed
[mod_sofia] Unfound users are not processed ping status and Make SOFIA_REG_UNREACHABLE SOFIA_REG_REACHABLE name and description consistent.
1 parent b0b646a commit d7c83cd

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/mod/endpoints/mod_sofia/sofia.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6400,7 +6400,7 @@ const char *sofia_gateway_status_name(sofia_gateway_status_t status)
64006400

64016401
const char *sofia_sip_user_status_name(sofia_sip_user_status_t status)
64026402
{
6403-
static const char *status_names[] = { "UNREACHABLE", "REACHABLE", NULL };
6403+
static const char *status_names[] = { "REACHABLE", "UNREACHABLE", NULL };
64046404

64056405
if (status < SOFIA_REG_INVALID) {
64066406
return status_names[status];
@@ -6525,11 +6525,17 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu
65256525
sip_user_status.status_len = sizeof(ping_status);
65266526
sip_user_status.contact = sip_contact;
65276527
sip_user_status.contact_len = sizeof(sip_contact);
6528+
sip_user_status.count = -1;
65286529
sql = switch_mprintf("select ping_status, ping_count, contact from sip_registrations where sip_user='%q' and sip_host='%q' and call_id='%q'",
65296530
sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host, call_id);
65306531
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_sip_user_status_callback, &sip_user_status);
65316532
switch_safe_free(sql);
65326533

6534+
if (sip_user_status.count < 0) {
6535+
switch_safe_free(sip_user);
6536+
return;
6537+
}
6538+
65336539
if (status != 200 && status != 486) {
65346540
sip_user_status.count--;
65356541
if (sip_user_status.count >= 0) {
@@ -6549,7 +6555,7 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu
65496555
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
65506556
switch_safe_free(sql);
65516557
sofia_reg_fire_custom_sip_user_state_event(profile, sip_user, sip_user_status.contact, sip->sip_to->a_url->url_user,
6552-
sip->sip_to->a_url->url_host, call_id, SOFIA_REG_REACHABLE, status, phrase);
6558+
sip->sip_to->a_url->url_host, call_id, SOFIA_REG_UNREACHABLE, status, phrase);
65536559

65546560
if (sofia_test_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL)) {
65556561
time_t now = switch_epoch_time_now(NULL);
@@ -6582,7 +6588,7 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu
65826588
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
65836589
switch_safe_free(sql);
65846590
sofia_reg_fire_custom_sip_user_state_event(profile, sip_user, sip_user_status.contact, sip->sip_to->a_url->url_user,
6585-
sip->sip_to->a_url->url_host, call_id, SOFIA_REG_UNREACHABLE, status, phrase);
6591+
sip->sip_to->a_url->url_host, call_id, SOFIA_REG_REACHABLE, status, phrase);
65866592
}
65876593
}
65886594
}

0 commit comments

Comments
 (0)