[svn-commits] mmichelson: branch group/CCSS r226645 - in /team/group/CCSS: include/asterisk...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Oct 30 16:07:32 CDT 2009


Author: mmichelson
Date: Fri Oct 30 16:07:28 2009
New Revision: 226645

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=226645
Log:
Change the way in which a recall is handled.

Now, when a callee becomes available, the core does
not issue a status request. The reason for this is that
a status request is not always something that can be guaranteed
to return quickly. Instead, when the callee becomes available,
the core alerts the agent of such, and it is assumed that the
agent will notify the caller that he may attempt to recall. If
the agent is unable to reach the caller, or if the agent has
the ability to check beforehand that the caller is not going
to be available, it can then signal to the core that the caller
is unavailable and abort the recall attempt.

The other change is that the CC_RECALLING state is actually entered
now when the caller actually initiates the recall.


Modified:
    team/group/CCSS/include/asterisk/ccss.h
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/include/asterisk/ccss.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/include/asterisk/ccss.h?view=diff&rev=226645&r1=226644&r2=226645
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Fri Oct 30 16:07:28 2009
@@ -912,6 +912,24 @@
 
 /*!
  * \since 1.6.4
+ * \brief Indicate that the caller is busy
+ *
+ * When the callee makes it known that he is available, the core
+ * will let the caller's channel driver know that it may attempt
+ * to let the caller know to attempt a recall. If the channel
+ * driver can detect, though, that the caller is busy, then
+ * the channel driver should call this function to let the CC
+ * core know.
+ *
+ * \param core_id cor_id of the CC transaction
+ * \param debug optional string to print for debugging purposes
+ * \retval 0 Success
+ * \retval -1 Failure
+ */
+int ast_cc_caller_busy(int core_id, const char * const debug);
+
+/*!
+ * \since 1.6.4
  * \brief Indicate that a previously unavailable caller has become available
  *
  * If a monitor is suspended due to a caller becoming unavailable, then this
@@ -923,6 +941,21 @@
  * \retval -1 Failure
  */
 int ast_cc_caller_available(int core_id, const char * const debug);
+
+/*!
+ * \since 1.6.4
+ * \brief Tell the CC core that a caller is currently recalling
+ *
+ * The main purpose of this is so that the core can alert the monitor
+ * to stop its available timer since the caller has begun its recall
+ * phase.
+ *
+ * \param core_id core_id of the CC transaction
+ * \param debug optional string to print for debugging purposes
+ * \retval 0 Success
+ * \retval -1 Failure
+ */
+int ast_cc_recalling(int core_id, const char * const debug);
 
 /*!
  * \since 1.6.4

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=226645&r1=226644&r2=226645
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Fri Oct 30 16:07:28 2009
@@ -1976,6 +1976,7 @@
 	char *context;
 	char *exten;
 	const char *callback_macro = ast_get_cc_callback_macro(agent->cc_params);
+
 	tech = interface;
 	if ((target = strchr(interface, '/'))) {
 		*target++ = '\0';
@@ -2010,6 +2011,7 @@
 	ast_copy_string(chan->exten, exten, sizeof(chan->exten));
 	ast_copy_string(chan->context, context, sizeof(chan->context));
 	chan->priority = 1;
+	ast_cc_recalling(agent->core_id, "Generic agent is recalling");
 	ast_pbx_start(chan);
 	return NULL;
 }
@@ -2017,6 +2019,15 @@
 static int cc_generic_agent_recall(struct ast_cc_agent *agent)
 {
 	pthread_t clotho;
+	enum ast_device_state current_state = ast_device_state(agent->interface);
+
+	if (current_state != AST_DEVICE_NOT_INUSE && current_state != AST_DEVICE_UNKNOWN) {
+		/* We can't try to contact the device right now because he's not available
+		 * Let the core know he's busy.
+		 */
+		ast_cc_caller_busy(agent->core_id, "Generic agent caller is busy");
+		return 0;
+	}
 	ast_pthread_create_detached_background(&clotho, NULL, generic_recall, agent);
 	return 0;
 }
@@ -2454,13 +2465,7 @@
 
 static int cc_callee_ready(struct cc_core_instance *core_instance, struct cc_state_change_args *args, enum cc_state previous_state)
 {
-	if (core_instance->agent->callbacks->status_request(core_instance->agent) == AST_DEVICE_NOT_INUSE) {
-		ast_log_dynamic_level(cc_logger_level, "Both parties are ready. Attempting recall\n");
-		cc_request_state_change(CC_RECALLING, core_instance->core_id, "Both parties are available\n");
-	} else {
-		ast_log_dynamic_level(cc_logger_level, "Caller %s has become busy, begin monitoring\n", core_instance->agent->interface);
-		cc_request_state_change(CC_CALLER_BUSY, core_instance->core_id, "Caller is busy\n");
-	}
+	core_instance->agent->callbacks->recall(core_instance->agent);
 	return 0;
 }
 
@@ -2483,7 +2488,6 @@
 	/* Both caller and callee are available, call agent's recall callback
 	 */
 	core_instance->monitor->callbacks->cancel_available_timer(core_instance->monitor, core_instance->core_id, NULL);
-	core_instance->agent->callbacks->recall(core_instance->agent);
 	manager_event(EVENT_FLAG_CC, "CCCallerRecalling",
 		"CoreID: %d\r\n"
 		"Caller: %s\r\n",
@@ -2605,9 +2609,19 @@
 			cc_ref(monitor, "Bump reference count until cc_devstate_change executes"));
 }
 
+int ast_cc_caller_busy(int core_id, const char * debug)
+{
+	return cc_request_state_change(CC_CALLER_BUSY, core_id, debug);
+}
+
 int ast_cc_caller_available(int core_id, const char * const debug)
 {
 	return cc_request_state_change(CC_ACTIVE, core_id, debug);
+}
+
+int ast_cc_recalling(int core_id, const char * const debug)
+{
+	return cc_request_state_change(CC_RECALLING, core_id, debug);
 }
 
 int ast_cc_completed(int core_id, const char * const debug)




More information about the svn-commits mailing list