[asterisk-commits] mmichelson: branch group/CCSS r219891 - /team/group/CCSS/main/ccss.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 22 18:44:14 CDT 2009
Author: mmichelson
Date: Tue Sep 22 18:44:10 2009
New Revision: 219891
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=219891
Log:
Move devstate processing to the taskprocessor thread.
Tests well!
Modified:
team/group/CCSS/main/ccss.c
Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=219891&r1=219890&r2=219891
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Tue Sep 22 18:44:10 2009
@@ -1526,6 +1526,31 @@
return 0;
}
+struct generic_tp_cb_data {
+ struct ast_cc_monitor *monitor;
+ enum ast_device_state new_state;
+};
+
+static int generic_monitor_devstate_tp_cb(void *data)
+{
+ struct generic_tp_cb_data *gtcd = data;
+ struct ast_cc_monitor *monitor = gtcd->monitor;
+ enum ast_device_state new_state = gtcd->new_state;
+ struct generic_monitor_pvt *gen_mon_pvt = monitor->private_data;
+
+ if (gen_mon_pvt->current_state == new_state) {
+ return 0;
+ }
+
+ gen_mon_pvt->current_state = new_state;
+
+ if (new_state == AST_DEVICE_NOT_INUSE) {
+ ast_cc_monitor_announce_availability(monitor);
+ }
+ ast_free(gtcd);
+ return 0;
+}
+
static void generic_monitor_devstate_cb(const struct ast_event *event, void *userdata)
{
/* Wow, it's cool that we've picked up on a state change, but we really want
@@ -1534,20 +1559,16 @@
* no steenkin' locks!
*/
struct ast_cc_monitor *monitor = userdata;
- struct generic_monitor_pvt *gen_mon_pvt = monitor->private_data;
- enum ast_device_state new_state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
-
- /* XXX Move this to core taskprocessor thread.
- */
- if (gen_mon_pvt->current_state == new_state) {
+ struct generic_tp_cb_data *gtcd = ast_calloc(1, sizeof(*gtcd));
+
+ if (!gtcd) {
return;
}
- gen_mon_pvt->current_state = new_state;
-
- if (new_state == AST_DEVICE_NOT_INUSE) {
- ast_cc_monitor_announce_availability(monitor);
- }
+ gtcd->monitor = monitor;
+ gtcd->new_state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
+
+ ast_taskprocessor_push(cc_core_taskprocessor, generic_monitor_devstate_tp_cb, gtcd);
return;
}
More information about the asterisk-commits
mailing list