Commit 8bbc5838 authored by Pekka Pessi's avatar Pekka Pessi

nua client: fixed possible crash when terminating a dialog usage.

darcs-hash:20070410200413-65a35-ba4ffafd73488b9e7c11a1acbf302be563e081d6.gz
parent c5148618
......@@ -561,8 +561,13 @@ int nua_dialog_shutdown(nua_owner_t *owner, nua_dialog_state_t *ds)
return 1;
}
/** (Gracefully) terminate usage */
void nua_dialog_usage_shutdown(nua_owner_t *owner,
/** (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)
{
......@@ -570,6 +575,8 @@ void nua_dialog_usage_shutdown(nua_owner_t *owner,
du->du_refresh = 0;
du->du_shutdown = 1;
assert(du->du_class->usage_shutdown);
du->du_class->usage_shutdown(owner, ds, du);
return du->du_class->usage_shutdown(owner, ds, du);
}
else
return 200;
}
......@@ -453,9 +453,9 @@ void nua_dialog_usage_refresh(nua_owner_t *owner,
nua_dialog_usage_t *du,
sip_time_t now);
void nua_dialog_usage_shutdown(nua_owner_t *owner,
nua_dialog_state_t *ds,
nua_dialog_usage_t *du);
int nua_dialog_usage_shutdown(nua_owner_t *owner,
nua_dialog_state_t *ds,
nua_dialog_usage_t *du);
static inline
int nua_dialog_is_established(nua_dialog_state_t const *ds)
......
......@@ -2641,22 +2641,23 @@ int nua_base_client_response(nua_client_request_t *cr,
if (cr->cr_terminated < 0) {
/* XXX - dialog has been terminated */;
nua_dialog_deinit(nh, nh->nh_ds);
nua_dialog_deinit(nh, nh->nh_ds), cr->cr_usage = NULL;
}
else if (du) {
if (cr->cr_terminated ||
(!du->du_ready && status >= 300 && nua_client_is_bound(cr))) {
/* Usage has been destroyed */
nua_dialog_usage_remove(nh, nh->nh_ds, du);
nua_dialog_usage_remove(nh, nh->nh_ds, du), cr->cr_usage = NULL;
}
else if (cr->cr_graceful) {
/* Terminate usage gracefully */
nua_dialog_usage_shutdown(nh, nh->nh_ds, du);
if (nua_dialog_usage_shutdown(nh, nh->nh_ds, du) > 0)
cr->cr_usage = NULL;
}
}
else if (cr->cr_terminated) {
if (nh->nh_ds->ds_usage == NULL)
nua_dialog_remove(nh, nh->nh_ds, NULL);
nua_dialog_remove(nh, nh->nh_ds, NULL), cr->cr_usage = NULL;
}
cr->cr_reporting = 0, nh->nh_ds->ds_reporting = 0;
......
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