[asterisk-commits] mmichelson: branch mmichelson/atxfer_features r392188 - /team/mmichelson/atxf...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 18 15:40:43 CDT 2013


Author: mmichelson
Date: Tue Jun 18 15:40:41 2013
New Revision: 392188

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392188
Log:
Use a queue for stimuli during an attended transfer.

There is also a change in bridging.c to fix a compilation error
that occurred during a merge.


Modified:
    team/mmichelson/atxfer_features/main/bridging.c
    team/mmichelson/atxfer_features/main/bridging_basic.c

Modified: team/mmichelson/atxfer_features/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/bridging.c?view=diff&rev=392188&r1=392187&r2=392188
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging.c (original)
+++ team/mmichelson/atxfer_features/main/bridging.c Tue Jun 18 15:40:41 2013
@@ -650,7 +650,7 @@
 		|| ast_bridge_channel_establish_roles(bridge_channel)) {
 		ast_debug(1, "Bridge %s: pushing %p(%s) into bridge failed\n",
 			bridge->uniqueid, bridge_channel, ast_channel_name(bridge_channel->chan));
-		bridge_features_remove(bridge_channel->features, AST_BRIDGE_HOOK_REMOVE_ON_PULL);
+		ast_bridge_features_remove(bridge_channel->features, AST_BRIDGE_HOOK_REMOVE_ON_PULL);
 		return -1;
 	}
 	bridge_channel->in_bridge = 1;

Modified: team/mmichelson/atxfer_features/main/bridging_basic.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/bridging_basic.c?view=diff&rev=392188&r1=392187&r2=392188
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging_basic.c (original)
+++ team/mmichelson/atxfer_features/main/bridging_basic.c Tue Jun 18 15:40:41 2013
@@ -449,6 +449,11 @@
 	STIMULUS_DTMF_ATXFER_SWAP,
 };
 
+struct stimulus_list {
+	enum attended_transfer_stimulus stimulus;
+	AST_LIST_ENTRY(stimulus_list) next;
+};
+
 struct attended_transfer_properties {
 	ast_mutex_t lock;
 	ast_cond_t cond;
@@ -458,7 +463,7 @@
 	struct ast_channel *transfer_target;
 	struct timeval start;
 	struct timeval timeout;
-	enum attended_transfer_stimulus stimulus;
+	AST_LIST_HEAD(,stimulus_list) stimulus_queue;
 	enum attended_transfer_state state;
 	int atxferdropcall;
 	int atxfercallbackretries;
@@ -476,9 +481,10 @@
 	return ast_bridge_move(props->target_bridge, props->transferee_bridge, props->transferer, NULL, 1);
 }
 
