[svn-commits] nadi: branch group/trunk-cm-csel-hash r47966 - /team/group/trunk-cm-csel-hash...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Nov 23 07:47:48 MST 2006


Author: nadi
Date: Thu Nov 23 08:47:47 2006
New Revision: 47966

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47966
Log:
statemachine_get_state w/o locking

Modified:
    team/group/trunk-cm-csel-hash/res/res_statemachine.c

Modified: team/group/trunk-cm-csel-hash/res/res_statemachine.c
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/res/res_statemachine.c?view=diff&rev=47966&r1=47965&r2=47966
==============================================================================
--- team/group/trunk-cm-csel-hash/res/res_statemachine.c (original)
+++ team/group/trunk-cm-csel-hash/res/res_statemachine.c Thu Nov 23 08:47:47 2006
@@ -44,7 +44,7 @@
 struct statemachine {
 	ast_mutex_t                     lock;
 	void                            *p;
-	int                             state;
+	volatile int                    state;
 	struct statemachine_transition  *table;
 	int                             num_rows;
 	int                             (*send_event)(void *p, int event);
@@ -94,7 +94,6 @@
 		event_out = EVENT_DEFAULT,
 		err,
 		retval = -1,
-		state,
 		leave = 0;
 
 	LOCK(sm);
@@ -102,10 +101,9 @@
 	if (sm->log_event)
 		sm->log_event(sm->p, LOG_RECEIVE, sm->state, event);
 
-	state = sm->state;
 	for (; i < sm->num_rows; ++i) {
 		t = &sm->table[i];
-		if ((t->state == state || t->state == STATE_ANY) &&
+		if ((t->state == sm->state || t->state == STATE_ANY) &&
 			(t->event == event || t->event == EVENT_ANY)) {
 			if (t->handle) {
 				handle_retval = t->handle(sm->p, sm->state, event);
@@ -153,14 +151,9 @@
 
 int statemachine_get_state (struct statemachine *sm)
 {
-	int state;
+	return sm->state;
+}
 
-	LOCK(sm);
-	state = sm->state;
-	UNLOCK(sm);
-
-	return state;
-}
 void statemachine_set_state (struct statemachine *sm, int state)
 {
 	LOCK(sm);



More information about the svn-commits mailing list