Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,131 +0,0 @@
1
-/*
2
- * Copyright (C) 2009 iptelorg GmbH
3
- *
4
- * Permission to use, copy, modify, and distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
7
- *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
- */
16
-
17
-/**
18
- * @file
19
- * @brief Kamailio core :: timer_proc.h - separate process timers
20
- *
21
- * (unrelated to the main fast and slow timers)
22
- * @ingroup core
23
- * Module: @ref core
24
- */
25
-
26
-#ifndef __timer_proc_h
27
-#define __timer_proc_h
28
-
29
-#include "local_timer.h"
30
-
31
-/**
32
- * \brief update internal counters for running new basic sec. timers
33
- * @param timers number of basic timer processes
34
- * @return 0 on success; -1 on error
35
- */
36
-int register_basic_timers(int timers);
37
-
38
-#define register_dummy_timers register_basic_timers
39
-
40
-#define register_basic_utimers register_basic_utimers
41
-
42
-/**
43
- * \brief Forks a separate simple sleep() periodic timer
44
- *
45
- * Forks a very basic periodic timer process, that just sleep()s for
46
- * the specified interval and then calls the timer function.
47
- * The new "basic timer" process execution start immediately, the sleep()
48
- * is called first (so the first call to the timer function will happen
49
- * \<interval\> seconds after the call to fork_basic_timer)
50
- * @param child_id  @see fork_process()
51
- * @param desc      @see fork_process()
52
- * @param make_sock @see fork_process()
53
- * @param f         timer function/callback
54
- * @param param     parameter passed to the timer function
55
- * @param interval  interval in seconds.
56
- * @return pid of the new process on success, -1 on error
57
- * (doesn't return anything in the child process)
58
- */
59
-int fork_basic_timer(int child_id, char* desc, int make_sock,
60
-						timer_function* f, void* param, int interval);
61
-
62
-#define fork_dummy_timer fork_basic_timer
63
-
64
-/**
65
- * \brief Forks a separate simple milisecond-sleep() periodic timer
66
- *
67
- * Forks a very basic periodic timer process, that just ms-sleep()s for
68
- * the specified interval and then calls the timer function.
69
- * The new "basic timer" process execution start immediately, the ms-sleep()
70
- * is called first (so the first call to the timer function will happen
71
- * \<interval\> seconds after the call to fork_basic_utimer)
72
- * @param child_id  @see fork_process()
73
- * @param desc      @see fork_process()
74
- * @param make_sock @see fork_process()
75
- * @param f         timer function/callback
76
- * @param param     parameter passed to the timer function
77
- * @param uinterval  interval in mili-seconds.
78
- * @return pid of the new process on success, -1 on error
79
- * (doesn't return anything in the child process)
80
- */
81
-int fork_basic_utimer(int child_id, char* desc, int make_sock,
82
-						timer_function* f, void* param, int uinterval);
83
-/**
84
- * \brief Forks a timer process based on the local timer
85
- *
86
- * Forks a separate timer process running a local_timer.h type of timer
87
- * A pointer to the local_timer handle (allocated in shared memory) is
88
- * returned in lt_h. It can be used to add/delete more timers at runtime
89
- * (via local_timer_add()/local_timer_del() a.s.o).
90
- * If timers are added from separate processes, some form of locking must be
91
- * used (all the calls to local_timer* must be enclosed by locks if it
92
- * cannot be guaranteed that they cannot execute in the same time)
93
- * The timer "engine" must be run manually from the child process. For
94
- * example a very simple local timer process that just runs a single
95
- * periodic timer can be started in the following way:
96
- * struct local_timer* lt_h;
97
- *
98
- * pid=fork_local_timer_process(...., &lt_h);
99
- * if (pid==0){
100
- *          timer_init(&my_timer, my_timer_f, 0, 0);
101
- *          local_timer_add(&lt_h, &my_timer, S_TO_TICKS(10), get_ticks_raw());
102
- *          while(1) { sleep(1); local_timer_run(lt, get_ticks_raw()); }
103
- * }
104
- *
105
- * @param child_id  @see fork_process()
106
- * @param desc      @see fork_process()
107
- * @param make_sock @see fork_process()
108
- * @param lt_h      local_timer handler
109
- * @return pid to the parent, 0 to the child, -1 if error.
110
- */
111
-int fork_local_timer_process(int child_id, char* desc, int make_sock,
112
-						struct local_timer** lt_h);
113
-
114
-/**
115
- * sync timers
116
- */
117
-int register_sync_timers(int timers);
118
-
119
-int fork_sync_timer(int child_id, char* desc, int make_sock,
120
-						timer_function* f, void* param, int interval);
121
-
122
-int fork_sync_utimer(int child_id, char* desc, int make_sock,
123
-						utimer_function* f, void* param, int uinterval);
124
-
125
-int sr_wtimer_init(void);
126
-int sr_wtimer_add(timer_function* f, void* param, int interval);
127
-int sr_wtimer_start(void);
128
-
129
-#endif /*__timer_proc_h*/
130
-
131
-/* vi: set ts=4 sw=4 tw=79:ai:cindent: */
Browse code

