[asterisk-commits] mnicholson: branch 1.8 r299353 - in /branches/1.8: ./ channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 21 15:25:13 UTC 2010


Author: mnicholson
Date: Tue Dec 21 09:25:03 2010
New Revision: 299353

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=299353
Log:
Merged revisions 299242 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

................
  r299242 | mnicholson | 2010-12-20 15:25:35 -0600 (Mon, 20 Dec 2010) | 23 lines
  
  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
  ........
................

Modified:
    branches/1.8/   (props changed)
    branches/1.8/channels/chan_sip.c

Propchange: branches/1.8/
------------------------------------------------------------------------------
Binary property 'branch-1.6.2-merged' - no diff available.

Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=299353&r1=299352&r2=299353
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Tue Dec 21 09:25:03 2010
@@ -20099,7 +20099,7 @@
 	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);
@@ -20108,7 +20108,7 @@
 		ast_log(LOG_WARNING, "Masquerade failed.\n");
 		transmit_response(transferer->tech_pvt, "503 Internal error", &req);
 		deinit_req(&d->req);
-		free(d);
+		ast_free(d);
 		return NULL;
 	}
 
@@ -20127,7 +20127,6 @@
 
 	/* 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);
@@ -20142,7 +20141,7 @@
 		/* Do not hangup call */
 	}
 	deinit_req(&d->req);
-	free(d);
+	ast_free(d);
 	return NULL;
 }
 
@@ -20223,23 +20222,24 @@
 		}
 		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;
-		d->parkexten = parkexten;
-		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;
+	d->parkexten = parkexten;
+	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
@@ -21759,7 +21759,6 @@
 		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);
@@ -21774,7 +21773,6 @@
 	}
 
 	/* 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");
@@ -22148,6 +22146,9 @@
 
 	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, &current, req, seqno, nounlock)))
@@ -22185,13 +22186,13 @@
 			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, p->refer->refer_to);
+		if (sip_park(current.chan2, current.chan1, req, seqno, p->refer->refer_to)) {
+			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);




More information about the asterisk-commits mailing list