Skip to content

Commit

Permalink
Merge pull request #38 from freeswitch/refrace
Browse files Browse the repository at this point in the history
Add new nua_unref_user() and nua_handle_unref_user() APIs. Fix race in nua_handle_by_call_id() and nua_handle_by_replaces(). Version bump to 1.13.3
  • Loading branch information
briankwest committed Feb 23, 2021
2 parents 2a2c3ac + 067046c commit d2f3f91
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 14 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dnl information on the package
dnl ---------------------------

dnl update both the version for AC_INIT and the LIBSOFIA_SIP_UA_MAJOR_MINOR
AC_INIT([sofia-sip], [1.13.2])
AC_INIT([sofia-sip], [1.13.3])

CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
sofia-sip (1.13.3-1) unstable; urgency=medium

* New Release.

-- FreeSWITCH Solutions <[email protected]> Fri, 11 Dec 2020 01:13:37 +0200

sofia-sip (1.13.2-1) unstable; urgency=medium

* New Release.
Expand Down
39 changes: 31 additions & 8 deletions libsofia-sip-ua/nua/nua.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,12 @@ static int nua_stack_handle_by_replaces_call(void *arg)
struct nua_stack_handle_by_replaces_args *a = arg;

a->retval = nua_stack_handle_by_replaces(a->nua, a->r);
if (!NH_IS_VALID(a->retval) || NH_IS_DEFAULT(a->retval)) {
a->retval = NULL;
return 1;
}

nua_handle_ref(a->retval);

return 0;
}
Expand All @@ -1020,6 +1026,12 @@ static int nua_stack_handle_by_call_id_call(void *arg)
struct nua_stack_handle_by_call_id_args *a = arg;

a->retval = nua_stack_handle_by_call_id(a->nua, a->call_id);
if (!NH_IS_VALID(a->retval) || NH_IS_DEFAULT(a->retval)) {
a->retval = NULL;
return 1;
}

nua_handle_ref(a->retval);

return 0;
}
Expand Down Expand Up @@ -1050,10 +1062,7 @@ nua_handle_t *nua_handle_by_replaces(nua_t *nua, sip_replaces_t const *r)
if (su_task_execute(nua->nua_server,
nua_stack_handle_by_replaces_call, (void *)&a,
NULL) == 0) {
nua_handle_t *nh = a.retval;

if (nh && !NH_IS_DEFAULT(nh) && nh->nh_valid)
return nua_handle_ref(nh);
return a.retval;
}
}
return NULL;
Expand Down Expand Up @@ -1085,10 +1094,7 @@ nua_handle_t *nua_handle_by_call_id(nua_t *nua, const char *call_id)
if (su_task_execute(nua->nua_server,
nua_stack_handle_by_call_id_call, (void *)&a,
NULL) == 0) {
nua_handle_t *nh = a.retval;

if (nh && !NH_IS_DEFAULT(nh) && nh->nh_valid)
return nua_handle_ref(nh);
return a.retval;
}
}
return NULL;
Expand Down Expand Up @@ -1150,3 +1156,20 @@ void nua_handle_dialog_usage_set_refresh_range(nua_handle_t *nh,
nua_dialog_usage_set_refresh_range(nh->nh_ds->ds_usage, min, max);
}
}

void nua_unref_user(nua_t *nua)
{
enter;
nua_signal(nua, NULL, NULL, nua_r_unref, 0, NULL, TAG_NULL());
}

void nua_handle_unref_user(nua_handle_t *nh)
{
enter;
if (NH_IS_VALID(nh)) {
nua_signal(nh->nh_nua, nh, NULL, nua_r_handle_unref, 0, NULL, TAG_NULL());
}
else {
SU_DEBUG_1(("nua: nua_r_handle_unref with invalid handle %p\n", (void *)nh));
}
}
6 changes: 6 additions & 0 deletions libsofia-sip-ua/nua/nua_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,12 @@ 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_unref:
nua_unref(nua);
break;
case nua_r_handle_unref:
nua_handle_unref(nh);
break;
default:
break;
}
Expand Down
8 changes: 7 additions & 1 deletion libsofia-sip-ua/nua/sofia-sip/nua.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ typedef enum nua_event_e {
compatibility! */
nua_i_network_changed, /**< Local IP(v6) address has changed.
@NEW_1_12_2 */
nua_i_register /**< Incoming REGISTER. @NEW_1_12_4. */
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_event_t;

typedef struct event_s {
Expand Down Expand Up @@ -393,6 +395,10 @@ nua_handle_t *nua_handle_by_call_id(nua_t *nua, const char *call_id);
SOFIAPUBFUN const nta_leg_t *nua_get_dialog_state_leg(nua_handle_t *nh);
SOFIAPUBFUN su_home_t *nua_handle_get_home(nua_handle_t *nh);
SOFIAPUBFUN void nua_unref(nua_t *nua);
/** Destroy reference to nua using dispatcher */
SOFIAPUBFUN void nua_unref_user(nua_t *nua);
/** Destroy reference to handle using dispatcher */
SOFIAPUBFUN void nua_handle_unref_user(nua_handle_t *nh);
SOFIAPUBFUN su_home_t *nua_get_home(nua_t *nua);
SOFIAPUBFUN nta_agent_t *nua_get_agent(nua_t *nua);
SOFIAPUBFUN void nua_handle_set_has_invite(nua_handle_t *nh, unsigned val);
Expand Down
6 changes: 3 additions & 3 deletions open_c/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,13 @@
#define PACKAGE_NAME "sofia-sip"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "sofia-sip 1.13.2work"
#define PACKAGE_STRING "sofia-sip 1.13.3work"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "sofia-sip"

/* Define to the version of this package. */
#define PACKAGE_VERSION "1.13.2work"
#define PACKAGE_VERSION "1.13.3work"

/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
Expand All @@ -408,7 +408,7 @@
#define TIME_WITH_SYS_TIME 1

/* Version number of package */
#define VERSION "1.13.2work"
#define VERSION "1.13.3work"

/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
Expand Down
2 changes: 1 addition & 1 deletion sofia-sip.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: sofia-sip
Version: 1.13.2
Version: 1.13.3
Release: 1%{?dist}
Summary: Sofia SIP User-Agent library

Expand Down

0 comments on commit d2f3f91

Please sign in to comment.