Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Add new nua_handle_destroy_user() API. #228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions libsofia-sip-ua/nua/nua.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,36 @@ void nua_handle_destroy(nua_handle_t *nh)
}
}

/** Attempt to destroy a handle indirectly.
*
* Does not destroy the handle directly but forwards the nua_r_destroy_user event
* to the application so it could call nua_handle_destroy() from there.
*
* @param nh Pointer to operation handle
*
* @return
* nothing
*
* @par Related Tags:
* none
*
* @par Events:
* none
*
* * @since New in @VERSION_1_13_17.
*
* @sa nua_handle_destroy(), nua_handle(), nua_handle_bind(), nua_handle_ref(), nua_handle_unref(),
* nua_unregister(), nua_unpublish(), nua_unsubscribe(), nua_bye().
*/
void nua_handle_destroy_user(nua_handle_t *nh)
{
enter;

if (NH_IS_VALID(nh)) {
nua_signal(nh->nh_nua, nh, NULL, nua_r_destroy_user, 0, NULL, TAG_END());
}
}

/* ---------------------------------------------------------------------- */

struct nua_stack_handle_make_replaces_args {
Expand Down
1 change: 1 addition & 0 deletions libsofia-sip-ua/nua/nua_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ char const *nua_event_name(nua_event_t event)
case nua_r_ack: return "nua_r_ack";
case nua_r_handle_unref: return "nua_r_handle_unref";
case nua_r_unref: return "nua_r_unref";
case nua_r_destroy_user: return "nua_r_destroy_user";
default: return "NUA_UNKNOWN";
}
}
Expand Down
5 changes: 5 additions & 0 deletions libsofia-sip-ua/nua/nua_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,11 @@ void nua_stack_signal(nua_t *nua, su_msg_r msg, nua_ee_data_t *ee)
su_msg_destroy(nua->nua_signal);
}
return;
case nua_r_destroy_user:
if (nh) {
nua_stack_event(nh->nh_nua, nh, NULL, nua_r_destroy_user, 0, NULL, NULL);
}
break;
case nua_r_unref:
nua_unref(nua);
break;
Expand Down
6 changes: 5 additions & 1 deletion libsofia-sip-ua/nua/sofia-sip/nua.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ typedef enum nua_event_e {
nua_i_register, /**< Incoming REGISTER. @NEW_1_12_4. */
nua_r_unref, /** Calls nua_unref() from dispatcher @NEW_1_13_3 */
nua_r_handle_unref, /** Calls nua_handle_unref() from dispatcher @NEW_1_13_3 */
nua_r_nta_agent_resolver_clean_dns_cache /** Calls nua_resolver_clean_dns_cache() from dispatcher @NEW_1_13_12 */
nua_r_nta_agent_resolver_clean_dns_cache, /** Calls nua_resolver_clean_dns_cache() from dispatcher @NEW_1_13_12 */
nua_r_destroy_user /** Requests dispatcher to forward the event to the app's callback @NEW_1_13_17 */
} nua_event_t;

typedef struct event_s {
Expand Down Expand Up @@ -219,6 +220,9 @@ SOFIAPUBFUN nua_handle_t *nua_handle(nua_t *nua, nua_hmagic_t *hmagic,
/** Destroy a handle */
SOFIAPUBFUN void nua_handle_destroy(nua_handle_t *h);

/** Does not destroy the handle directly but forwards the nua_r_destroy_user event to the application so it could call nua_handle_destroy() from there. */
SOFIAPUBFUN void nua_handle_destroy_user(nua_handle_t *h);

/** Make a new reference to handle */
SOFIAPUBFUN nua_handle_t *nua_handle_ref(nua_handle_t *);

Expand Down