- 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,46 +0,0 @@ |
1 |
-/* |
|
2 |
- * |
|
3 |
- * Copyright (C) 2001-2003 FhG Fokus |
|
4 |
- * |
|
5 |
- * Permission to use, copy, modify, and distribute this software for any |
|
6 |
- * purpose with or without fee is hereby granted, provided that the above |
|
7 |
- * copyright notice and this permission notice appear in all copies. |
|
8 |
- * |
|
9 |
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
10 |
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
11 |
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
12 |
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
13 |
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
14 |
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
15 |
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
16 |
- */ |
|
17 |
-/*! |
|
18 |
- * \file |
|
19 |
- * \brief Kamailio core :: Daemonize |
|
20 |
- * \author andrei |
|
21 |
- * |
|
22 |
- * \ingroup core |
|
23 |
- * Module: \ref core |
|
24 |
- * |
|
25 |
- * |
|
26 |
- */ |
|
27 |
- |
|
28 |
-#ifndef _daemonize_h |
|
29 |
-#define _daemonize_h |
|
30 |
- |
|
31 |
-int daemonize(char* name, int daemon_status_fd_input); |
|
32 |
-int do_suid(void); |
|
33 |
-int increase_open_fds(int target); |
|
34 |
-int set_core_dump(int enable, long unsigned int size); |
|
35 |
-int mem_lock_pages(void); |
|
36 |
-int set_rt_prio(int prio, int policy); |
|
37 |
- |
|
38 |
-void daemon_status_init(void); |
|
39 |
-void daemon_status_on_fork_cleanup(void); |
|
40 |
-int daemon_status_send(char status); |
|
41 |
-void daemon_status_no_wait(void); |
|
42 |
-void daemon_status_on_fork_cleanup(void); |
|
43 |
- |
|
44 |
-#endif /*_daemonize_h */ |
|
45 |
- |
|
46 |
-/* vi: set ts=4 sw=4 tw=79:ai:cindent: */ |
... | ... |
@@ -1,5 +1,4 @@ |
1 | 1 |
/* |
2 |
- * $Id$ |
|
3 | 2 |
* |
4 | 3 |
* Copyright (C) 2001-2003 FhG Fokus |
5 | 4 |
* |
... | ... |
@@ -15,13 +14,15 @@ |
15 | 14 |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
16 | 15 |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17 | 16 |
*/ |
18 |
-/* |
|
17 |
+/*! |
|
18 |
+ * \file |
|
19 |
+ * \brief SIP-router core :: Daemonize |
|
20 |
+ * \author andrei |
|
21 |
+ * |
|
22 |
+ * \ingroup core |
|
23 |
+ * Module: \ref core |
|
24 |
+ * |
|
19 | 25 |
* |
20 |
- * History: |
|
21 |
- * -------- |
|
22 |
- * 2004-02-20 created by andrei |
|
23 |
- * 2007-06-07 added mem_lock_pages() (andrei) |
|
24 |
- * 2010-08-19 send status via pipe code derived from 9167c1 (ibc) (andrei) |
|
25 | 26 |
*/ |
26 | 27 |
|
27 | 28 |
#ifndef _daemonize_h |
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)
... | ... |
@@ -28,17 +28,17 @@ |
28 | 28 |
#define _daemonize_h |
29 | 29 |
|
30 | 30 |
int daemonize(char* name, int daemon_status_fd_input); |
31 |
-int do_suid(); |
|
31 |
+int do_suid(void); |
|
32 | 32 |
int increase_open_fds(int target); |
33 | 33 |
int set_core_dump(int enable, long unsigned int size); |
34 |
-int mem_lock_pages(); |
|
34 |
+int mem_lock_pages(void); |
|
35 | 35 |
int set_rt_prio(int prio, int policy); |
36 | 36 |
|
37 |
-void daemon_status_init(); |
|
38 |
-void daemon_status_on_fork_cleanup(); |
|
37 |
+void daemon_status_init(void); |
|
38 |
+void daemon_status_on_fork_cleanup(void); |
|
39 | 39 |
int daemon_status_send(char status); |
40 |
-void daemon_status_no_wait(); |
|
41 |
-void daemon_status_on_fork_cleanup(); |
|
40 |
+void daemon_status_no_wait(void); |
|
41 |
+void daemon_status_on_fork_cleanup(void); |
|
42 | 42 |
|
43 | 43 |
#endif /*_daemonize_h */ |
44 | 44 |
|
- init rlimit struct for proper dbg message when core limits are not
changed
... | ... |
@@ -30,7 +30,7 @@ |
30 | 30 |
int daemonize(char* name, int daemon_status_fd_input); |
31 | 31 |
int do_suid(); |
32 | 32 |
int increase_open_fds(int target); |
33 |
-int set_core_dump(int enable, int size); |
|
33 |
+int set_core_dump(int enable, long unsigned int size); |
|
34 | 34 |
int mem_lock_pages(); |
35 | 35 |
int set_rt_prio(int prio, int policy); |
36 | 36 |
|
- 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]
... | ... |
@@ -3,28 +3,25 @@ |
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2001-2003 FhG Fokus |
5 | 5 |
* |
6 |
- * This file is part of SIP-router, a free SIP server. |
|
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. |
|
7 | 9 |
* |
8 |
- * SIP-router is free software; you can redistribute it and/or modify |
|
9 |
- * it under the terms of the GNU General Public License as published by |
|
10 |
- * the Free Software Foundation; either version 2 of the License, or |
|
11 |
- * (at your option) any later version |
|
12 |
- * |
|
13 |
- * SIP-router is distributed in the hope that it will be useful, |
|
14 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
- * GNU General Public License for more details. |
|
17 |
- * |
|
18 |
- * You should have received a copy of the GNU General Public License |
|
19 |
- * along with this program; if not, write to the Free Software |
|
20 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
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. |
|
21 | 17 |
*/ |
22 | 18 |
/* |
23 | 19 |
* |
24 | 20 |
* History: |
25 | 21 |
* -------- |
26 | 22 |
* 2004-02-20 created by andrei |
27 |
- * 2007-06-07 added mem_lock_pages() (andrei) |
|
23 |
+ * 2007-06-07 added mem_lock_pages() (andrei) |
|
24 |
+ * 2010-08-19 send status via pipe code derived from 9167c1 (ibc) (andrei) |
|
28 | 25 |
*/ |
29 | 26 |
|
30 | 27 |
#ifndef _daemonize_h |
... | ... |
@@ -37,5 +34,12 @@ int set_core_dump(int enable, int size); |
37 | 34 |
int mem_lock_pages(); |
38 | 35 |
int set_rt_prio(int prio, int policy); |
39 | 36 |
|
37 |
+void daemon_status_init(); |
|
38 |
+void daemon_status_on_fork_cleanup(); |
|
39 |
+int daemon_status_send(char status); |
|
40 |
+void daemon_status_no_wait(); |
|
41 |
+void daemon_status_on_fork_cleanup(); |
|
42 |
+ |
|
43 |
+#endif /*_daemonize_h */ |
|
40 | 44 |
|
41 |
-#endif |
|
45 |
+/* vi: set ts=4 sw=4 tw=79:ai:cindent: */ |
If for example the listen address is not local or a DB connection uses an invalid password, then the command
"ser" would return 0 (OK) anyway (even if it fails to start).This occurs because all those checking
(socket, DB connections...) are performed *after* invoking daemonize() so the parent process (which
could be invoked by "/etc/init.d/ser start") returns 0 knowing nothing about those errors. This caused some
management tools like HeartBeat to work badly.
The patch is simple: the master process opens a pipe, and reads from one end. The forked main process,
after the correct initialization of components, will write some bytes to the writting end. In case of error,
no data is written to the pipe.
The master process waits for 10 seconds, or else it considers the main process blocked and exits with a different
error code( -2 ). In this case, it is left for the user to ensure that all ser children are killed correctly.
Patch initially from Iñaki Baz Castillo.
... | ... |
@@ -3,19 +3,14 @@ |
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2001-2003 FhG Fokus |
5 | 5 |
* |
6 |
- * This file is part of ser, a free SIP server. |
|
6 |
+ * This file is part of SIP-router, a free SIP server. |
|
7 | 7 |
* |
8 |
- * ser is free software; you can redistribute it and/or modify |
|
8 |
+ * SIP-router is free software; you can redistribute it and/or modify |
|
9 | 9 |
* it under the terms of the GNU General Public License as published by |
10 | 10 |
* the Free Software Foundation; either version 2 of the License, or |
11 | 11 |
* (at your option) any later version |
12 | 12 |
* |
13 |
- * For a license to use the ser software under conditions |
|
14 |
- * other than those described here, or to purchase support for this |
|
15 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
16 |
- * info@iptel.org |
|
17 |
- * |
|
18 |
- * ser is distributed in the hope that it will be useful, |
|
13 |
+ * SIP-router is distributed in the hope that it will be useful, |
|
19 | 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | 16 |
* GNU General Public License for more details. |
... | ... |
@@ -29,6 +29,7 @@ |
29 | 29 |
* History: |
30 | 30 |
* -------- |
31 | 31 |
* 2004-02-20 created by andrei |
32 |
+ * 2007-06-07 added mem_lock_pages() (andrei) |
|
32 | 33 |
*/ |
33 | 34 |
|
34 | 35 |
#ifndef _daemonize_h |
... | ... |
@@ -38,6 +39,8 @@ int daemonize(char* name); |
38 | 39 |
int do_suid(); |
39 | 40 |
int increase_open_fds(int target); |
40 | 41 |
int set_core_dump(int enable, int size); |
42 |
+int mem_lock_pages(); |
|
43 |
+int set_rt_prio(int prio, int policy); |
|
41 | 44 |
|
42 | 45 |
|
43 | 46 |
#endif |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,41 @@ |
1 |
+/* |
|
2 |
+ * $Id$ |
|
3 |
+ * |
|
4 |
+ * Copyright (C) 2001-2003 Fhg Fokus |
|
5 |
+ * |
|
6 |
+ * This file is part of ser, a free SIP server. |
|
7 |
+ * |
|
8 |
+ * ser is free software; you can redistribute it and/or modify |
|
9 |
+ * it under the terms of the GNU General Public License as published by |
|
10 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
11 |
+ * (at your option) any later version |
|
12 |
+ * |
|
13 |
+ * For a license to use the ser software under conditions |
|
14 |
+ * other than those described here, or to purchase support for this |
|
15 |
+ * software, please contact iptel.org by e-mail at the following addresses: |
|
16 |
+ * info@iptel.org |
|
17 |
+ * |
|
18 |
+ * ser is distributed in the hope that it will be useful, |
|
19 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
+ * GNU General Public License for more details. |
|
22 |
+ * |
|
23 |
+ * You should have received a copy of the GNU General Public License |
|
24 |
+ * along with this program; if not, write to the Free Software |
|
25 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
26 |
+ */ |
|
27 |
+/* |
|
28 |
+ * |
|
29 |
+ * History: |
|
30 |
+ * -------- |
|
31 |
+ * 2004-02-20 created by andrei |
|
32 |
+ */ |
|
33 |
+ |
|
34 |
+#ifndef _daemonize_h |
|
35 |
+#define _daemonize_h |
|
36 |
+ |
|
37 |
+int daemonize(char* name); |
|
38 |
+int do_suid(); |
|
39 |
+ |
|
40 |
+ |
|
41 |
+#endif |