summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorzuul <zuul@gerrit.asterisk.org>2016-03-16 12:14:23 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2016-03-16 12:14:24 -0500
commit739c28357e609a1893ba72d1c9c6544afa31e200 (patch)
treee0e1beb41a4dc972b206437df21a098db70dd148 /channels
parent61863068525cc67dbc883415fd78c1d624d000fc (diff)
parent56bcb97a3cae238a2ff06db2ff2a46e3dd04599f (diff)
Merge "chan_sip.c: Simplify sip_pvt destructor call levels." into 13
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c33
-rw-r--r--channels/sip/include/dialog.h13
2 files changed, 8 insertions, 38 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 3d45b384e..bbe260f60 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -6371,11 +6371,14 @@ static void offered_media_list_destroy(struct sip_pvt *p)
}
}
-/*! \brief Execute destruction of SIP dialog structure, release memory */
-void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
+/*! \brief ao2 destructor for SIP dialog structure */
+static void sip_pvt_dtor(void *vdoomed)
{
+ struct sip_pvt *p = vdoomed;
struct sip_request *req;
+ ast_debug(3, "Destroying SIP dialog %s\n", p->callid);
+
/* Destroy Session-Timers if allocated */
if (p->stimer) {
p->stimer->quit_flag = 1;
@@ -6394,14 +6397,12 @@ void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
/* Unlink us from the owner if we have one */
if (p->owner) {
- if (lockowner)
- ast_channel_lock(p->owner);
+ ast_channel_lock(p->owner);
ast_debug(1, "Detaching from %s\n", ast_channel_name(p->owner));
ast_channel_tech_pvt_set(p->owner, NULL);
/* Make sure that the channel knows its backend is going away */
ast_channel_softhangup_internal_flag_add(p->owner, AST_SOFTHANGUP_DEV);
- if (lockowner)
- ast_channel_unlock(p->owner);
+ ast_channel_unlock(p->owner);
/* Give the channel a chance to react before deallocation */
usleep(1);
}
@@ -6711,24 +6712,6 @@ static int update_call_counter(struct sip_pvt *fup, int event)
return 0;
}
-
-static void sip_destroy_fn(void *p)
-{
- sip_destroy(p);
-}
-
-/*! \brief Destroy SIP call structure.
- * Make it return NULL so the caller can do things like
- * foo = sip_destroy(foo);
- * and reduce the chance of bugs due to dangling pointers.
- */
-struct sip_pvt *sip_destroy(struct sip_pvt *p)
-{
- ast_debug(3, "Destroying SIP dialog %s\n", p->callid);
- __sip_destroy(p, TRUE, TRUE);
- return NULL;
-}
-
/*! \brief Convert SIP hangup causes to Asterisk hangup causes */
int hangup_sip2cause(int cause)
{
@@ -8634,7 +8617,7 @@ struct sip_pvt *__sip_alloc(ast_string_field callid, struct ast_sockaddr *addr,
{
struct sip_pvt *p;
- p = __ao2_alloc_debug(sizeof(*p), sip_destroy_fn,
+ p = __ao2_alloc_debug(sizeof(*p), sip_pvt_dtor,
AO2_ALLOC_OPT_LOCK_MUTEX, "allocate a dialog(pvt) struct",
file, line, func, 1);
if (!p) {
diff --git a/channels/sip/include/dialog.h b/channels/sip/include/dialog.h
index 582841d54..c0dfd605a 100644
--- a/channels/sip/include/dialog.h
+++ b/channels/sip/include/dialog.h
@@ -43,19 +43,6 @@ void sip_scheddestroy_final(struct sip_pvt *p, int ms);
void sip_scheddestroy(struct sip_pvt *p, int ms);
int sip_cancel_destroy(struct sip_pvt *p);
-/*! \brief Destroy SIP call structure.
- * Make it return NULL so the caller can do things like
- * foo = sip_destroy(foo);
- * and reduce the chance of bugs due to dangling pointers.
- */
-struct sip_pvt *sip_destroy(struct sip_pvt *p);
-
-/*! \brief Destroy SIP call structure.
- * Make it return NULL so the caller can do things like
- * foo = sip_destroy(foo);
- * and reduce the chance of bugs due to dangling pointers.
- */
-void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist);
/*!
* \brief Unlink a dialog from the dialogs container, as well as any other places
* that it may be currently stored.