[sr-dev] git:3.1: core: wrapper to pre-register new dummy timers

Daniel-Constantin Mierla miconda at gmail.com
Thu Apr 7 23:02:57 CEST 2011


Module: sip-router
Branch: 3.1
Commit: febb7de20cbcf94046f8e119664308ec596fa266
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=febb7de20cbcf94046f8e119664308ec596fa266

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Thu Apr  7 20:34:18 2011 +0200

core: wrapper to pre-register new dummy timers

- register_dummy_timers(no) adds the number of new processes in the
  process table and initializes as well the number of new childres
  to the cfg framework
- fork_dummy_timer() handles now the updates in cfg framework
(cherry picked from commit 421cba5d6b25d85d542b875633368e0bc98be07d)

---

 timer_proc.c |   15 +++++++++++++++
 timer_proc.h |    3 +++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/timer_proc.c b/timer_proc.c
index 09d19d3..a042008 100644
--- a/timer_proc.c
+++ b/timer_proc.c
@@ -36,12 +36,25 @@
  */
 
 #include "timer_proc.h"
+#include "cfg/cfg_struct.h"
 #include "pt.h"
 #include "mem/shm_mem.h"
 
 #include <unistd.h>
 
 
+/** update internal counters for running new dummy timers
+ *  @param timers - number of dummy timer processes
+ *  @return - 0 on success; -1 on error
+ */
+int register_dummy_timers(int timers)
+{
+	if(register_procs(timers)<0)
+		return -1;
+	cfg_register_child(timers);
+	return 0;
+}
+
 /** forks a separate simple sleep() periodic timer.
   * Forks a very basic periodic timer process, that just sleep()s for 
   * the specified interval and then calls the timer function.
@@ -66,8 +79,10 @@ int fork_dummy_timer(int child_id, char* desc, int make_sock,
 	if (pid<0) return -1;
 	if (pid==0){
 		/* child */
+		if (cfg_child_init()) return -1;
 		for(;;){
 			sleep(interval);
+			cfg_update();
 			f(get_ticks(), param); /* ticks in s for compatibility with old
 									  timers */
 		}
diff --git a/timer_proc.h b/timer_proc.h
index 81088d6..5e95400 100644
--- a/timer_proc.h
+++ b/timer_proc.h
@@ -36,6 +36,9 @@
 
 #include "local_timer.h"
 
+/** @brief register the number of extra dummy timer processes */
+int register_dummy_timers(int timers);
+
 /** @brief forks a separate simple sleep() periodic timer */
 int fork_dummy_timer(int child_id, char* desc, int make_sock,
 						timer_function* f, void* param, int interval);




More information about the sr-dev mailing list