Commit 731e1cee authored by Pekka Pessi's avatar Pekka Pessi

nua_subnotref.c: not increasing the subscription expiration time by NOTIFY

darcs-hash:20080306174833-65a35-63dc179886fa173f65f579913a79ae99890a1570.gz
parent e0a2de84
...@@ -59,7 +59,8 @@ ...@@ -59,7 +59,8 @@
struct event_usage struct event_usage
{ {
enum nua_substate eu_substate; /**< Subscription state */ enum nua_substate eu_substate; /**< Subscription state */
sip_time_t eu_expires; /**< Proposed expiration time */ unsigned eu_delta; /**< Proposed expiration */
sip_time_t eu_expires; /**< Absolute expiration time */
unsigned eu_notified; /**< Number of NOTIFYs received */ unsigned eu_notified; /**< Number of NOTIFYs received */
unsigned eu_unsolicited:1; /**< Not SUBSCRIBEd or REFERed */ unsigned eu_unsolicited:1; /**< Not SUBSCRIBEd or REFERed */
unsigned eu_refer:1; /**< Implied subscription by refer */ unsigned eu_refer:1; /**< Implied subscription by refer */
...@@ -273,16 +274,16 @@ static int nua_subscribe_client_request(nua_client_request_t *cr, ...@@ -273,16 +274,16 @@ static int nua_subscribe_client_request(nua_client_request_t *cr,
nua_dialog_usage_reset_refresh(du); /* during SUBSCRIBE transaction */ nua_dialog_usage_reset_refresh(du); /* during SUBSCRIBE transaction */
if (cr->cr_terminating) if (cr->cr_terminating)
expires = eu->eu_expires = 0; expires = eu->eu_delta = 0;
else if (sip->sip_expires) else if (sip->sip_expires)
/* Use value specified by application or negotiated with Min-Expires */ /* Use value specified by application or negotiated with Min-Expires */
expires = eu->eu_expires = sip->sip_expires->ex_delta; expires = eu->eu_delta = sip->sip_expires->ex_delta;
else else
/* We just use common default value, but the default is actually /* We just use common default value, but the default is actually
package-specific according to the RFC 3265 section 4.4.4: package-specific according to the RFC 3265 section 4.4.4:
[Event] packages MUST also define a [Event] packages MUST also define a
default "Expires" value to be used if none is specified. */ default "Expires" value to be used if none is specified. */
expires = eu->eu_expires = 3600; expires = eu->eu_delta = 3600;
eu->eu_final_wait = 0; eu->eu_final_wait = 0;
...@@ -365,14 +366,14 @@ static int nua_subscribe_client_response(nua_client_request_t *cr, ...@@ -365,14 +366,14 @@ static int nua_subscribe_client_response(nua_client_request_t *cr,
if (eu->eu_substate != nua_substate_terminated) if (eu->eu_substate != nua_substate_terminated)
/* If there is no @Expires header, /* If there is no @Expires header,
use default value stored in eu_expires */ use default value stored in eu_delta */
delta = sip_contact_expires(NULL, sip->sip_expires, sip->sip_date, delta = sip_contact_expires(NULL, sip->sip_expires, sip->sip_date,
eu->eu_expires, now); eu->eu_delta, now);
else else
delta = 0; delta = 0;
if (delta > eu->eu_expires) if (delta > eu->eu_delta)
delta = eu->eu_expires; delta = eu->eu_delta;
if (win_messenger_enable && !nua_dialog_is_established(nh->nh_ds)) { if (win_messenger_enable && !nua_dialog_is_established(nh->nh_ds)) {
/* Notify from messanger does not match with dialog tag */ /* Notify from messanger does not match with dialog tag */
...@@ -381,6 +382,7 @@ static int nua_subscribe_client_response(nua_client_request_t *cr, ...@@ -381,6 +382,7 @@ static int nua_subscribe_client_response(nua_client_request_t *cr,
if (delta > 0) { if (delta > 0) {
nua_dialog_usage_set_refresh(du, delta); nua_dialog_usage_set_refresh(du, delta);
eu->eu_expires = du->du_refquested + delta;
} }
else { else {
if (eu->eu_substate == nua_substate_terminated) { if (eu->eu_substate == nua_substate_terminated) {
...@@ -399,6 +401,11 @@ static int nua_subscribe_client_response(nua_client_request_t *cr, ...@@ -399,6 +401,11 @@ static int nua_subscribe_client_response(nua_client_request_t *cr,
nua_dialog_usage_set_refresh_range(du, delta, delta); nua_dialog_usage_set_refresh_range(du, delta, delta);
} }
else {
nua_dialog_usage_reset_refresh(du);
}
eu->eu_expires = du->du_refquested;
} }
substate = eu->eu_substate; substate = eu->eu_substate;
...@@ -592,7 +599,7 @@ int nua_notify_server_preprocess(nua_server_request_t *sr) ...@@ -592,7 +599,7 @@ int nua_notify_server_preprocess(nua_server_request_t *sr)
if (subs == NULL) { if (subs == NULL) {
/* Compatibility */ /* Compatibility */
unsigned long delta = eu->eu_expires; unsigned long delta = eu->eu_delta;
if (sip->sip_expires) if (sip->sip_expires)
delta = sip->sip_expires->ex_delta; delta = sip->sip_expires->ex_delta;
...@@ -651,8 +658,12 @@ int nua_notify_server_report(nua_server_request_t *sr, tagi_t const *tags) ...@@ -651,8 +658,12 @@ int nua_notify_server_report(nua_server_request_t *sr, tagi_t const *tags)
substate = eu->eu_substate; substate = eu->eu_substate;
if (substate == nua_substate_active || substate == nua_substate_pending) { if (substate == nua_substate_active || substate == nua_substate_pending) {
if (subs && subs->ss_expires) if (subs && subs->ss_expires) {
delta = strtoul(subs->ss_expires, NULL, 10); sip_time_t now = sip_now();
sip_time_t delta0 = strtoul(subs->ss_expires, NULL, 10);
if (now + delta0 <= eu->eu_expires)
delta = delta0;
}
} }
else if (substate == nua_substate_embryonic) { else if (substate == nua_substate_embryonic) {
if (subs && subs->ss_reason) { if (subs && subs->ss_reason) {
...@@ -690,8 +701,10 @@ int nua_notify_server_report(nua_server_request_t *sr, tagi_t const *tags) ...@@ -690,8 +701,10 @@ int nua_notify_server_report(nua_server_request_t *sr, tagi_t const *tags)
nua_dialog_usage_set_refresh_range(du, retry, retry + 5); nua_dialog_usage_set_refresh_range(du, retry, retry + 5);
} }
else { else {
if (delta < SIP_TIME_MAX) if (delta < SIP_TIME_MAX) {
nua_dialog_usage_set_refresh(du, delta); nua_dialog_usage_set_refresh(du, delta);
eu->eu_expires = du->du_refquested + delta;
}
} }
return retval; return retval;
......
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