Commit 92ab2130 authored by Pekka Pessi's avatar Pekka Pessi

nua_dialog.[hc]: renamed functions setting refresh interval

darcs-hash:20070906160125-65a35-507322edb7907b488832d65891263465a27519c2.gz
parent 67d47760
......@@ -450,29 +450,28 @@ void nua_dialog_deinit(nua_owner_t *own,
* if @a delta is less than 5 minutes but longer than 90 seconds, 30..60
* seconds before end of interval.
*
* If @a delta is 0, the refresh time is set at the end of the world
* (maximum time, for 32-bit systems sometimes during 2036).
* If @a delta is 0, the dialog usage is never refreshed.
*/
void nua_dialog_usage_set_refresh(nua_dialog_usage_t *du, unsigned delta)
{
if (delta == 0)
du->du_refresh = 0;
nua_dialog_usage_reset_refresh(du);
else if (delta > 90 && delta < 5 * 60)
/* refresh 30..60 seconds before deadline */
nua_dialog_usage_refresh_range(du, delta - 60, delta - 30);
nua_dialog_usage_set_refresh_range(du, delta - 60, delta - 30);
else {
/* By default, refresh around half time before deadline */
unsigned min = (delta + 2) / 4;
unsigned max = (delta + 2) / 4 + (delta + 1) / 2;
if (min == 0)
min = 1;
nua_dialog_usage_refresh_range(du, min, max);
nua_dialog_usage_set_refresh_range(du, min, max);
}
}
/**@internal Set refresh in range min..max seconds in the future. */
void nua_dialog_usage_refresh_range(nua_dialog_usage_t *du,
unsigned min, unsigned max)
void nua_dialog_usage_set_refresh_range(nua_dialog_usage_t *du,
unsigned min, unsigned max)
{
sip_time_t now = sip_now(), target;
unsigned delta;
......@@ -493,12 +492,12 @@ void nua_dialog_usage_refresh_range(nua_dialog_usage_t *du,
SU_DEBUG_7(("nua(): refresh %s after %lu seconds (in [%u..%u])\n",
nua_dialog_usage_name(du), target - now, min, max));
du->du_refresh = target;
nua_dialog_usage_set_refresh_at(du, target);
}
/** Set absolute refresh time */
void nua_dialog_usage_refresh_at(nua_dialog_usage_t *du,
sip_time_t target)
void nua_dialog_usage_set_refresh_at(nua_dialog_usage_t *du,
sip_time_t target)
{
SU_DEBUG_7(("nua(): refresh %s after %lu seconds\n",
nua_dialog_usage_name(du), target - sip_now()));
......@@ -552,18 +551,18 @@ int nua_dialog_shutdown(nua_owner_t *owner, nua_dialog_state_t *ds)
return 1;
}
/** (Gracefully) terminate usage.
/** Shutdown (gracefully terminate) usage.
*
* @retval >0 shutdown done
* @retval 0 shutdown in progress
* @retval <0 try again later
*/
int nua_dialog_usage_shutdown(nua_owner_t *owner,
nua_dialog_state_t *ds,
nua_dialog_usage_t *du)
nua_dialog_state_t *ds,
nua_dialog_usage_t *du)
{
if (du) {
du->du_refresh = 0;
nua_dialog_usage_reset_refresh(du);
du->du_shutdown = 1;
assert(du->du_class->usage_shutdown);
return du->du_class->usage_shutdown(owner, ds, du);
......
......@@ -442,11 +442,11 @@ int nua_dialog_shutdown(nua_owner_t *owner, nua_dialog_state_t *ds);
void nua_dialog_usage_set_refresh(nua_dialog_usage_t *du, unsigned delta);
void nua_dialog_usage_refresh_range(nua_dialog_usage_t *du,
unsigned min, unsigned max);
void nua_dialog_usage_set_refresh_range(nua_dialog_usage_t *du,
unsigned min, unsigned max);
void nua_dialog_usage_refresh_at(nua_dialog_usage_t *du,
sip_time_t target);
void nua_dialog_usage_set_refresh_at(nua_dialog_usage_t *du,
sip_time_t target);
void nua_dialog_usage_reset_refresh(nua_dialog_usage_t *du);
......
......@@ -696,7 +696,7 @@ static int nua_notify_client_report(nua_client_request_t *cr,
nua_client_resend_request(cr, 0);
}
else if (nu->nu_expires) {
nua_dialog_usage_refresh_at(du, nu->nu_expires);
nua_dialog_usage_set_refresh_at(du, nu->nu_expires);
}
}
......
......@@ -973,7 +973,7 @@ static int nua_register_client_response(nua_client_request_t *cr,
nua_registration_set_ready(nr, 1);
}
else if (du) {
nua_dialog_usage_set_refresh(du, 0);
nua_dialog_usage_reset_refresh(du);
su_free(nh->nh_home, nr->nr_route);
nr->nr_route = NULL;
......@@ -1028,7 +1028,7 @@ void nua_register_connection_closed(tp_stack_t *sip_stack,
tport_unref(nr->nr_tport), nr->nr_tport = NULL;
/* Schedule re-REGISTER immediately */
nua_dialog_usage_refresh_at(nua_dialog_usage_public(nr), sip_now());
nua_dialog_usage_set_refresh_range(nua_dialog_usage_public(nr), 0, 0);
}
......
......@@ -642,7 +642,7 @@ static int nua_invite_client_request(nua_client_request_t *cr,
invite_timeout = UINT_MAX;
/* Send CANCEL if we don't get response within timeout*/
/* nua_dialog_usage_set_expires(du, invite_timeout); Xyzzy */
nua_dialog_usage_set_refresh(du, 0);
nua_dialog_usage_reset_refresh(du);
/* Add session timer headers */
if (session_timer_is_supported(ss->ss_timer))
......@@ -4131,7 +4131,7 @@ session_timer_set(nua_session_usage_t *ss)
if (t->interval >= 90)
low -=5, high += 5;
nua_dialog_usage_refresh_range(du, low, high);
nua_dialog_usage_set_refresh_range(du, low, high);
t->timer_set = 1;
}
else if (t->refresher == nua_remote_refresher) {
......@@ -4144,7 +4144,7 @@ session_timer_set(nua_session_usage_t *ss)
interval -= 32 > interval / 6 ? interval / 3 : 32 + interval / 3;
nua_dialog_usage_refresh_range(du, interval, interval);
nua_dialog_usage_set_refresh_range(du, interval, interval);
t->timer_set = 1;
}
else {
......
......@@ -389,7 +389,7 @@ static int nua_subscribe_client_response(nua_client_request_t *cr,
if (eu->eu_substate == nua_substate_terminated)
eu->eu_substate = nua_substate_embryonic;
nua_dialog_usage_refresh_range(du, delta, delta);
nua_dialog_usage_set_refresh_range(du, delta, delta);
}
else {
eu->eu_substate = nua_substate_terminated;
......@@ -681,7 +681,7 @@ int nua_notify_server_report(nua_server_request_t *sr, tagi_t const *tags)
else if (retry >= 0) { /* Try to subscribe again */
/* XXX - this needs through testing */
nua_dialog_remove(nh, nh->nh_ds, du); /* tear down */
nua_dialog_usage_refresh_range(du, retry, retry + 5);
nua_dialog_usage_set_refresh_range(du, retry, retry + 5);
}
else {
nua_dialog_usage_set_refresh(du, delta);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment