Browse Source

cfg framework: timer must reset the handles more frequently

The timer processes must reset the cfg group handles after
each registered timer function is executed, otherwise cfg_select()
in one function may influence another function.
Miklos Tirpak 15 years ago
parent
commit
58829230ee
2 changed files with 14 additions and 0 deletions
  1. 10 0
      cfg/cfg_struct.h
  2. 4 0
      timer.c

+ 10 - 0
cfg/cfg_struct.h

@@ -421,6 +421,16 @@ static inline void cfg_reset_handles(void)
 			cfg_update_local(1); \
 			cfg_update_local(1); \
 	} while(0)
 	} while(0)
 
 
+/* Reset all the group handles in the child process,
+ * i.e. move them back to the default local configuration.
+ */
+#define cfg_reset_all() \
+	do { \
+		if (unlikely(cfg_ginst_count)) \
+			cfg_reset_handles(); \
+	} while(0)
+
+
 /* searches a group by name */
 /* searches a group by name */
 cfg_group_t *cfg_lookup_group(char *name, int len);
 cfg_group_t *cfg_lookup_group(char *name, int len);
 	
 	

+ 4 - 0
timer.c

@@ -892,6 +892,8 @@ inline static void timer_list_expire(ticks_t t, struct timer_head* h
 #endif
 #endif
 			UNLOCK_TIMER_LIST(); /* acts also as write barrier */ 
 			UNLOCK_TIMER_LIST(); /* acts also as write barrier */ 
 				ret=tl->f(t, tl, tl->data);
 				ret=tl->f(t, tl, tl->data);
+				/* reset the configuration group handles */
+				cfg_reset_all();
 				if (ret==0){
 				if (ret==0){
 					UNSET_RUNNING();
 					UNSET_RUNNING();
 					LOCK_TIMER_LIST();
 					LOCK_TIMER_LIST();
@@ -1147,6 +1149,8 @@ void slow_timer_main()
 				SET_RUNNING_SLOW(tl);
 				SET_RUNNING_SLOW(tl);
 				UNLOCK_SLOW_TIMER_LIST();
 				UNLOCK_SLOW_TIMER_LIST();
 					ret=tl->f(*ticks, tl, tl->data);
 					ret=tl->f(*ticks, tl, tl->data);
+					/* reset the configuration group handles */
+					cfg_reset_all();
 					if (ret==0){
 					if (ret==0){
 						/* one shot */
 						/* one shot */
 						UNSET_RUNNING_SLOW();
 						UNSET_RUNNING_SLOW();