Review Board 1.7.16


Fix directed group pickup feature code *8 with pickupsounds enabled , deadlock and segfault, affects 1.8.0 and trunk

Review Request #1185 - Created April 17, 2011 and submitted

Alec Davis
trunk
18654
Reviewers
asterisk-dev
rmudgett
Asterisk
Since 1.8, the new pickupsound and pickupfailsound in features.conf cause many issues.

1). chan_sip:handle_request_invite() shouldn't be playing out the fail/success audio, as it has 'netlock' locked.
2). dialplan applications for directed_pickups shouldn't beep.
3). feature code for directed pickup should beep on success/failure if configured.

Moved app_directed:pickup_do() to features:ast_do_pickup().

Functions below, all now use the new ast_do_pickup()
app_directed_pickup.c:
   pickup_by_channel()
   pickup_by_exten()
   pickup_by_mark()
   pickup_by_part()
features.c:
   ast_pickup_call()

Created a sip_pickup() thread to handle the pickup and playout the audio, spawned from handle_request_invite.
pickup using *8 feature code, with pickup sounds enabled/disabled

exten => 71,1,Pickup()           ; any ringing extension in same pickupgroup 
exten => 72,1,Pickup(85@phones)  ; dahdi extension
exten => 73,1,Pickup(823@phones) ; sip extension

Changes between revision 1 and 2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

  1. trunk/main/features.c: Loading...
trunk/main/features.c
Diff Revision 1 Diff Revision 2
[20] 5688 lines
[+20] [+] static int find_channel_by_group(void *obj, void *arg, void *data, int flags)
5689

    
   
5689

   
5690
	return i ? CMP_MATCH | CMP_STOP : 0;
5690
	return i ? CMP_MATCH | CMP_STOP : 0;
5691
}
5691
}
5692

    
   
5692

   
5693
/*!
5693
/*!
Moved from 5748

    
   
5694
 * \brief Pickup a call
Moved from 5749

    
   
5695
 * \param chan channel that initiated pickup.
Moved from 5750

    
   
5696
 *
Moved from 5751

    
   
5697
 * Walk list of channels, checking it is not itself, channel is pbx one,
Moved from 5752

    
   
5698
 * check that the callgroup for both channels are the same and the channel is ringing.
Moved from 5753

    
   
5699
 * Answer calling channel, flag channel as answered on queue, masq channels together.
Moved from 5754

    
   
5700
*/
Moved from 5755

    
   
5701
int ast_pickup_call(struct ast_channel *chan)
Moved from 5756

    
   
5702
{
Moved from 5757

    
   
5703
	struct ast_channel *target = NULL;
Moved from 5758

    
   
5704
	int res;

    
   
5705

   
Moved from 5760

    
   
5706
	if (!(target = ast_channel_callback(find_channel_by_group, NULL, chan, 0))) {
Moved from 5761

    
   
5707
		ast_debug(1, "No call pickup possible...\n");
Moved from 5762

    
   
5708
		if (!ast_strlen_zero(pickupfailsound)) {
Moved from 5763

    
   
5709
			ast_stream_and_wait(chan, pickupfailsound, "");
Moved from 5764

    
   
5710
		}
Moved from 5765

    
   
5711
		return -1;
Moved from 5766

    
   
5712
	}

    
   
5713

   
Moved from 5768

    
   
5714
	if (target) {
Moved from 5769

    
   
5715
		ast_channel_lock(target);
Moved from 5770

    
   
5716
		res = ast_do_pickup(chan, target);
Moved from 5771

    
   
5717
		if (!ast_strlen_zero(pickupsound)) {
Moved from 5772

    
   
5718
			ast_stream_and_wait(target, pickupsound, "");
Moved from 5773

    
   
5719
		}
Moved from 5774

    
   
5720
		ast_channel_unlock(target);
Moved from 5775

    
   
5721
		target = ast_channel_unref(target);
Moved from 5776

    
   
5722
	}
Moved from 5777

    
   
5723
	return res;
Moved from 5778

    
   
5724
}

    
   
5725

   

    
   
5726
/*!
5694
 * \brief Pickup a call target, Common Code.
5727
 * \brief Pickup a call target, Common Code.
5695
 * \param chan channel that initiated pickup.
5728
 * \param chan channel that initiated pickup.
5696
 * \param target channel.
5729
 * \param target channel.
5697
 *
5730
 *
5698
 * Answer calling channel, flag channel as answered on queue, masq channels together.
5731
 * Answer calling channel, flag channel as answered on queue, masq channels together.
[+20] [20] 43 lines
[+20] [+] int ast_do_pickup(struct ast_channel *chan, struct ast_channel *target)
5742
		"Channel: %s\r\nTargetChannel: %s\r\n", chan->name, target->name);
5775
		"Channel: %s\r\nTargetChannel: %s\r\n", chan->name, target->name);
5743

    
   
5776

   
5744
	return res;
5777
	return res;
5745
}
5778
}
5746

    
   
5779

   
5747
/*!

   
5748
 * \brief Pickup a call
Moved to 5694

   
5749
 * \param chan channel that initiated pickup.
Moved to 5695

   
5750
 *
Moved to 5696

   
5751
 * Walk list of channels, checking it is not itself, channel is pbx one,
Moved to 5697

   
5752
 * check that the callgroup for both channels are the same and the channel is ringing.
Moved to 5698

   
5753
 * Answer calling channel, flag channel as answered on queue, masq channels together.
Moved to 5699

   
5754
*/
Moved to 5700

   
5755
int ast_pickup_call(struct ast_channel *chan)
Moved to 5701

   
5756
{
Moved to 5702

   
5757
	struct ast_channel *target = NULL;
Moved to 5703

   
5758
	int res;
Moved to 5704

   
5759

    
   

   
5760
	if (!(target = ast_channel_callback(find_channel_by_group, NULL, chan, 0))) {
Moved to 5706

   
5761
		ast_debug(1, "No call pickup possible...\n");
Moved to 5707

   
5762
		if (!ast_strlen_zero(pickupfailsound)) {
Moved to 5708

   
5763
			ast_stream_and_wait(chan, pickupfailsound, "");
Moved to 5709

   
5764
		}
Moved to 5710

   
5765
		return -1;
Moved to 5711

   
5766
	}
Moved to 5712

   
5767

    
   

   
5768
	if (target) {
Moved to 5714

   
5769
		ast_channel_lock(target);
Moved to 5715

   
5770
		res = ast_do_pickup(chan, target);
Moved to 5716

   
5771
		if (!ast_strlen_zero(pickupsound)) {
Moved to 5717

   
5772
			ast_stream_and_wait(target, pickupsound, "");
Moved to 5718

   
5773
		}
Moved to 5719

   
5774
		ast_channel_unlock(target);
Moved to 5720

   
5775
		target = ast_channel_unref(target);
Moved to 5721

   
5776
	}
Moved to 5722

   
5777
	return res;
Moved to 5723

   
5778
}
Moved to 5724

   
5779

    
   

   
5780
static char *app_bridge = "Bridge";
5780
static char *app_bridge = "Bridge";
5781

    
   
5781

   
5782
enum {
5782
enum {
5783
	BRIDGE_OPT_PLAYTONE = (1 << 0),
5783
	BRIDGE_OPT_PLAYTONE = (1 << 0),
5784
	OPT_CALLEE_HANGUP =	(1 << 1),
5784
	OPT_CALLEE_HANGUP =	(1 << 1),
[+20] [20] 337 lines
  1. trunk/main/features.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.