core: timer - coherent indentation and whitespacing

Daniel-Constantin Mierla authored on 05/05/2016 06:28:19
Showing 1 changed files
... ...
@@ -1,4 +1,4 @@
1
-/* 
1
+/*
2 2
  * Copyright (C) 2009 iptelorg GmbH
3 3
  *
4 4
  * Permission to use, copy, modify, and distribute this software for any
... ...
@@ -41,8 +41,8 @@ int register_basic_timers(int timers);
41 41
 
42 42
 /**
43 43
  * \brief Forks a separate simple sleep() periodic timer
44
- * 
45
- * Forks a very basic periodic timer process, that just sleep()s for 
44
+ *
45
+ * Forks a very basic periodic timer process, that just sleep()s for
46 46
  * the specified interval and then calls the timer function.
47 47
  * The new "basic timer" process execution start immediately, the sleep()
48 48
  * is called first (so the first call to the timer function will happen
... ...
@@ -63,8 +63,8 @@ int fork_basic_timer(int child_id, char* desc, int make_sock,
63 63
 
64 64
 /**
65 65
  * \brief Forks a separate simple milisecond-sleep() periodic timer
66
- * 
67
- * Forks a very basic periodic timer process, that just ms-sleep()s for 
66
+ *
67
+ * Forks a very basic periodic timer process, that just ms-sleep()s for
68 68
  * the specified interval and then calls the timer function.
69 69
  * The new "basic timer" process execution start immediately, the ms-sleep()
70 70
  * is called first (so the first call to the timer function will happen
... ...
@@ -82,7 +82,7 @@ int fork_basic_utimer(int child_id, char* desc, int make_sock,
82 82
 						timer_function* f, void* param, int uinterval);
83 83
 /**
84 84
  * \brief Forks a timer process based on the local timer
85
- * 
85
+ *
86 86
  * Forks a separate timer process running a local_timer.h type of timer
87 87
  * A pointer to the local_timer handle (allocated in shared memory) is
88 88
  * returned in lt_h. It can be used to add/delete more timers at runtime
... ...
@@ -91,10 +91,10 @@ int fork_basic_utimer(int child_id, char* desc, int make_sock,
91 91
  * used (all the calls to local_timer* must be enclosed by locks if it
92 92
  * cannot be guaranteed that they cannot execute in the same time)
93 93
  * The timer "engine" must be run manually from the child process. For
94
- * example a very simple local timer process that just runs a single 
94
+ * example a very simple local timer process that just runs a single
95 95
  * periodic timer can be started in the following way:
96 96
  * struct local_timer* lt_h;
97
- * 
97
+ *
98 98
  * pid=fork_local_timer_process(...., &lt_h);
99 99
  * if (pid==0){
100 100
  *          timer_init(&my_timer, my_timer_f, 0, 0);
Browse code

core: wheel timer implementation

- to be shared by modules needing to execute timer tasks, don't want to
interfere with main core timers, but don't do lots of operations to
create own timer

Daniel-Constantin Mierla authored on 21/01/2016 13:17:37
Showing 1 changed files
... ...
@@ -122,6 +122,10 @@ int fork_sync_timer(int child_id, char* desc, int make_sock,
122 122
 int fork_sync_utimer(int child_id, char* desc, int make_sock,
123 123
 						utimer_function* f, void* param, int uinterval);
124 124
 
125
+int sr_wtimer_init(void);
126
+int sr_wtimer_add(timer_function* f, void* param, int interval);
127
+int sr_wtimer_start(void);
128
+
125 129
 #endif /*__timer_proc_h*/
126 130
 
127 131
 /* vi: set ts=4 sw=4 tw=79:ai:cindent: */
Browse code

