Index: chan_iax2.c =================================================================== --- chan_iax2.c (revision 16775) +++ chan_iax2.c (working copy) @@ -1642,6 +1642,30 @@ return res; } +static void iax2_destroy_helper(struct chan_iax2_pvt *pvt) +{ + /* No more pings or lagrq's */ + if (pvt->pingid > -1) + ast_sched_del(sched, pvt->pingid); + pvt->pingid = -1; + if (pvt->lagid > -1) + ast_sched_del(sched, pvt->lagid); + pvt->lagid = -1; + if (pvt->autoid > -1) + ast_sched_del(sched, pvt->autoid); + pvt->autoid = -1; + if (pvt->authid > -1) + ast_sched_del(sched, pvt->authid); + pvt->authid = -1; + if (pvt->initid > -1) + ast_sched_del(sched, pvt->initid); + pvt->initid = -1; +#ifdef NEWJB + if (pvt->jbid > -1) + ast_sched_del(sched, pvt->jbid); + pvt->jbid = -1; +#endif +} static int iax2_predestroy(int callno) { @@ -1654,27 +1678,7 @@ return -1; } if (!ast_test_flag(pvt, IAX_ALREADYGONE)) { - /* No more pings or lagrq's */ - if (pvt->pingid > -1) - ast_sched_del(sched, pvt->pingid); - if (pvt->lagid > -1) - ast_sched_del(sched, pvt->lagid); - if (pvt->autoid > -1) - ast_sched_del(sched, pvt->autoid); - if (pvt->authid > -1) - ast_sched_del(sched, pvt->authid); - if (pvt->initid > -1) - ast_sched_del(sched, pvt->initid); -#ifdef NEWJB - if (pvt->jbid > -1) - ast_sched_del(sched, pvt->jbid); - pvt->jbid = -1; -#endif - pvt->pingid = -1; - pvt->lagid = -1; - pvt->autoid = -1; - pvt->initid = -1; - pvt->authid = -1; + iax2_destroy_helper(pvt); ast_set_flag(pvt, IAX_ALREADYGONE); } c = pvt->owner; @@ -1729,27 +1733,7 @@ if (pvt) { if (!owner) pvt->owner = NULL; - /* No more pings or lagrq's */ - if (pvt->pingid > -1) - ast_sched_del(sched, pvt->pingid); - if (pvt->lagid > -1) - ast_sched_del(sched, pvt->lagid); - if (pvt->autoid > -1) - ast_sched_del(sched, pvt->autoid); - if (pvt->authid > -1) - ast_sched_del(sched, pvt->authid); - if (pvt->initid > -1) - ast_sched_del(sched, pvt->initid); -#ifdef NEWJB - if (pvt->jbid > -1) - ast_sched_del(sched, pvt->jbid); - pvt->jbid = -1; -#endif - pvt->pingid = -1; - pvt->lagid = -1; - pvt->autoid = -1; - pvt->authid = -1; - pvt->initid = -1; + iax2_destroy_helper(pvt); if (pvt->bridgetrans) ast_translator_free_path(pvt->bridgetrans); pvt->bridgetrans = NULL; @@ -6050,29 +6034,9 @@ return -1; } -static int stop_stuff(int callno) +static void stop_stuff(int callno) { - if (iaxs[callno]->lagid > -1) - ast_sched_del(sched, iaxs[callno]->lagid); - iaxs[callno]->lagid = -1; - if (iaxs[callno]->pingid > -1) - ast_sched_del(sched, iaxs[callno]->pingid); - iaxs[callno]->pingid = -1; - if (iaxs[callno]->autoid > -1) - ast_sched_del(sched, iaxs[callno]->autoid); - iaxs[callno]->autoid = -1; - if (iaxs[callno]->initid > -1) - ast_sched_del(sched, iaxs[callno]->initid); - iaxs[callno]->initid = -1; - if (iaxs[callno]->authid > -1) - ast_sched_del(sched, iaxs[callno]->authid); - iaxs[callno]->authid = -1; -#ifdef NEWJB - if (iaxs[callno]->jbid > -1) - ast_sched_del(sched, iaxs[callno]->jbid); - iaxs[callno]->jbid = -1; -#endif - return 0; + iax2_destroy_helper(iaxs[callno]); } static void __auth_reject(void *nothing) @@ -6099,9 +6063,8 @@ { int callno = (int)(long)(data); ast_mutex_lock(&iaxsl[callno]); - if (iaxs[callno]) { + if (iaxs[callno]) iaxs[callno]->authid = -1; - } ast_mutex_unlock(&iaxsl[callno]); #ifdef SCHED_MULTITHREADED if (schedule_action(__auth_reject, data))