Review Board 1.7.16


IAX2: Transfer Reject: Lock bridgecallno before touching it, refactor

Review Request #2613 - Created June 11, 2013 and submitted

Alec Davis
1.8 to trunk
Reviewers
asterisk-dev
mjordan
Asterisk
1). When touching the bridgecallno, we need to lock it.

2). Remove magic number '0' and replace with TRANSFER_NONE.

3). Exit early if no bridgecallno.

4). Reduce indentation.
Test calls to the queue app up the trunk, which inturn make a call back down same trunk.
These queue calls don't have have a bridgecallno.
Verified that 'unable to transfer' was still emiited.  

Diff revision 1 (Latest)

  1. branches/1.8/channels/chan_iax2.c: Loading...
branches/1.8/channels/chan_iax2.c
Revision 391332 New Change
[20] 11366 lines
[+20] [+] immediatedial:
11367
					iax_ie_append_byte(&ied0, IAX_IE_CAUSECODE, AST_CAUSE_FACILITY_NOT_SUBSCRIBED);
11367
					iax_ie_append_byte(&ied0, IAX_IE_CAUSECODE, AST_CAUSE_FACILITY_NOT_SUBSCRIBED);
11368
					send_command_final(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_REJECT, 0, ied0.buf, ied0.pos, -1);
11368
					send_command_final(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_REJECT, 0, ied0.buf, ied0.pos, -1);
11369
				}
11369
				}
11370
				break;
11370
				break;
11371
			case IAX_COMMAND_TXREJ:
11371
			case IAX_COMMAND_TXREJ:
11372
				iaxs[fr->callno]->transferring = 0;
11372
				if (iaxs[fr->callno]->bridgecallno) {

    
   
11373
					while (ast_mutex_trylock(&iaxsl[iaxs[fr->callno]->bridgecallno])) {

    
   
11374
						DEADLOCK_AVOIDANCE(&iaxsl[fr->callno]);

    
   
11375
					}

    
   
11376
					if (!iaxs[fr->callno]) {

    
   
11377
						break;

    
   
11378
					}

    
   
11379
				}

    
   
11380

   

    
   
11381
				iaxs[fr->callno]->transferring = TRANSFER_NONE;
11373
				ast_verb(3, "Channel '%s' unable to transfer\n", iaxs[fr->callno]->owner ? iaxs[fr->callno]->owner->name : "<Unknown>");
11382
				ast_verb(3, "Channel '%s' unable to transfer\n", iaxs[fr->callno]->owner ? iaxs[fr->callno]->owner->name : "<Unknown>");
11374
				memset(&iaxs[fr->callno]->transfer, 0, sizeof(iaxs[fr->callno]->transfer));
11383
				memset(&iaxs[fr->callno]->transfer, 0, sizeof(iaxs[fr->callno]->transfer));
11375
				if (iaxs[fr->callno]->bridgecallno) {
11384

   

    
   
11385
				if (!iaxs[fr->callno]->bridgecallno) {

    
   
11386
					break;

    
   
11387
				}

    
   
11388

   
11376
					if (iaxs[iaxs[fr->callno]->bridgecallno]->transferring) {
11389
				if (iaxs[iaxs[fr->callno]->bridgecallno]->transferring) {
11377
						iaxs[iaxs[fr->callno]->bridgecallno]->transferring = 0;
11390
					iaxs[iaxs[fr->callno]->bridgecallno]->transferring = TRANSFER_NONE;
11378
						send_command(iaxs[iaxs[fr->callno]->bridgecallno], AST_FRAME_IAX, IAX_COMMAND_TXREJ, 0, NULL, 0, -1);
11391
					send_command(iaxs[iaxs[fr->callno]->bridgecallno], AST_FRAME_IAX, IAX_COMMAND_TXREJ, 0, NULL, 0, -1);
11379
					}
11392
				}
11380
				}
11393
				ast_mutex_unlock(&iaxsl[iaxs[fr->callno]->bridgecallno]);
11381
				break;
11394
				break;
11382
			case IAX_COMMAND_TXREADY:
11395
			case IAX_COMMAND_TXREADY:
11383
				if (iaxs[fr->callno]->bridgecallno) {
11396
				if (iaxs[fr->callno]->bridgecallno) {
11384
					while (ast_mutex_trylock(&iaxsl[iaxs[fr->callno]->bridgecallno])) {
11397
					while (ast_mutex_trylock(&iaxsl[iaxs[fr->callno]->bridgecallno])) {
11385
						DEADLOCK_AVOIDANCE(&iaxsl[fr->callno]);
11398
						DEADLOCK_AVOIDANCE(&iaxsl[fr->callno]);
[+20] [20] 3504 lines
  1. branches/1.8/channels/chan_iax2.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.