core: Modify doxygen, remove history, remove SVN IDs, change "ser" and "sip-router" to "KAMAILIO"

Olle E. Johansson authored on 16/01/2015 16:38:46
Showing 1 changed files
... ...
@@ -14,15 +14,9 @@
14 14
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 15
  */
16 16
 
17
-/*
18
- * History:
19
- * --------
20
- *  2009-03-10  initial version (andrei)
21
-*/
22
-
23 17
 /**
24 18
  * @file
25
- * @brief SIP-router core :: timer_proc.h - separate process timers
19
+ * @brief Kamailio core :: timer_proc.h - separate process timers
26 20
  *
27 21
  * (unrelated to the main fast and slow timers)
28 22
  * @ingroup core
Browse code

core: added support for basic timer + interval sync

- new functions to start basic timers that will sync the interval after
executing the task. Useful if the task is taking long, the process
will skip the delay in the sleep value

Daniel-Constantin Mierla authored on 19/04/2012 08:52:02
Showing 1 changed files
... ...
@@ -117,6 +117,17 @@ int fork_basic_utimer(int child_id, char* desc, int make_sock,
117 117
 int fork_local_timer_process(int child_id, char* desc, int make_sock,
118 118
 						struct local_timer** lt_h);
119 119
 
120
+/**
121
+ * sync timers
122
+ */
123
+int register_sync_timers(int timers);
124
+
125
+int fork_sync_timer(int child_id, char* desc, int make_sock,
126
+						timer_function* f, void* param, int interval);
127
+
128
+int fork_sync_utimer(int child_id, char* desc, int make_sock,
129
+						utimer_function* f, void* param, int uinterval);
130
+
120 131
 #endif /*__timer_proc_h*/
121 132
 
122 133
 /* vi: set ts=4 sw=4 tw=79:ai:cindent: */
Browse code

core/timer: added support for basic mili-second timers

- renamed second-based timer functions from dummy to basic

Daniel-Constantin Mierla authored on 14/12/2011 22:18:36
Showing 1 changed files
... ...
@@ -35,21 +35,24 @@
35 35
 #include "local_timer.h"
36 36
 
37 37
 /**
38
- * \brief update internal counters for running new dummy timers
39
- * @param timers number of dummy timer processes
38
+ * \brief update internal counters for running new basic sec. timers
39
+ * @param timers number of basic timer processes
40 40
  * @return 0 on success; -1 on error
41 41
  */
42
-int register_dummy_timers(int timers);
42
+int register_basic_timers(int timers);
43 43
 
44
+#define register_dummy_timers register_basic_timers
45
+
46
+#define register_basic_utimers register_basic_utimers
44 47
 
45 48
 /**
46 49
  * \brief Forks a separate simple sleep() periodic timer
47 50
  * 
48 51
  * Forks a very basic periodic timer process, that just sleep()s for 
49 52
  * the specified interval and then calls the timer function.
50
- * The new "dummy timer" process execution start immediately, the sleep()
53
+ * The new "basic timer" process execution start immediately, the sleep()
51 54
  * is called first (so the first call to the timer function will happen
52
- * \<interval\> seconds after the call to fork_dummy_timer)
55
+ * \<interval\> seconds after the call to fork_basic_timer)
53 56
  * @param child_id  @see fork_process()
54 57
  * @param desc      @see fork_process()
55 58
  * @param make_sock @see fork_process()
... ...
@@ -59,10 +62,30 @@ int register_dummy_timers(int timers);
59 62
  * @return pid of the new process on success, -1 on error
60 63
  * (doesn't return anything in the child process)
61 64
  */
