FS-6413 --resolve with this patch you will need to make sure the boxes have the clocks synced and both started inside the same occurence of the most recent new year.

This commit is contained in:
Anthony Minessale 2014-03-31 15:23:50 -05:00
parent 107c5eccc3
commit c02a5e67b8
3 changed files with 34 additions and 16 deletions

View File

@ -4666,7 +4666,6 @@ static int notify_csta_callback(void *pArg, int argc, char **argv, char **column
char *contact;
sip_cseq_t *cseq = NULL;
uint32_t callsequence;
uint32_t now = (uint32_t) switch_epoch_time_now(NULL);
sofia_destination_t *dst = NULL;
char *route_uri = NULL;
@ -4691,12 +4690,7 @@ static int notify_csta_callback(void *pArg, int argc, char **argv, char **column
route_uri = sofia_glue_strip_uri(dst->route_uri);
}
switch_mutex_lock(profile->ireg_mutex);
if (!profile->cseq_base) {
profile->cseq_base = (now - 1312693200) * 10;
}
callsequence = ++profile->cseq_base;
switch_mutex_unlock(profile->ireg_mutex);
callsequence = sofia_presence_get_cseq(profile);
//nh = nua_handle(profile->nua, NULL, NUTAG_URL(dst->contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(profile->url), TAG_END());
nh = nua_handle(profile->nua, NULL, NUTAG_URL(dst->contact), SIPTAG_FROM_STR(full_to), SIPTAG_TO_STR(full_from), SIPTAG_CONTACT_STR(profile->url), TAG_END());
@ -5528,6 +5522,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
switch_management_interface_t *management_interface;
switch_application_interface_t *app_interface;
struct in_addr in;
struct tm tm = {0};
time_t now;
memset(&mod_sofia_globals, 0, sizeof(mod_sofia_globals));
mod_sofia_globals.destroy_private.destroy_nh = 1;
@ -5536,6 +5532,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
mod_sofia_globals.pool = pool;
switch_mutex_init(&mod_sofia_globals.mutex, SWITCH_MUTEX_NESTED, mod_sofia_globals.pool);
now = switch_epoch_time_now(NULL);
tm = *(localtime(&now));
mod_sofia_globals.presence_epoch = now - (tm.tm_yday * 86400);
switch_find_local_ip(mod_sofia_globals.guess_ip, sizeof(mod_sofia_globals.guess_ip), &mod_sofia_globals.guess_mask, AF_INET);
in.s_addr = mod_sofia_globals.guess_mask;
switch_set_string(mod_sofia_globals.guess_mask_str, inet_ntoa(in));

View File

@ -361,6 +361,7 @@ struct mod_sofia_globals {
int presence_flush;
switch_thread_t *presence_thread;
uint32_t max_reg_threads;
time_t presence_epoch;
};
extern struct mod_sofia_globals mod_sofia_globals;
@ -678,7 +679,7 @@ struct sofia_profile {
int watchdog_enabled;
switch_mutex_t *gw_mutex;
uint32_t queued_events;
uint32_t cseq_base;
uint32_t last_cseq;
int tls_only;
int tls_verify_date;
enum tport_tls_verify_policy tls_verify_policy;
@ -1111,6 +1112,7 @@ switch_bool_t sofia_glue_profile_exists(const char *key);
void sofia_glue_global_siptrace(switch_bool_t on);
void sofia_glue_global_capture(switch_bool_t on);
void sofia_glue_global_watchdog(switch_bool_t on);
uint32_t sofia_presence_get_cseq(sofia_profile_t *profile);
void sofia_glue_build_vid_refresh_message(switch_core_session_t *session, const char *pl);
char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, nua_handle_t *nh, sofia_dispatch_event_t *de, sofia_nat_parse_t *np);

View File

@ -2114,6 +2114,28 @@ static int sofia_dialog_probe_callback(void *pArg, int argc, char **argv, char *
return 0;
}
uint32_t sofia_presence_get_cseq(sofia_profile_t *profile)
{
uint32_t callsequence;
uint32_t now = (uint32_t) switch_epoch_time_now(NULL);
switch_mutex_lock(profile->ireg_mutex);
callsequence = (now - mod_sofia_globals.presence_epoch) * 100;
if (profile->last_cseq && callsequence <= profile->last_cseq) {
callsequence = ++profile->last_cseq;
}
profile->last_cseq = callsequence;
switch_mutex_unlock(profile->ireg_mutex);
return callsequence;
}
#define send_presence_notify(_a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l) \
_send_presence_notify(_a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l,__FILE__, __SWITCH_FUNC__, __LINE__)
@ -2286,20 +2308,13 @@ static void _send_presence_notify(sofia_profile_t *profile,
}
switch_mutex_lock(profile->ireg_mutex);
if (!profile->cseq_base) {
profile->cseq_base = (now - 1312693200) * 10;
}
callsequence = ++profile->cseq_base;
switch_mutex_unlock(profile->ireg_mutex);
callsequence = sofia_presence_get_cseq(profile);
if (cparams) {
send_contact = switch_mprintf("%s;%s", contact_str, cparams);
contact_str = send_contact;
}
nh = nua_handle(profile->nua, NULL, NUTAG_URL(contact), SIPTAG_CONTACT_STR(contact_str), TAG_END());
cseq = sip_cseq_create(nh->nh_home, callsequence, SIP_METHOD_NOTIFY);
nua_handle_bind(nh, &mod_sofia_globals.destroy_private);