[asterisk-commits] kmoore: branch kmoore/stasis-presence_state r383599 - /team/kmoore/stasis-pre...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Mar 22 09:44:41 CDT 2013
Author: kmoore
Date: Fri Mar 22 09:44:38 2013
New Revision: 383599
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383599
Log:
Remove another serializer that is now useless
Modified:
team/kmoore/stasis-presence_state/main/presencestate.c
Modified: team/kmoore/stasis-presence_state/main/presencestate.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-presence_state/main/presencestate.c?view=diff&rev=383599&r1=383598&r2=383599
==============================================================================
--- team/kmoore/stasis-presence_state/main/presencestate.c (original)
+++ team/kmoore/stasis-presence_state/main/presencestate.c Fri Mar 22 09:44:38 2013
@@ -57,14 +57,6 @@
struct stasis_topic *presence_state_topic_all;
struct stasis_caching_topic *presence_state_topic_cached;
-/*! \brief Flag for the queue */
-static ast_cond_t change_pending;
-
-struct state_change {
- AST_LIST_ENTRY(state_change) list;
- char provider[1];
-};
-
/*! \brief A presence state provider */
struct presence_state_provider {
char label[40];
@@ -74,13 +66,6 @@
/*! \brief A list of providers */
static AST_RWLIST_HEAD_STATIC(presence_state_providers, presence_state_provider);
-
-/*! \brief The state change queue. State changes are queued
- for processing by a separate thread */
-static AST_LIST_HEAD_STATIC(state_changes, state_change);
-
-/*! \brief The presence state change notification thread */
-static pthread_t change_thread = AST_PTHREADT_NULL;
const char *ast_presence_state2str(enum ast_presence_state state)
{
@@ -280,19 +265,10 @@
const char *message,
const char *presence_provider)
{
- struct state_change *change;
-
- if (state != AST_PRESENCE_NOT_SET) {
- presence_state_event(presence_provider, state, subtype, message);
- } else if ((change_thread == AST_PTHREADT_NULL) ||
- !(change = ast_calloc(1, sizeof(*change) + strlen(presence_provider)))) {
+ if (state == AST_PRESENCE_NOT_SET) {
do_presence_state_change(presence_provider);
} else {
- strcpy(change->provider, presence_provider);
- AST_LIST_LOCK(&state_changes);
- AST_LIST_INSERT_TAIL(&state_changes, change, list);
- ast_cond_signal(&change_pending);
- AST_LIST_UNLOCK(&state_changes);
+ presence_state_event(presence_provider, state, subtype, message);
}
return 0;
@@ -311,31 +287,6 @@
va_end(ap);
return ast_presence_state_changed_literal(state, subtype, message, buf);
-}
-
-/*! \brief Go through the presence state change queue and update changes in the presence state thread */
-static void *do_presence_changes(void *data)
-{
- struct state_change *next, *current;
-
- for (;;) {
- /* This basically pops off any state change entries, resets the list back to NULL, unlocks, and processes each state change */
- AST_LIST_LOCK(&state_changes);
- if (AST_LIST_EMPTY(&state_changes))
- ast_cond_wait(&change_pending, &state_changes.lock);
- next = AST_LIST_FIRST(&state_changes);
- AST_LIST_HEAD_INIT_NOLOCK(&state_changes);
- AST_LIST_UNLOCK(&state_changes);
-
- /* Process each state change */
- while ((current = next)) {
- next = AST_LIST_NEXT(current, list);
- do_presence_state_change(current->provider);
- ast_free(current);
- }
- }
-
- return NULL;
}
struct stasis_message_type *stasis_presence_state_message(void)
@@ -392,12 +343,6 @@
}
ast_register_atexit(presence_state_engine_cleanup);
- ast_cond_init(&change_pending, NULL);
- if (ast_pthread_create_background(&change_thread, NULL, do_presence_changes, NULL) < 0) {
- ast_log(LOG_ERROR, "Unable to start presence state change thread.\n");
- return -1;
- }
-
return 0;
}
More information about the asterisk-commits
mailing list