62
-int fork_dummy_timer(int child_id, char* desc, int make_sock,
65
+int fork_basic_timer(int child_id, char* desc, int make_sock,
63 66
 						timer_function* f, void* param, int interval);
64 67
 
68
+#define fork_dummy_timer fork_basic_timer
65 69
 
70
+/**
71
+ * \brief Forks a separate simple milisecond-sleep() periodic timer
72
+ * 
73
+ * Forks a very basic periodic timer process, that just ms-sleep()s for 
74
+ * the specified interval and then calls the timer function.
75
+ * The new "basic timer" process execution start immediately, the ms-sleep()
76
+ * is called first (so the first call to the timer function will happen
77
+ * \<interval\> seconds after the call to fork_basic_utimer)
78
+ * @param child_id  @see fork_process()
79
+ * @param desc      @see fork_process()
80
+ * @param make_sock @see fork_process()
81
+ * @param f         timer function/callback
82
+ * @param param     parameter passed to the timer function
83
+ * @param uinterval  interval in mili-seconds.
84
+ * @return pid of the new process on success, -1 on error
85
+ * (doesn't return anything in the child process)
86
+ */
87
+int fork_basic_utimer(int child_id, char* desc, int make_sock,
88
+						timer_function* f, void* param, int uinterval);
66 89
 /**
67 90
  * \brief Forks a timer process based on the local timer
68 91
  * 
Browse code

doxygen comment fixes (escapes, missing parameters, syntax errors) all over the place

Henning Westerholt authored on 22/07/2011 07:23:18
Showing 1 changed files
... ...
@@ -1,6 +1,4 @@
1 1
 /* 
2
- * $Id$
3
- * 
4 2
  * Copyright (C) 2009 iptelorg GmbH
5 3
  *
6 4
  * Permission to use, copy, modify, and distribute this software for any
... ...
@@ -36,14 +34,63 @@
36 34
 
37 35
 #include "local_timer.h"
38 36
 
39
-/** @brief register the number of extra dummy timer processes */
37
+/**
38
+ * \brief update internal counters for running new dummy timers
39
+ * @param timers number of dummy timer processes
40
+ * @return 0 on success; -1 on error
41
+ */
40 42
 int register_dummy_timers(int timers);
41 43
 
42
-/** @brief forks a separate simple sleep() periodic timer */
44
+
45
+/**
46
+ * \brief Forks a separate simple sleep() periodic timer
47
+ * 
48
+ * Forks a very basic periodic timer process, that just sleep()s for 
49
+ * the specified interval and then calls the timer function.
50
+ * The new "dummy timer" process execution start immediately, the sleep()
51
+ * is called first (so the first call to the timer function will happen
52
+ * \<interval\> seconds after the call to fork_dummy_timer)
53
+ * @param child_id  @see fork_process()
54
+ * @param desc      @see fork_process()
55
+ * @param make_sock @see fork_process()
56
+ * @param f         timer function/callback
57
+ * @param param     parameter passed to the timer function
58
+ * @param interval  interval in seconds.
59
+ * @return pid of the new process on success, -1 on error
60
+ * (doesn't return anything in the child process)
61
+ */
43 62
 int fork_dummy_timer(int child_id, char* desc, int make_sock,
44 63
 						timer_function* f, void* param, int interval);
45 64
 
46
-/** @briefforks a timer process based on the local timer */
65
+
66
+/**
67
+ * \brief Forks a timer process based on the local timer
68
+ * 
69
+ * Forks a separate timer process running a local_timer.h type of timer
70
+ * A pointer to the local_timer handle (allocated in shared memory) is
71
+ * returned in lt_h. It can be used to add/delete more timers at runtime
72
+ * (via local_timer_add()/local_timer_del() a.s.o).
73
+ * If timers are added from separate processes, some form of locking must be
74
+ * used (all the calls to local_timer* must be enclosed by locks if it
75
+ * cannot be guaranteed that they cannot execute in the same time)
76
+ * The timer "engine" must be run manually from the child process. For
77
+ * example a very simple local timer process that just runs a single 
78
+ * periodic timer can be started in the following way:
79
+ * struct local_timer* lt_h;
80
+ * 
81
+ * pid=fork_local_timer_process(...., &lt_h);
82
+ * if (pid==0){
83
+ *          timer_init(&my_timer, my_timer_f, 0, 0);
84
+ *          local_timer_add(&lt_h, &my_timer, S_TO_TICKS(10), get_ticks_raw());
85
+ *          while(1) { sleep(1); local_timer_run(lt, get_ticks_raw()); }
86
+ * }
87
+ *
88
+ * @param child_id  @see fork_process()
89
+ * @param desc      @see fork_process()
90
+ * @param make_sock @see fork_process()
91
+ * @param lt_h      local_timer handler
92
+ * @return pid to the parent, 0 to the child, -1 if error.
93
+ */
47 94
 int fork_local_timer_process(int child_id, char* desc, int make_sock,
48 95
 						struct local_timer** lt_h);
49 96
 
Browse code

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

Daniel-Constantin Mierla authored on 07/04/2011 18:34:18
Showing 1 changed files
... ...
@@ -36,6 +36,9 @@
36 36
 
37 37
 #include "local_timer.h"
38 38
 
39
+/** @brief register the number of extra dummy timer processes */
40
+int register_dummy_timers(int timers);
41
+
39 42
 /** @brief forks a separate simple sleep() periodic timer */
40 43
 int fork_dummy_timer(int child_id, char* desc, int make_sock,
41 44
 						timer_function* f, void* param, int interval);
Browse code

Doxygen updates on timer modules

- changing from \ and ! to javadoc format
- adding new doxygen file headers

oej authored on 22/10/2009 17:56:48
Showing 1 changed files
... ...
@@ -15,26 +15,32 @@
15 15
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 16
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 17
  */
18
-/*
19
- * timer_proc.h - separate process timers
20
- * (unrelated to the main fast and slow timers)
21
- */
18
+
22 19
 /*
23 20
  * History:
24 21
  * --------
25 22
  *  2009-03-10  initial version (andrei)
26 23
 */
27 24
 
25
+/**
26
+ * @file
27
+ * @brief SIP-router core :: timer_proc.h - separate process timers
28
+ *
29
+ * (unrelated to the main fast and slow timers)
30
+ * @ingroup core
31
+ * Module: @ref core
32
+ */
33
+
28 34
 #ifndef __timer_proc_h
29 35
 #define __timer_proc_h
30 36
 
31 37
 #include "local_timer.h"
32 38
 
33
-/* forks a separate simple sleep() periodic timer */
39
+/** @brief forks a separate simple sleep() periodic timer */
34 40
 int fork_dummy_timer(int child_id, char* desc, int make_sock,
35 41
 						timer_function* f, void* param, int interval);
36 42
 
37
-/* forks a timer process based on the local timer */
43
+/** @briefforks a timer process based on the local timer */
38 44
 int fork_local_timer_process(int child_id, char* desc, int make_sock,
39 45
 						struct local_timer** lt_h);
40 46
 
Browse code

timers: helpers for forking separate timer procs

Helper functions for forking simple separate timer processes:

fork_dummy_timer(...) - forks a process that will just sleep()
for the required interval and then will call the provided
timer function, all that in a loop.
Care must be taken to use it only when fork_process() is
allowed (e.g.: module child_init function, when
rank==PROC_MAIN; see doc/modules_init.txt for more details)
It can be used to replace kamailio register_timer_process()
(but note that it's not a "drop-in" replacement).

fork_local_timer_process() - forks a process, initializes a
local_timer for it, and returns the local_timer handler both
to the parent and to the child process, so both of them can
add/del timers (if appropriate locking is used).
Example usage:
struct local_timer* lt_h;

pid=fork_local_timer_process(...., &lt_h);
if (pid==0){
timer_init(&my_timer1, my_timer_f1, 0, 0);
...
local_timer_add(&lt_h, &my_timer, S_TO_TICKS(10), get_ticks_raw());
...
while(1) { sleep(1); local_timer_run(lt, get_ticks_raw()); }
}
(note that instead of sleep()-ing the process can do some useful work,
like polling some fds a.s.o.)

Andrei Pelinescu-Onciul authored on 10/03/2009 21:35:33
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,43 @@
1
+/* 
2
+ * $Id$
3
+ * 
4
+ * Copyright (C) 2009 iptelorg GmbH
5
+ *
6
+ * Permission to use, copy, modify, and distribute this software for any
7
+ * purpose with or without fee is hereby granted, provided that the above
8
+ * copyright notice and this permission notice appear in all copies.
9
+ *
10
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
+ */
18
+/*
19
+ * timer_proc.h - separate process timers
20
+ * (unrelated to the main fast and slow timers)
21
+ */
22
+/*
23
+ * History:
24
+ * --------
25
+ *  2009-03-10  initial version (andrei)
26
+*/
27
+
28
+#ifndef __timer_proc_h
29
+#define __timer_proc_h
30
+
31
+#include "local_timer.h"
32
+
33
+/* forks a separate simple sleep() periodic timer */
34
+int fork_dummy_timer(int child_id, char* desc, int make_sock,
35
+						timer_function* f, void* param, int interval);
36
+
37
+/* forks a timer process based on the local timer */
38
+int fork_local_timer_process(int child_id, char* desc, int make_sock,
39
+						struct local_timer** lt_h);
40
+
41
+#endif /*__timer_proc_h*/
42
+
43
+/* vi: set ts=4 sw=4 tw=79:ai:cindent: */