aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_iax2.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-12 18:55:18 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-12 18:55:18 +0000
commit79a53174fa3cedb772f29b6dc140afd44e216472 (patch)
tree12a3b2046dc886de029796f555de2321be20814b /channels/chan_iax2.c
parent185eb10047829c248db066e315b9ee69938d9745 (diff)
Merged revisions 156229 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r156229 | tilghman | 2008-11-12 12:39:21 -0600 (Wed, 12 Nov 2008) | 11 lines Revert revision 132506, since it occasionally caused IAX2 HANGUP packets not to be sent, and instead, schedule a task to destroy the iax2 pvt structure 10 seconds later. This allows the IAX2 HANGUP packet to be queued, transmitted, and ACKed before the pvt is destroyed. (closes issue #13645) Reported by: dzajro Patches: 20081111__bug13645__3.diff.txt uploaded by Corydon76 (license 14) Tested by: vazir Reviewed: http://reviewboard.digium.com/r/51/ ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@156243 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r--channels/chan_iax2.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index b89fa102a..b618d03c1 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -884,6 +884,7 @@ static AST_LIST_HEAD_STATIC(active_list, iax2_thread);
static AST_LIST_HEAD_STATIC(dynamic_list, iax2_thread);
static void *iax2_process_thread(void *data);
+static void iax2_destroy(int callno);
static void signal_condition(ast_mutex_t *lock, ast_cond_t *cond)
{
@@ -1535,6 +1536,20 @@ static void iax2_frame_free(struct iax_frame *fr)
iax_frame_free(fr);
}
+static int scheduled_destroy(const void *vid)
+{
+ short callno = PTR_TO_CALLNO(vid);
+ ast_mutex_lock(&iaxsl[callno]);
+ if (iaxs[callno]) {
+ if (option_debug) {
+ ast_log(LOG_DEBUG, "Really destroying %d now...\n", callno);
+ }
+ iax2_destroy(callno);
+ }
+ ast_mutex_unlock(&iaxsl[callno]);
+ return 0;
+}
+
static void pvt_destructor(void *obj)
{
struct chan_iax2_pvt *pvt = obj;
@@ -3883,14 +3898,18 @@ static int iax2_hangup(struct ast_channel *c)
{
unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
struct iax_ie_data ied;
+ int alreadygone;
memset(&ied, 0, sizeof(ied));
ast_mutex_lock(&iaxsl[callno]);
if (callno && iaxs[callno]) {
ast_debug(1, "We're hanging up %s now...\n", c->name);
+ alreadygone = ast_test_flag(iaxs[callno], IAX_ALREADYGONE);
/* Send the hangup unless we have had a transmission error or are already gone */
iax_ie_append_byte(&ied, IAX_IE_CAUSECODE, (unsigned char)c->hangupcause);
- if (!iaxs[callno]->error && !ast_test_flag(iaxs[callno], IAX_ALREADYGONE)) {
- send_command_final(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_HANGUP, 0, ied.buf, ied.pos, -1);
+ if (!iaxs[callno]->error && !alreadygone) {
+ if (send_command_final(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_HANGUP, 0, ied.buf, ied.pos, -1)) {
+ ast_log(LOG_WARNING, "No final packet could be sent for callno %d\n", callno);
+ }
if (!iaxs[callno]) {
ast_mutex_unlock(&iaxsl[callno]);
return 0;
@@ -3899,9 +3918,14 @@ static int iax2_hangup(struct ast_channel *c)
/* Explicitly predestroy it */
iax2_predestroy(callno);
/* If we were already gone to begin with, destroy us now */
- if (iaxs[callno]) {
+ if (iaxs[callno] && alreadygone) {
ast_debug(1, "Really destroying %s now...\n", c->name);
iax2_destroy(callno);
+ } else if (iaxs[callno]) {
+ if (ast_sched_add(sched, 10000, scheduled_destroy, CALLNO_TO_PTR(callno)) < 0) {
+ ast_log(LOG_ERROR, "Unable to schedule iax2 callno %d destruction?!! Destroying immediately.\n", callno);
+ iax2_destroy(callno);
+ }
}
} else if (c->tech_pvt) {
/* If this call no longer exists, but the channel still