Commit f6d468cf authored by Pekka Pessi's avatar Pekka Pessi

nua: refactored dialog refresh code

darcs-hash:20070723205948-65a35-b1087fa43f5773dfffef1380df26ca13b2926ac2.gz
parent 07fd7537
......@@ -214,7 +214,7 @@ void nua_destroy(nua_t *nua)
if (!nua->nua_shutdown_final) {
SU_DEBUG_0(("nua_destroy(%p): FATAL: nua_shutdown not completed\n",
(void *)nua));
assert(nua->nua_shutdown);
assert(nua->nua_usage_queue->queue_shutdown);
return;
}
......
......@@ -114,6 +114,7 @@ nua_handle_t *nh_create_handle(nua_t *nua,
nh->nh_nua = nua;
nh->nh_magic = hmagic;
nh->nh_prefs = nua->nua_dhandle->nh_prefs;
nh->nh_ds->ds_owner = nh;
if (nua_handle_save_tags(nh, tags) < 0) {
SU_DEBUG_5(("nua(%p): creating handle %p failed\n",
......
This diff is collapsed.
......@@ -35,10 +35,6 @@
* @date Created: Wed Mar 8 11:38:18 EET 2006 ppessi
*/
typedef struct nua_dialog_state nua_dialog_state_t;
typedef struct nua_dialog_usage nua_dialog_usage_t;
typedef struct nua_remote_s nua_remote_t;
#ifndef NUA_OWNER_T
#define NUA_OWNER_T struct nua_owner_s
#endif
......@@ -48,10 +44,14 @@ typedef NUA_OWNER_T nua_owner_t;
#include <sofia-sip/nta.h>
#endif
typedef su_msg_r nua_saved_signal_t;
typedef struct nua_dialog_state nua_dialog_state_t;
typedef struct nua_dialog_usage nua_dialog_usage_t;
typedef struct nua_server_request nua_server_request_t;
typedef struct nua_client_request nua_client_request_t;
typedef struct nua_usage_queue nua_usage_queue_t;
typedef struct nua_dialog_peer_info nua_dialog_peer_info_t;
typedef su_msg_r nua_saved_signal_t;
typedef struct {
sip_method_t sm_method;
......@@ -272,6 +272,8 @@ struct nua_client_request
nta_outgoing_t *cr_orq;
su_timer_t *cr_timer; /**< Expires or retry timer */
/*nua_event_t*/ int cr_event; /**< Request event */
sip_method_t cr_method;
char const *cr_method_name;
......@@ -303,8 +305,10 @@ struct nua_client_request
unsigned cr_dialog:1; /**< Request can initiate dialog */
/* Current state */
unsigned cr_waiting:1; /**< Request is waiting */
unsigned cr_challenged:1; /**< Request was challenged */
unsigned cr_wait_for_cred:1; /**< Request is pending authentication */
unsigned cr_wait_for_timer:1; /**< Request is waiting for a timer to expire */
unsigned cr_restarting:1; /**< Request is being restarted */
unsigned cr_reporting:1; /**< Reporting in progress */
unsigned cr_terminating:1; /**< Request terminates the usage */
......@@ -316,6 +320,9 @@ struct nua_client_request
struct nua_dialog_state
{
/** Dialog owner */
nua_owner_t *ds_owner;
/** Dialog usages. */
nua_dialog_usage_t *ds_usage;
......@@ -351,7 +358,7 @@ struct nua_dialog_state
* if dialog is established.
*/
struct nua_remote_s {
struct nua_dialog_peer_info {
sip_allow_t *nr_allow;
sip_accept_t *nr_accept;
sip_require_t *nr_require;
......@@ -360,9 +367,12 @@ struct nua_dialog_state
} ds_remote_ua[1];
};
typedef void nh_pending_f(nua_owner_t *,
nua_dialog_usage_t *du,
sip_time_t now);
struct nua_usage_queue {
su_timer_t *queue_timer;
struct nua_usage_heap { void *private; } queue_heap[1];
su_time_t queue_next; /**< Next scheduled run, or 0 if none */
sip_time_t queue_shutdown; /**< Shutdown started */
};
/** Virtual function pointer table for dialog usage. */
typedef struct {
......@@ -388,21 +398,17 @@ typedef struct {
struct nua_dialog_usage {
nua_dialog_usage_t *du_next;
nua_usage_class const *du_class;
nua_dialog_state_t *du_dialog;
nua_client_request_t *du_cr; /**< Client request bound with usage */
unsigned du_ready:1; /**< Established usage */
unsigned du_shutdown:1; /**< Shutdown in progress */
unsigned:0;
/** When usage expires.
* Non-zero if the usage is established, SIP_TIME_MAX if there no
* expiration time.
*/
sip_time_t du_refresh; /**< When to refresh */
size_t du_queued; /**< Queued for refresh */
su_time_t du_refresh; /**< When to refresh */
sip_event_t const *du_event; /**< Event of usage */
};
void nua_dialog_uac_route(nua_owner_t *, nua_dialog_state_t *ds,
......@@ -440,13 +446,22 @@ void nua_dialog_deinit(nua_owner_t *own,
int nua_dialog_shutdown(nua_owner_t *owner, nua_dialog_state_t *ds);
int nua_dialog_repeat_shutdown(nua_owner_t *owner,
nua_dialog_state_t *ds);
nua_usage_queue_t *nua_usage_queue_by_owner(nua_owner_t *);
int nua_usage_queue_init(nua_usage_queue_t *queue, su_root_t *);
int nua_usage_queue_shutdown(nua_usage_queue_t *queue, sip_time_t now);
int nua_usage_queue_deinit(nua_usage_queue_t *queue);
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,
su_time_t target);
void nua_dialog_usage_reset_refresh(nua_dialog_usage_t *du);
......
......@@ -696,7 +696,8 @@ 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);
su_time_t tv; tv.tv_sec = nu->nu_expires, tv.tv_usec = 313313;
nua_dialog_usage_set_refresh_at(du, tv);
}
}
......
......@@ -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 {
......
This diff is collapsed.
......@@ -109,7 +109,7 @@ typedef struct register_usage nua_registration_t;
#define nua_handle_unref(nh) nua_handle_unref_by((nh), __func__)
su_inline nua_handle_t *nua_handle_ref_by(nua_handle_t *nh,
char const *by)
char const *by)
{
if (nh)
SU_DEBUG_0(("nua_handle_ref(%p) => "MOD_ZU" by %s\n", nh,
......@@ -238,12 +238,9 @@ struct nua_s {
su_root_t *nua_root;
su_task_r nua_server;
nta_agent_t *nua_nta;
su_timer_t *nua_timer;
void *nua_sip_parser;
sip_time_t nua_shutdown;
/* Route */
sip_service_route_t *nua_service_route;
......@@ -258,6 +255,8 @@ struct nua_s {
nua_handle_t *nua_handles;
nua_handle_t **nua_handles_tail;
nua_usage_queue_t nua_usage_queue[1];
};
#define nua_dhandle nua_handles
......
......@@ -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