- 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)
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,96 +0,0 @@ |
1 |
-/* |
|
2 |
- * Process Table |
|
3 |
- * |
|
4 |
- * Copyright (C) 2001-2003 FhG Fokus |
|
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 |
-/** Kamailio core :: internal fork functions and process table. |
|
19 |
- * @file: pt.h |
|
20 |
- * @ingroup core |
|
21 |
- */ |
|
22 |
- |
|
23 |
-#ifndef _PT_H |
|
24 |
-#define _PT_H |
|
25 |
- |
|
26 |
-#include <sys/types.h> |
|
27 |
-#include <unistd.h> |
|
28 |
-#include <stdlib.h> |
|
29 |
- |
|
30 |
-#include "globals.h" |
|
31 |
-#include "timer.h" |
|
32 |
-#include "socket_info.h" |
|
33 |
-#include "locking.h" |
|
34 |
- |
|
35 |
-#define MAX_PT_DESC 128 |
|
36 |
- |
|
37 |
-struct process_table { |
|
38 |
- int pid; |
|
39 |
-#ifdef USE_TCP |
|
40 |
- int unix_sock; /* unix socket on which tcp main listens */ |
|
41 |
- int idx; /* tcp child index, -1 for other processes */ |
|
42 |
-#endif |
|
43 |
- char desc[MAX_PT_DESC]; |
|
44 |
-}; |
|
45 |
- |
|
46 |
-extern struct process_table *pt; |
|
47 |
-extern gen_lock_t* process_lock; |
|
48 |
-extern int *process_count; |
|
49 |
-extern int process_no; |
|
50 |
- |
|
51 |
-extern struct tcp_child* tcp_children; |
|
52 |
- |
|
53 |
-int init_pt(int proc_no); |
|
54 |
-int get_max_procs(void); |
|
55 |
-int register_procs(int no); |
|
56 |
-int get_max_open_fds(void); |
|
57 |
-int register_fds(int no); |
|
58 |
- |
|
59 |
- |
|
60 |
-int close_extra_socks(int proc_id, int proc_no); |
|
61 |
- |
|
62 |
-#define get_proc_no() ((process_count)?*process_count:0) |
|
63 |
- |
|
64 |
-/* return processes pid */ |
|
65 |
-int my_pid(void); |
|
66 |
- |
|
67 |
-/** |
|
68 |
- * Forks a new process. |
|
69 |
- * @param desc - text description for the process table |
|
70 |
- * @param make_sock - if to create a unix socket pair for it |
|
71 |
- * @returns the pid of the new process |
|
72 |
- */ |
|
73 |
-int fork_process(int child_id,char *desc,int make_sock); |
|
74 |
- |
|
75 |
-/** |
|
76 |
- * Forks a new TCP process. |
|
77 |
- * @param desc - text description for the process table |
|
78 |
- * @param r - index in the tcp_children array |
|
79 |
- * @param *reader_fd_1 - pointer to return the reader_fd[1] |
|
80 |
- * @returns the pid of the new process |
|
81 |
- */ |
|
82 |
-#ifdef USE_TCP |
|
83 |
-int fork_tcp_process(int child_id,char *desc,int r,int *reader_fd_1); |
|
84 |
-#endif |
|
85 |
- |
|
86 |
-#ifdef PKG_MALLOC |
|
87 |
-void mem_dump_pkg_cb(str *gname, str *name); |
|
88 |
-#endif |
|
89 |
- |
|
90 |
-#ifdef SHM_MEM |
|
91 |
-int mem_dump_shm_fixup(void *handle, str *gname, str *name, void **val); |
|
92 |
-#endif |
|
93 |
- |
|
94 |
-unsigned int set_fork_delay(unsigned int v); |
|
95 |
- |
|
96 |
-#endif |
... | ... |
@@ -1,10 +1,6 @@ |
1 | 1 |
/* |
2 |
- * $Id$ |
|
3 |
- * |
|
4 | 2 |
* Process Table |
5 | 3 |
* |
6 |
- * |
|
7 |
- * |
|
8 | 4 |
* Copyright (C) 2001-2003 FhG Fokus |
9 | 5 |
* |
10 | 6 |
* Permission to use, copy, modify, and distribute this software for any |
... | ... |
@@ -19,19 +15,11 @@ |
19 | 15 |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
20 | 16 |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
21 | 17 |
*/ |
22 |
-/* |
|
23 |
- * History: |
|
24 |
- * -------- |
|
25 |
- * 2003-04-15 added tcp_disable support (andrei) |
|
26 |
- * 2006-06-14 added process table in shared mem (dragos) |
|
27 |
- * 2007-07-04 added register_fds() and get_max_open_fds(() (andrei) |
|
28 |
- */ |
|
29 |
-/** internal fork functions and process table. |
|
18 |
+/** Kamailio core :: internal fork functions and process table. |
|
30 | 19 |
* @file: pt.h |
31 | 20 |
* @ingroup core |
32 | 21 |
*/ |
33 | 22 |
|
34 |
- |
|
35 | 23 |
#ifndef _PT_H |
36 | 24 |
#define _PT_H |
37 | 25 |
|
In C language, a declaration in the form int f(); is equivalent to int f(...);, thus being able to accept an indefinit number of parameters. With the -Wstrict-prototypes GCC options, these declarations are reported as "function declaration isn’t a prototype".
On some cases, this may trick the compiler into generating unoptimized code (like preparing to handle variadic argument list).
In all cases having a declaration int f() and a definition inf f(int) is missleading, even if standard compliant.
This is still Work in Progress. (maybe adding the -Wstrict-prototypes option to default is desireable)
... | ... |
@@ -63,9 +63,9 @@ extern int process_no; |
63 | 63 |
extern struct tcp_child* tcp_children; |
64 | 64 |
|
65 | 65 |
int init_pt(int proc_no); |
66 |
-int get_max_procs(); |
|
66 |
+int get_max_procs(void); |
|
67 | 67 |
int register_procs(int no); |
68 |
-int get_max_open_fds(); |
|
68 |
+int get_max_open_fds(void); |
|
69 | 69 |
int register_fds(int no); |
70 | 70 |
|
71 | 71 |
|
... | ... |
@@ -74,7 +74,7 @@ int close_extra_socks(int proc_id, int proc_no); |
74 | 74 |
#define get_proc_no() ((process_count)?*process_count:0) |
75 | 75 |
|
76 | 76 |
/* return processes pid */ |
77 |
-int my_pid(); |
|
77 |
+int my_pid(void); |
|
78 | 78 |
|
79 | 79 |
/** |
80 | 80 |
* Forks a new process. |
- number of usecs to wait before forking a process
- default is 0, don't wait
- useful in case there are some throttling policies for the system
running the sip server (e.g., number of new db connections per second)
-- you can introduce delays so that worker processes are not forked at
once
- moved most of the daemon status stuff to daemonize.[ch].
- nicer interface (e.g. daemon_status_send(code))
- send/read only 1 byte which will be used as exit code
- send an error status on error (fixes
"Main process exited before writing to pipe" error message)
- disabled the timeout. Not needed (now a status is sent always
and even an unlikely process crash before sending it is detected via
the read() failure) and very hard to find a good value (some
setups start very slow).
- close the pipe "send" fd in processes not needing it
- attempt to send back status only if dont_daemonize is not set
(not only if dont_fork==0, it is possible to have forking
enabled, but daemonize disabled: ser -DD)
- BSDed daemonize.[ch] and pt.[ch]
... | ... |
@@ -7,26 +7,17 @@ |
7 | 7 |
* |
8 | 8 |
* Copyright (C) 2001-2003 FhG Fokus |
9 | 9 |
* |
10 |
- * This file is part of ser, a free SIP server. |
|
10 |
+ * Permission to use, copy, modify, and distribute this software for any |
|
11 |
+ * purpose with or without fee is hereby granted, provided that the above |
|
12 |
+ * copyright notice and this permission notice appear in all copies. |
|
11 | 13 |
* |
12 |
- * ser is free software; you can redistribute it and/or modify |
|
13 |
- * it under the terms of the GNU General Public License as published by |
|
14 |
- * the Free Software Foundation; either version 2 of the License, or |
|
15 |
- * (at your option) any later version |
|
16 |
- * |
|
17 |
- * For a license to use the ser software under conditions |
|
18 |
- * other than those described here, or to purchase support for this |
|
19 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
20 |
- * info@iptel.org |
|
21 |
- * |
|
22 |
- * ser is distributed in the hope that it will be useful, |
|
23 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
24 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
25 |
- * GNU General Public License for more details. |
|
26 |
- * |
|
27 |
- * You should have received a copy of the GNU General Public License |
|
28 |
- * along with this program; if not, write to the Free Software |
|
29 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
14 |
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
15 |
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
16 |
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
17 |
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
18 |
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
19 |
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
20 |
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
30 | 21 |
*/ |
31 | 22 |
/* |
32 | 23 |
* History: |
... | ... |
@@ -35,6 +26,10 @@ |
35 | 26 |
* 2006-06-14 added process table in shared mem (dragos) |
36 | 27 |
* 2007-07-04 added register_fds() and get_max_open_fds(() (andrei) |
37 | 28 |
*/ |
29 |
+/** internal fork functions and process table. |
|
30 |
+ * @file: pt.h |
|
31 |
+ * @ingroup core |
|
32 |
+ */ |
|
38 | 33 |
|
39 | 34 |
|
40 | 35 |
#ifndef _PT_H |
... | ... |
@@ -101,11 +101,11 @@ int fork_tcp_process(int child_id,char *desc,int r,int *reader_fd_1); |
101 | 101 |
#endif |
102 | 102 |
|
103 | 103 |
#ifdef PKG_MALLOC |
104 |
-void mem_dump_pkg_cb(str *name); |
|
104 |
+void mem_dump_pkg_cb(str *gname, str *name); |
|
105 | 105 |
#endif |
106 | 106 |
|
107 | 107 |
#ifdef SHM_MEM |
108 |
-int mem_dump_shm_fixup(void *handle, str *name, void **val); |
|
108 |
+int mem_dump_shm_fixup(void *handle, str *gname, str *name, void **val); |
|
109 | 109 |
#endif |
110 | 110 |
|
111 | 111 |
#endif |
sercmd cfg.set_now_int mem_dump_pkg <pid_number>
Dumps the pkg memory status of the given processs
sercmd cfg.set_now_int mem_dump_shm 1
Dumps the shm memory status
... | ... |
@@ -100,4 +100,12 @@ int fork_process(int child_id,char *desc,int make_sock); |
100 | 100 |
int fork_tcp_process(int child_id,char *desc,int r,int *reader_fd_1); |
101 | 101 |
#endif |
102 | 102 |
|
103 |
+#ifdef PKG_MALLOC |
|
104 |
+void mem_dump_pkg_cb(str *name); |
|
105 |
+#endif |
|
106 |
+ |
|
107 |
+#ifdef SHM_MEM |
|
108 |
+int mem_dump_shm_fixup(void *handle, str *name, void **val); |
|
109 |
+#endif |
|
110 |
+ |
|
103 | 111 |
#endif |
... | ... |
@@ -73,6 +73,11 @@ int register_procs(int no); |
73 | 73 |
int get_max_open_fds(); |
74 | 74 |
int register_fds(int no); |
75 | 75 |
|
76 |
+ |
|
77 |
+int close_extra_socks(int proc_id, int proc_no); |
|
78 |
+ |
|
79 |
+#define get_proc_no() ((process_count)?*process_count:0) |
|
80 |
+ |
|
76 | 81 |
/* return processes pid */ |
77 | 82 |
int my_pid(); |
78 | 83 |
|
... | ... |
@@ -33,6 +33,7 @@ |
33 | 33 |
* -------- |
34 | 34 |
* 2003-04-15 added tcp_disable support (andrei) |
35 | 35 |
* 2006-06-14 added process table in shared mem (dragos) |
36 |
+ * 2007-07-04 added register_fds() and get_max_open_fds(() (andrei) |
|
36 | 37 |
*/ |
37 | 38 |
|
38 | 39 |
|
... | ... |
@@ -69,6 +70,8 @@ extern struct tcp_child* tcp_children; |
69 | 70 |
int init_pt(); |
70 | 71 |
int get_max_procs(); |
71 | 72 |
int register_procs(int no); |
73 |
+int get_max_open_fds(); |
|
74 |
+int register_fds(int no); |
|
72 | 75 |
|
73 | 76 |
/* return processes pid */ |
74 | 77 |
int my_pid(); |
... | ... |
@@ -66,12 +66,12 @@ extern int process_no; |
66 | 66 |
|
67 | 67 |
extern struct tcp_child* tcp_children; |
68 | 68 |
|
69 |
-inline int init_pt(); |
|
69 |
+int init_pt(); |
|
70 | 70 |
int get_max_procs(); |
71 | 71 |
int register_procs(int no); |
72 | 72 |
|
73 | 73 |
/* return processes pid */ |
74 |
-inline int my_pid(); |
|
74 |
+int my_pid(); |
|
75 | 75 |
|
76 | 76 |
/** |
77 | 77 |
* Forks a new process. |
... | ... |
@@ -79,7 +79,7 @@ inline int my_pid(); |
79 | 79 |
* @param make_sock - if to create a unix socket pair for it |
80 | 80 |
* @returns the pid of the new process |
81 | 81 |
*/ |
82 |
-inline int fork_process(int child_id,char *desc,int make_sock); |
|
82 |
+int fork_process(int child_id,char *desc,int make_sock); |
|
83 | 83 |
|
84 | 84 |
/** |
85 | 85 |
* Forks a new TCP process. |
... | ... |
@@ -89,7 +89,7 @@ inline int fork_process(int child_id,char *desc,int make_sock); |
89 | 89 |
* @returns the pid of the new process |
90 | 90 |
*/ |
91 | 91 |
#ifdef USE_TCP |
92 |
-inline int fork_tcp_process(int child_id,char *desc,int r,int *reader_fd_1); |
|
92 |
+int fork_tcp_process(int child_id,char *desc,int r,int *reader_fd_1); |
|
93 | 93 |
#endif |
94 | 94 |
|
95 | 95 |
#endif |
... | ... |
@@ -88,6 +88,8 @@ inline int fork_process(int child_id,char *desc,int make_sock); |
88 | 88 |
* @param *reader_fd_1 - pointer to return the reader_fd[1] |
89 | 89 |
* @returns the pid of the new process |
90 | 90 |
*/ |
91 |
+#ifdef USE_TCP |
|
91 | 92 |
inline int fork_tcp_process(int child_id,char *desc,int r,int *reader_fd_1); |
93 |
+#endif |
|
92 | 94 |
|
93 | 95 |
#endif |
... | ... |
@@ -32,6 +32,7 @@ |
32 | 32 |
* History: |
33 | 33 |
* -------- |
34 | 34 |
* 2003-04-15 added tcp_disable support (andrei) |
35 |
+ * 2006-06-14 added process table in shared mem (dragos) |
|
35 | 36 |
*/ |
36 | 37 |
|
37 | 38 |
|
... | ... |
@@ -40,33 +41,53 @@ |
40 | 41 |
|
41 | 42 |
#include <sys/types.h> |
42 | 43 |
#include <unistd.h> |
44 |
+#include <stdlib.h> |
|
43 | 45 |
|
44 | 46 |
#include "globals.h" |
45 | 47 |
#include "timer.h" |
46 | 48 |
#include "socket_info.h" |
49 |
+#include "locking.h" |
|
47 | 50 |
|
48 |
-#define MAX_PT_DESC 128 |
|
51 |
+#define MAX_PT_DESC 128 |
|
49 | 52 |
|
50 | 53 |
struct process_table { |
51 | 54 |
int pid; |
52 | 55 |
#ifdef USE_TCP |
53 |
- int unix_sock; /* unix socket on which tcp main listens */ |
|
54 |
- int idx; /* tcp child index, -1 for other processes */ |
|
56 |
+ int unix_sock; /* unix socket on which tcp main listens */ |
|
57 |
+ int idx; /* tcp child index, -1 for other processes */ |
|
55 | 58 |
#endif |
56 | 59 |
char desc[MAX_PT_DESC]; |
57 | 60 |
}; |
58 | 61 |
|
59 | 62 |
extern struct process_table *pt; |
63 |
+extern gen_lock_t* process_lock; |
|
64 |
+extern int *process_count; |
|
60 | 65 |
extern int process_no; |
61 |
-extern int process_count; |
|
62 |
-extern int last_process; |
|
63 | 66 |
|
67 |
+extern struct tcp_child* tcp_children; |
|
68 |
+ |
|
69 |
+inline int init_pt(); |
|
70 |
+int get_max_procs(); |
|
71 |
+int register_procs(int no); |
|
64 | 72 |
|
65 | 73 |
/* return processes pid */ |
66 |
-inline static int my_pid() |
|
67 |
-{ |
|
68 |
- return pt ? pt[process_no].pid : getpid(); |
|
69 |
-} |
|
74 |
+inline int my_pid(); |
|
75 |
+ |
|
76 |
+/** |
|
77 |
+ * Forks a new process. |
|
78 |
+ * @param desc - text description for the process table |
|
79 |
+ * @param make_sock - if to create a unix socket pair for it |
|
80 |
+ * @returns the pid of the new process |
|
81 |
+ */ |
|
82 |
+inline int fork_process(int child_id,char *desc,int make_sock); |
|
70 | 83 |
|
84 |
+/** |
|
85 |
+ * Forks a new TCP process. |
|
86 |
+ * @param desc - text description for the process table |
|
87 |
+ * @param r - index in the tcp_children array |
|
88 |
+ * @param *reader_fd_1 - pointer to return the reader_fd[1] |
|
89 |
+ * @returns the pid of the new process |
|
90 |
+ */ |
|
91 |
+inline int fork_tcp_process(int child_id,char *desc,int r,int *reader_fd_1); |
|
71 | 92 |
|
72 | 93 |
#endif |
... | ... |
@@ -58,34 +58,8 @@ struct process_table { |
58 | 58 |
|
59 | 59 |
extern struct process_table *pt; |
60 | 60 |
extern int process_no; |
61 |
- |
|
62 |
-/* get number of process started by main with |
|
63 |
- given configuration |
|
64 |
-*/ |
|
65 |
-inline static int process_count() |
|
66 |
-{ |
|
67 |
- int udp_listeners; |
|
68 |
- struct socket_info* si; |
|
69 |
- |
|
70 |
- for (si=udp_listen, udp_listeners=0; si; si=si->next, udp_listeners++); |
|
71 |
- return |
|
72 |
- /* receivers and attendant */ |
|
73 |
- (dont_fork ? 1 : children_no*udp_listeners + 1) |
|
74 |
- /* timer process */ |
|
75 |
- + 1 /* always, we need it in most cases, and we can't tell here |
|
76 |
- & now if we don't need it */ |
|
77 |
-#ifdef USE_SLOW_TIMER |
|
78 |
- + 1 /* slow timer process */ |
|
79 |
-#endif |
|
80 |
- /* fifo server */ |
|
81 |
- +((fifo==NULL || strlen(fifo)==0) ? 0 : 1 ) |
|
82 |
- /* unixsock server*/ |
|
83 |
- +(unixsock_name?unixsock_children:0) |
|
84 |
-#ifdef USE_TCP |
|
85 |
- +((!tcp_disable)?( 1/* tcp main */ + tcp_children_no ):0) |
|
86 |
-#endif |
|
87 |
- ; |
|
88 |
-} |
|
61 |
+extern int process_count; |
|
62 |
+extern int last_process; |
|
89 | 63 |
|
90 | 64 |
|
91 | 65 |
/* return processes pid */ |
... | ... |
@@ -74,6 +74,9 @@ inline static int process_count() |
74 | 74 |
/* timer process */ |
75 | 75 |
+ 1 /* always, we need it in most cases, and we can't tell here |
76 | 76 |
& now if we don't need it */ |
77 |
+#ifdef USE_SLOW_TIMER |
|
78 |
+ + 1 /* slow timer process */ |
|
79 |
+#endif |
|
77 | 80 |
/* fifo server */ |
78 | 81 |
+((fifo==NULL || strlen(fifo)==0) ? 0 : 1 ) |
79 | 82 |
/* unixsock server*/ |
... | ... |
@@ -72,18 +72,15 @@ inline static int process_count() |
72 | 72 |
/* receivers and attendant */ |
73 | 73 |
(dont_fork ? 1 : children_no*udp_listeners + 1) |
74 | 74 |
/* timer process */ |
75 |
- + (timer_list ? 1 : 0 ) |
|
75 |
+ + 1 /* always, we need it in most cases, and we can't tell here |
|
76 |
+ & now if we don't need it */ |
|
76 | 77 |
/* fifo server */ |
77 | 78 |
+((fifo==NULL || strlen(fifo)==0) ? 0 : 1 ) |
78 | 79 |
/* unixsock server*/ |
79 | 80 |
+(unixsock_name?unixsock_children:0) |
80 | 81 |
#ifdef USE_TCP |
81 |
- +((!tcp_disable)?( 1/* tcp main */ + tcp_children_no + |
|
82 |
- (timer_list ? 0: 1)):0) /* add the timer proc. |
|
83 |
- if not already taken |
|
84 |
- into account */ |
|
82 |
+ +((!tcp_disable)?( 1/* tcp main */ + tcp_children_no ):0) |
|
85 | 83 |
#endif |
86 |
- |
|
87 | 84 |
; |
88 | 85 |
} |
89 | 86 |
|
... | ... |
@@ -5,7 +5,7 @@ |
5 | 5 |
* |
6 | 6 |
* |
7 | 7 |
* |
8 |
- * Copyright (C) 2001-2003 Fhg Fokus |
|
8 |
+ * Copyright (C) 2001-2003 FhG Fokus |
|
9 | 9 |
* |
10 | 10 |
* This file is part of ser, a free SIP server. |
11 | 11 |
* |
... | ... |
@@ -88,7 +88,7 @@ inline static int process_count() |
88 | 88 |
} |
89 | 89 |
|
90 | 90 |
|
91 |
-/* retun processes's pid */ |
|
91 |
+/* return processes pid */ |
|
92 | 92 |
inline static int my_pid() |
93 | 93 |
{ |
94 | 94 |
return pt ? pt[process_no].pid : getpid(); |
... | ... |
@@ -75,6 +75,8 @@ inline static int process_count() |
75 | 75 |
+ (timer_list ? 1 : 0 ) |
76 | 76 |
/* fifo server */ |
77 | 77 |
+((fifo==NULL || strlen(fifo)==0) ? 0 : 1 ) |
78 |
+ /* unixsock server*/ |
|
79 |
+ +(unixsock_name?unixsock_children:0) |
|
78 | 80 |
#ifdef USE_TCP |
79 | 81 |
+((!tcp_disable)?( 1/* tcp main */ + tcp_children_no + |
80 | 82 |
(timer_list ? 0: 1)):0) /* add the timer proc. |
... | ... |
@@ -43,6 +43,7 @@ |
43 | 43 |
|
44 | 44 |
#include "globals.h" |
45 | 45 |
#include "timer.h" |
46 |
+#include "socket_info.h" |
|
46 | 47 |
|
47 | 48 |
#define MAX_PT_DESC 128 |
48 | 49 |
|
... | ... |
@@ -63,9 +64,13 @@ extern int process_no; |
63 | 64 |
*/ |
64 | 65 |
inline static int process_count() |
65 | 66 |
{ |
67 |
+ int udp_listeners; |
|
68 |
+ struct socket_info* si; |
|
69 |
+ |
|
70 |
+ for (si=udp_listen, udp_listeners=0; si; si=si->next, udp_listeners++); |
|
66 | 71 |
return |
67 | 72 |
/* receivers and attendant */ |
68 |
- (dont_fork ? 1 : children_no*sock_no + 1) |
|
73 |
+ (dont_fork ? 1 : children_no*udp_listeners + 1) |
|
69 | 74 |
/* timer process */ |
70 | 75 |
+ (timer_list ? 1 : 0 ) |
71 | 76 |
/* fifo server */ |
... | ... |
@@ -71,8 +71,8 @@ inline static int process_count() |
71 | 71 |
/* fifo server */ |
72 | 72 |
+((fifo==NULL || strlen(fifo)==0) ? 0 : 1 ) |
73 | 73 |
#ifdef USE_TCP |
74 |
- + (!tcp_disable)?( 1/* tcp main */ + tcp_children_no + |
|
75 |
- (timer_list ? 0: 1)):0 /* add the timer proc. |
|
74 |
+ +((!tcp_disable)?( 1/* tcp main */ + tcp_children_no + |
|
75 |
+ (timer_list ? 0: 1)):0) /* add the timer proc. |
|
76 | 76 |
if not already taken |
77 | 77 |
into account */ |
78 | 78 |
#endif |
... | ... |
@@ -28,6 +28,11 @@ |
28 | 28 |
* along with this program; if not, write to the Free Software |
29 | 29 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
30 | 30 |
*/ |
31 |
+/* |
|
32 |
+ * History: |
|
33 |
+ * -------- |
|
34 |
+ * 2003-04-15 added tcp_disable support (andrei) |
|
35 |
+ */ |
|
31 | 36 |
|
32 | 37 |
|
33 | 38 |
#ifndef _PT_H |
... | ... |
@@ -66,9 +71,10 @@ inline static int process_count() |
66 | 71 |
/* fifo server */ |
67 | 72 |
+((fifo==NULL || strlen(fifo)==0) ? 0 : 1 ) |
68 | 73 |
#ifdef USE_TCP |
69 |
- + 1/* tcp main */ + tcp_children_no + |
|
70 |
- (timer_list ? 0: 1) /* add the timer proc. if not already taken |
|
71 |
- into account */ |
|
74 |
+ + (!tcp_disable)?( 1/* tcp main */ + tcp_children_no + |
|
75 |
+ (timer_list ? 0: 1)):0 /* add the timer proc. |
|
76 |
+ if not already taken |
|
77 |
+ into account */ |
|
72 | 78 |
#endif |
73 | 79 |
|
74 | 80 |
; |
... | ... |
@@ -60,7 +60,14 @@ inline static int process_count() |
60 | 60 |
/* timer process */ |
61 | 61 |
+ (timer_list ? 1 : 0 ) |
62 | 62 |
/* fifo server */ |
63 |
- +((fifo==NULL || strlen(fifo)==0) ? 0 : 1 ); |
|
63 |
+ +((fifo==NULL || strlen(fifo)==0) ? 0 : 1 ) |
|
64 |
+#ifdef USE_TCP |
|
65 |
+ + 1/* tcp main */ + tcp_children_no + |
|
66 |
+ (timer_list ? 0: 1) /* add the timer proc. if not already taken |
|
67 |
+ into account */ |
|
68 |
+#endif |
|
69 |
+ |
|
70 |
+ ; |
|
64 | 71 |
} |
65 | 72 |
|
66 | 73 |
|
... | ... |
@@ -4,8 +4,32 @@ |
4 | 4 |
* Process Table |
5 | 5 |
* |
6 | 6 |
* |
7 |
+ * |
|
8 |
+ * Copyright (C) 2001-2003 Fhg Fokus |
|
9 |
+ * |
|
10 |
+ * This file is part of ser, a free SIP server. |
|
11 |
+ * |
|
12 |
+ * ser is free software; you can redistribute it and/or modify |
|
13 |
+ * it under the terms of the GNU General Public License as published by |
|
14 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
15 |
+ * (at your option) any later version |
|
16 |
+ * |
|
17 |
+ * For a license to use the ser software under conditions |
|
18 |
+ * other than those described here, or to purchase support for this |
|
19 |
+ * software, please contact iptel.org by e-mail at the following addresses: |
|
20 |
+ * info@iptel.org |
|
21 |
+ * |
|
22 |
+ * ser is distributed in the hope that it will be useful, |
|
23 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
24 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
25 |
+ * GNU General Public License for more details. |
|
26 |
+ * |
|
27 |
+ * You should have received a copy of the GNU General Public License |
|
28 |
+ * along with this program; if not, write to the Free Software |
|
29 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
7 | 30 |
*/ |
8 | 31 |
|
32 |
+ |
|
9 | 33 |
#ifndef _PT_H |
10 | 34 |
|
11 | 35 |
#include <sys/types.h> |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,49 @@ |
1 |
+/* |
|
2 |
+ * $Id$ |
|
3 |
+ * |
|
4 |
+ * Process Table |
|
5 |
+ * |
|
6 |
+ * |
|
7 |
+ */ |
|
8 |
+ |
|
9 |
+#ifndef _PT_H |
|
10 |
+ |
|
11 |
+#include <sys/types.h> |
|
12 |
+#include <unistd.h> |
|
13 |
+ |
|
14 |
+#include "globals.h" |
|
15 |
+#include "timer.h" |
|
16 |
+ |
|
17 |
+#define MAX_PT_DESC 128 |
|
18 |
+ |
|
19 |
+struct process_table { |
|
20 |
+ int pid; |
|
21 |
+ char desc[MAX_PT_DESC]; |
|
22 |
+}; |
|
23 |
+ |
|
24 |
+extern struct process_table *pt; |
|
25 |
+extern int process_no; |
|
26 |
+ |
|
27 |
+/* get number of process started by main with |
|
28 |
+ given configuration |
|
29 |
+*/ |
|
30 |
+inline static int process_count() |
|
31 |
+{ |
|
32 |
+ return |
|
33 |
+ /* receivers and attendant */ |
|
34 |
+ (dont_fork ? 1 : children_no*sock_no + 1) |
|
35 |
+ /* timer process */ |
|
36 |
+ + (timer_list ? 1 : 0 ) |
|
37 |
+ /* fifo server */ |
|
38 |
+ +((fifo==NULL || strlen(fifo)==0) ? 0 : 1 ); |
|
39 |
+} |
|
40 |
+ |
|
41 |
+ |
|
42 |
+/* retun processes's pid */ |
|
43 |
+inline static int my_pid() |
|
44 |
+{ |
|
45 |
+ return pt ? pt[process_no].pid : getpid(); |
|
46 |
+} |
|
47 |
+ |
|
48 |
+ |
|
49 |
+#endif |