Skip to content

Commit

Permalink
Add new nua_handle_destroy_user() API.
Browse files Browse the repository at this point in the history
  • Loading branch information
andywolk committed Sep 14, 2023
1 parent 563fa31 commit 9255332
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
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
3 changes: 3 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,9 @@ 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:
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

0 comments on commit 9255332

Please sign in to comment.