-static enum attended_transfer_state calling_target_next(struct attended_transfer_properties *props)
-{
-	switch (props->stimulus) {
+static enum attended_transfer_state calling_target_next(struct attended_transfer_properties *props,
+		enum attended_transfer_stimulus stimulus)
+{
+	switch (stimulus) {
 	default:
 	case STIMULUS_NONE:
 	case STIMULUS_TRANSFERER_ANSWER:
@@ -506,9 +512,10 @@
 	return ast_bridge_move(props->transferee_bridge, props->target_bridge, props->transferer, NULL, 1);
 }
 
-static enum attended_transfer_state hesitant_next(struct attended_transfer_properties *props)
-{
-	switch (props->stimulus) {
+static enum attended_transfer_state hesitant_next(struct attended_transfer_properties *props,
+		enum attended_transfer_stimulus stimulus)
+{
+	switch (stimulus) {
 	default:
 	case STIMULUS_NONE:
 	case STIMULUS_TRANSFERER_ANSWER:
@@ -563,9 +570,10 @@
 	return ast_bridge_move(props->target_bridge, props->transferee_bridge, props->transferer, NULL, 1);
 }
 
-static enum attended_transfer_state consulting_next(struct attended_transfer_properties *props)
-{
-	switch (props->stimulus) {
+static enum attended_transfer_state consulting_next(struct attended_transfer_properties *props,
+		enum attended_transfer_stimulus stimulus)
+{
+	switch (stimulus) {
 	default:
 	case STIMULUS_NONE:
 	case STIMULUS_TIMEOUT:
@@ -604,9 +612,10 @@
 	return ast_bridge_move(props->transferee_bridge, props->target_bridge, props->transferer, NULL, 1);
 }
 
-static enum attended_transfer_state double_checking_next(struct attended_transfer_properties *props)
-{
-	switch (props->stimulus) {
+static enum attended_transfer_state double_checking_next(struct attended_transfer_properties *props,
+		enum attended_transfer_stimulus stimulus)
+{
+	switch (stimulus) {
 	default:
 	case STIMULUS_NONE:
 	case STIMULUS_TIMEOUT:
@@ -642,9 +651,10 @@
 	return 0;
 }
 
-static enum attended_transfer_state blond_next(struct attended_transfer_properties *props)
-{
-	switch (props->stimulus) {
+static enum attended_transfer_state blond_next(struct attended_transfer_properties *props,
+		enum attended_transfer_stimulus stimulus)
+{
+	switch (stimulus) {
 	default:
 	case STIMULUS_NONE:
 	case STIMULUS_DTMF_ATXFER_ABORT:
@@ -678,9 +688,10 @@
 	return 0;
 }
 
-static enum attended_transfer_state recalling_next(struct attended_transfer_properties *props)
-{
-	switch (props->stimulus) {
+static enum attended_transfer_state recalling_next(struct attended_transfer_properties *props,
+		enum attended_transfer_stimulus stimulus)
+{
+	switch (stimulus) {
 	default:
 	case STIMULUS_NONE:
 	case STIMULUS_DTMF_ATXFER_ABORT:
@@ -716,7 +727,8 @@
 	return 0;
 }
 
-static enum attended_transfer_state retransfer_next(struct attended_transfer_properties *props)
+static enum attended_transfer_state retransfer_next(struct attended_transfer_properties *props,
+		enum attended_transfer_stimulus stimulus)
 {
 	return TRANSFER_BLOND;
 }
@@ -736,7 +748,8 @@
 static struct attended_transfer_state_properties {
 	const char *state_name;
 	int (*enter)(struct attended_transfer_properties *props);
-	enum attended_transfer_state (*next)(struct attended_transfer_properties *props);
+	enum attended_transfer_state (*next)(struct attended_transfer_properties *props,
+			enum attended_transfer_stimulus stimulus);
 	enum attended_transfer_state_flags flags;
 } state_properties [] = {
 	[TRANSFER_CALLING_TARGET] = {
@@ -806,11 +819,12 @@
 	},
 };
 
-static void wait_for_stimulus(struct attended_transfer_properties *props)
-{
+static enum attended_transfer_stimulus wait_for_stimulus(struct attended_transfer_properties *props)
+{
+	RAII_VAR(struct stimulus_list *, list, NULL, ast_free_ptr);
 	SCOPED_MUTEX(lock, &props->lock);
 
-	while (props->stimulus == STIMULUS_NONE) {
+	while (!(list = AST_LIST_REMOVE_HEAD(&props->stimulus_queue, next))) {
 		if (!(state_properties[props->state].flags & TRANSFER_STATE_IS_TIMED)) {
 			ast_cond_wait(&props->cond, lock);
 		} else {
@@ -825,10 +839,11 @@
 			timeout_arg.tv_nsec = timeout.tv_usec * 1000;
 
 			if (ast_cond_timedwait(&props->cond, lock, &timeout_arg) == ETIMEDOUT) {
-				props->stimulus = STIMULUS_TIMEOUT;
+				return STIMULUS_TIMEOUT;
 			}
 		}
 	}
+	return list->stimulus;
 }
 
 static __attribute__((unused)) void *attended_transfer_monitor_thread(void *data)
@@ -836,6 +851,8 @@
 	struct attended_transfer_properties *props = data;
 
 	for (;;) {
+		enum attended_transfer_stimulus stimulus;
+
 		if (state_properties[props->state].enter &&
 				state_properties[props->state].enter(props)) {
 			break;
@@ -845,11 +862,11 @@
 			break;
 		}
 
-		wait_for_stimulus(props);
+		stimulus = wait_for_stimulus(props);
 		
 		ast_assert(state_properties[props->state].next != NULL);
 
-		props->state = state_properties[props->state].next(props);
+		props->state = state_properties[props->state].next(props, stimulus);
 	}
 
 	return NULL;




More information about the asterisk-commits mailing list