Skip to content

Commit 9255332

Browse files
committed
Add new nua_handle_destroy_user() API.
1 parent 563fa31 commit 9255332

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

libsofia-sip-ua/nua/nua.c

+30
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,36 @@ void nua_handle_destroy(nua_handle_t *nh)
925925
}
926926
}
927927

928+
/** Attempt to destroy a handle indirectly.
929+
*
930+
* Does not destroy the handle directly but forwards the nua_r_destroy_user event
931+
* to the application so it could call nua_handle_destroy() from there.
932+
*
933+
* @param nh Pointer to operation handle
934+
*
935+
* @return
936+
* nothing
937+
*
938+
* @par Related Tags:
939+
* none
940+
*
941+
* @par Events:
942+
* none
943+
*
944+
* * @since New in @VERSION_1_13_17.
945+
*
946+
* @sa nua_handle_destroy(), nua_handle(), nua_handle_bind(), nua_handle_ref(), nua_handle_unref(),
947+
* nua_unregister(), nua_unpublish(), nua_unsubscribe(), nua_bye().
948+
*/
949+
void nua_handle_destroy_user(nua_handle_t *nh)
950+
{
951+
enter;
952+
953+
if (NH_IS_VALID(nh)) {
954+
nua_signal(nh->nh_nua, nh, NULL, nua_r_destroy_user, 0, NULL, TAG_END());
955+
}
956+
}
957+
928958
/* ---------------------------------------------------------------------- */
929959

930960
struct nua_stack_handle_make_replaces_args {

libsofia-sip-ua/nua/nua_common.c

+1
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ char const *nua_event_name(nua_event_t event)
378378
case nua_r_ack: return "nua_r_ack";
379379
case nua_r_handle_unref: return "nua_r_handle_unref";
380380
case nua_r_unref: return "nua_r_unref";
381+
case nua_r_destroy_user: return "nua_r_destroy_user";
381382
default: return "NUA_UNKNOWN";
382383
}
383384
}

libsofia-sip-ua/nua/nua_stack.c

+3
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,9 @@ void nua_stack_signal(nua_t *nua, su_msg_r msg, nua_ee_data_t *ee)
690690
su_msg_destroy(nua->nua_signal);
691691
}
692692
return;
693+
case nua_r_destroy_user:
694+
nua_stack_event(nh->nh_nua, nh, NULL, nua_r_destroy_user, 0, NULL, NULL);
695+
break;
693696
case nua_r_unref:
694697
nua_unref(nua);
695698
break;

libsofia-sip-ua/nua/sofia-sip/nua.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ typedef enum nua_event_e {
161161
nua_i_register, /**< Incoming REGISTER. @NEW_1_12_4. */
162162
nua_r_unref, /** Calls nua_unref() from dispatcher @NEW_1_13_3 */
163163
nua_r_handle_unref, /** Calls nua_handle_unref() from dispatcher @NEW_1_13_3 */
164-
nua_r_nta_agent_resolver_clean_dns_cache /** Calls nua_resolver_clean_dns_cache() from dispatcher @NEW_1_13_12 */
164+
nua_r_nta_agent_resolver_clean_dns_cache, /** Calls nua_resolver_clean_dns_cache() from dispatcher @NEW_1_13_12 */
165+
nua_r_destroy_user /** Requests dispatcher to forward the event to the app's callback @NEW_1_13_17 */
165166
} nua_event_t;
166167

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

223+
/** 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. */
224+
SOFIAPUBFUN void nua_handle_destroy_user(nua_handle_t *h);
225+
222226
/** Make a new reference to handle */
223227
SOFIAPUBFUN nua_handle_t *nua_handle_ref(nua_handle_t *);
224228

0 commit comments

Comments
 (0)