diff options
author | mnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-12-20 21:25:35 +0000 |
---|---|---|
committer | mnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-12-20 21:25:35 +0000 |
commit | 31579a66e4becde6cd2e8710e9a55967e7455631 (patch) | |
tree | 9b983c62676dcbcadb0aa11c40b9afb2969e2ad0 /channels | |
parent | d02bc67d22990eafa04f360a33ce22b27cc41cad (diff) |
Merged revisions 299194,299198,299220 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r299194 | mnicholson | 2010-12-20 14:45:38 -0600 (Mon, 20 Dec 2010) | 6 lines
Respond as soon as possible with a 202 Accepted to refer requests.
This change also plugs a few memory leaks that can occur when parking sip calls.
ABE-2656
........
r299198 | mnicholson | 2010-12-20 15:00:44 -0600 (Mon, 20 Dec 2010) | 2 lines
Remove changes to via processing that were not supposed to go into the last commit.
........
r299220 | mnicholson | 2010-12-20 15:21:39 -0600 (Mon, 20 Dec 2010) | 4 lines
Use ast_free() instead of free()
ABE-2656
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@299242 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_sip.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 9a6b9300c..880443c0d 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -18976,7 +18976,7 @@ static void *sip_park_thread(void *stuff) if (!transferee || !transferer) { ast_log(LOG_ERROR, "Missing channels for parking! Transferer %s Transferee %s\n", transferer ? "<available>" : "<missing>", transferee ? "<available>" : "<missing>" ); deinit_req(&d->req); - free(d); + ast_free(d); return NULL; } ast_debug(4, "SIP Park: Transferer channel %s, Transferee %s\n", transferer->name, transferee->name); @@ -18987,7 +18987,7 @@ static void *sip_park_thread(void *stuff) transmit_response(transferer->tech_pvt, "503 Internal error", &req); ast_channel_unlock(transferee); deinit_req(&d->req); - free(d); + ast_free(d); return NULL; } ast_channel_unlock(transferee); @@ -19007,7 +19007,6 @@ static void *sip_park_thread(void *stuff) /* Any way back to the current call??? */ /* Transmit response to the REFER request */ - transmit_response(transferer->tech_pvt, "202 Accepted", &req); if (!res) { /* Transfer succeeded */ append_history(transferer->tech_pvt, "SIPpark", "Parked call on %d", ext); @@ -19022,7 +19021,7 @@ static void *sip_park_thread(void *stuff) /* Do not hangup call */ } deinit_req(&d->req); - free(d); + ast_free(d); return NULL; } @@ -19106,22 +19105,23 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct } return -1; } - if ((d = ast_calloc(1, sizeof(*d)))) { - - /* Save original request for followup */ - copy_request(&d->req, req); - d->chan1 = transferee; /* Transferee */ - d->chan2 = transferer; /* Transferer */ - d->seqno = seqno; - if (ast_pthread_create_detached_background(&th, NULL, sip_park_thread, d) < 0) { - /* Could not start thread */ - deinit_req(&d->req); - ast_free(d); /* We don't need it anymore. If thread is created, d will be free'd - by sip_park_thread() */ - return 0; - } - } - return -1; + if (!(d = ast_calloc(1, sizeof(*d)))) { + return -1; + } + + /* Save original request for followup */ + copy_request(&d->req, req); + d->chan1 = transferee; /* Transferee */ + d->chan2 = transferer; /* Transferer */ + d->seqno = seqno; + if (ast_pthread_create_detached_background(&th, NULL, sip_park_thread, d) < 0) { + /* Could not start thread */ + deinit_req(&d->req); + ast_free(d); /* We don't need it anymore. If thread is created, d will be free'd + by sip_park_thread() */ + return -1; + } + return 0; } /*! \brief Turn off generator data @@ -20669,7 +20669,6 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual * transferer->refer->replaces_callid_fromtag))) { if (transferer->refer->localtransfer) { /* We did not find the refered call. Sorry, can't accept then */ - transmit_response(transferer, "202 Accepted", req); /* Let's fake a response from someone else in order to follow the standard */ transmit_notify_with_sipfrag(transferer, seqno, "481 Call leg/transaction does not exist", TRUE); @@ -20684,7 +20683,6 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual * } /* Ok, we can accept this transfer */ - transmit_response(transferer, "202 Accepted", req); append_history(transferer, "Xfer", "Refer accepted"); if (!targetcall_pvt->owner) { /* No active channel */ ast_debug(4, "SIP attended transfer: Error: No owner of target call\n"); @@ -20976,6 +20974,9 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int ast_set_flag(&p->flags[0], SIP_GOTREFER); + /* From here on failures will be indicated with NOTIFY requests */ + transmit_response(p, "202 Accepted", req); + /* Attended transfer: Find all call legs and bridge transferee with target*/ if (p->refer->attendedtransfer) { if ((res = local_attended_transfer(p, ¤t, req, seqno))) @@ -21005,13 +21006,13 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int p->refer->refer_to); if (sipdebug) ast_debug(4, "SIP transfer to parking: trying to park %s. Parked by %s\n", current.chan2->name, current.chan1->name); - sip_park(current.chan2, current.chan1, req, seqno); + if ((res = sip_park(current.chan2, current.chan1, req, seqno))) { + transmit_notify_with_sipfrag(p, seqno, "500 Internal Server Error", TRUE); + } return res; } /* Blind transfers and remote attended xfers */ - transmit_response(p, "202 Accepted", req); - if (current.chan1 && current.chan2) { ast_debug(3, "chan1->name: %s\n", current.chan1->name); pbx_builtin_setvar_helper(current.chan1, "BLINDTRANSFER", current.chan2->name); |