mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-27 06:31:54 +00:00
chan_sip.c: Simplify sip_pvt destructor call levels.
Remove destructor calling destroy_it calling really_destroy_it for no benefit. Just make the destructor the really_destroy_it function. Change-Id: Idea0d47b27dd74f2488db75bcc7f353d8fdc614a
This commit is contained in:
@@ -6381,11 +6381,14 @@ static void offered_media_list_destroy(struct sip_pvt *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Execute destruction of SIP dialog structure, release memory */
|
/*! \brief ao2 destructor for SIP dialog structure */
|
||||||
void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
|
static void sip_pvt_dtor(void *vdoomed)
|
||||||
{
|
{
|
||||||
|
struct sip_pvt *p = vdoomed;
|
||||||
struct sip_request *req;
|
struct sip_request *req;
|
||||||
|
|
||||||
|
ast_debug(3, "Destroying SIP dialog %s\n", p->callid);
|
||||||
|
|
||||||
/* Destroy Session-Timers if allocated */
|
/* Destroy Session-Timers if allocated */
|
||||||
if (p->stimer) {
|
if (p->stimer) {
|
||||||
p->stimer->quit_flag = 1;
|
p->stimer->quit_flag = 1;
|
||||||
@@ -6404,13 +6407,11 @@ void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
|
|||||||
|
|
||||||
/* Unlink us from the owner if we have one */
|
/* Unlink us from the owner if we have one */
|
||||||
if (p->owner) {
|
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_debug(1, "Detaching from %s\n", ast_channel_name(p->owner));
|
||||||
ast_channel_tech_pvt_set(p->owner, NULL);
|
ast_channel_tech_pvt_set(p->owner, NULL);
|
||||||
/* Make sure that the channel knows its backend is going away */
|
/* Make sure that the channel knows its backend is going away */
|
||||||
ast_channel_softhangup_internal_flag_add(p->owner, AST_SOFTHANGUP_DEV);
|
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 */
|
/* Give the channel a chance to react before deallocation */
|
||||||
usleep(1);
|
usleep(1);
|
||||||
@@ -6716,24 +6717,6 @@ static int update_call_counter(struct sip_pvt *fup, int event)
|
|||||||
return 0;
|
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 */
|
/*! \brief Convert SIP hangup causes to Asterisk hangup causes */
|
||||||
int hangup_sip2cause(int cause)
|
int hangup_sip2cause(int cause)
|
||||||
{
|
{
|
||||||
@@ -8635,7 +8618,7 @@ struct sip_pvt *__sip_alloc(ast_string_field callid, struct ast_sockaddr *addr,
|
|||||||
{
|
{
|
||||||
struct sip_pvt *p;
|
struct sip_pvt *p;
|
||||||
|
|
||||||
p = __ao2_alloc(sizeof(*p), sip_destroy_fn,
|
p = __ao2_alloc(sizeof(*p), sip_pvt_dtor,
|
||||||
AO2_ALLOC_OPT_LOCK_MUTEX, "allocate a dialog(pvt) struct",
|
AO2_ALLOC_OPT_LOCK_MUTEX, "allocate a dialog(pvt) struct",
|
||||||
file, line, func);
|
file, line, func);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
|
|||||||
@@ -43,19 +43,6 @@ void sip_scheddestroy_final(struct sip_pvt *p, int ms);
|
|||||||
void sip_scheddestroy(struct sip_pvt *p, int ms);
|
void sip_scheddestroy(struct sip_pvt *p, int ms);
|
||||||
int sip_cancel_destroy(struct sip_pvt *p);
|
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
|
* \brief Unlink a dialog from the dialogs container, as well as any other places
|
||||||
* that it may be currently stored.
|
* that it may be currently stored.
|
||||||
|
|||||||
Reference in New Issue
Block a user