mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 20:51:58 +00:00
block any inbound messages when queue is full; add debounce for mwi and pres on register; fix missing detach attr on new mode to process reg in new thread
This commit is contained in:
@@ -993,6 +993,30 @@ uint32_t sofia_reg_reg_count(sofia_profile_t *profile, const char *user, const c
|
||||
return atoi(buf);
|
||||
}
|
||||
|
||||
static int debounce_check(sofia_profile_t *profile, const char *user, const char *host)
|
||||
{
|
||||
char key[512] = "";
|
||||
int r = 0;
|
||||
time_t *last, now = switch_epoch_time_now(NULL);
|
||||
|
||||
snprintf(key, sizeof(key), "%s%s", user, host);
|
||||
|
||||
if ((last = switch_core_hash_find(profile->mwi_debounce_hash, key))) {
|
||||
if (now - *last > 30) {
|
||||
*last = now;
|
||||
r = 1;
|
||||
}
|
||||
} else {
|
||||
last = switch_core_alloc(profile->pool, sizeof(*last));
|
||||
*last = now;
|
||||
switch_core_hash_insert(profile->mwi_debounce_hash, key, last);
|
||||
r = 1;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip,
|
||||
sofia_dispatch_event_t *de, sofia_regtype_t regtype, char *key,
|
||||
uint32_t keylen, switch_event_t **v_event, const char *is_nat)
|
||||
@@ -1668,11 +1692,14 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||
|
||||
if (contact) {
|
||||
if (exptime) {
|
||||
int debounce_ok = debounce_check(profile, mwi_user, mwi_host);
|
||||
|
||||
switch_snprintf(exp_param, sizeof(exp_param), "expires=%ld", exptime);
|
||||
sip_contact_add_param(nua_handle_home(nh), sip->sip_contact, exp_param);
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER) ||
|
||||
(reg_count == 1 && sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER))) {
|
||||
|
||||
if ((sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER) ||
|
||||
(reg_count == 1 && sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER))) && debounce_ok) {
|
||||
|
||||
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);
|
||||
@@ -1680,9 +1707,9 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||
}
|
||||
}
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_PRESENCE_ON_REGISTER) ||
|
||||
if ((sofia_test_pflag(profile, PFLAG_PRESENCE_ON_REGISTER) ||
|
||||
(reg_count == 1 && sofia_test_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER))
|
||||
|| send_pres == 1 || (reg_count == 1 && send_pres == 2)) {
|
||||
|| send_pres == 1 || (reg_count == 1 && send_pres == 2)) && debounce_ok) {
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER)) {
|
||||
if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
|
||||
|
||||
Reference in New Issue
Block a user