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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 22 13:46:46 CDT 2009


Author: mmichelson
Date: Tue Sep 22 13:46:42 2009
New Revision: 219813

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=219813
Log:
Make available timer expiration run in proper thread.


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=219813&r1=219812&r2=219813
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Tue Sep 22 13:46:42 2009
@@ -806,6 +806,18 @@
 
 /*!
  * \since 1.6.4
+ * \brief Scheduler callback for available timer expiration
+ *
+ * When arming the available timer from within a device monitor, you MUST
+ * use this function as the callback for the scheduler.
+ *
+ * \param data The parent link of the monitor for which the available timer has been
+ * armed.
+ */
+int ast_cc_available_timer_expire(const void *data);
+
+/*!
+ * \since 1.6.4
  * \brief Initialize CCSS
  *
  * XXX This needs to be updated as more functionality is added.

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=219813&r1=219812&r2=219813
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Tue Sep 22 13:46:42 2009
@@ -1516,9 +1516,9 @@
 	return;
 }
 
-static int available_timer_expire(const void *data)
-{
-	struct ast_cc_monitor_link *link = (struct ast_cc_monitor_link *) data;
+static int internal_cc_available_timer_expire(void *data)
+{
+	struct ast_cc_monitor_link *link = data;
 	struct ast_cc_monitor *parent_monitor = link->parent;
 	struct ast_cc_monitor *child_monitor = link->child;
 	int core_id = link->core_id;
@@ -1527,7 +1527,6 @@
 	 * available timer expires doesn't mean we should give
 	 * up monitoring other devices.
 	 */
-	/* XXX WHOA THIS RUNS IN THE WRONG THREAD */
 	prune_links(child_monitor, core_id, link);
 	AST_LIST_REMOVE(&parent_monitor->child_links, link, next_child);
 	destroy_link(link);
@@ -1542,6 +1541,16 @@
 	}
 	return 0;
 }
+
+int ast_cc_available_timer_expire(const void *data)
+{
+	/* It is essential that the link-pruning and destruction process happens in
+	 * the core CC thread, so we need to hand this off to the taskprocessor
+	 */
+	ast_taskprocessor_push(cc_core_taskprocessor, internal_cc_available_timer_expire, (void *) data);
+	return 0;
+}
+
 
 static int cc_generic_monitor_request_cc(struct ast_cc_monitor *monitor, const int core_id, struct ast_cc_monitor_link *parent_link)
 {
@@ -1578,7 +1587,7 @@
 		ast_get_ccnr_available_timer(monitor->interface->config_params);
 
 	parent_link->child_avail_id = ast_sched_thread_add(cc_sched_thread, when * 1000,
-			available_timer_expire, parent_link);
+			ast_cc_available_timer_expire, parent_link);
 
 	if (!(gen_mon_pvt->sub = ast_event_subscribe(
 			AST_EVENT_DEVICE_STATE, generic_monitor_devstate_cb, "Requesting CC", monitor, 




More information about the asterisk-commits mailing list