Mercurial > hg > freeDiameter
annotate freeDiameter/main.c @ 14:14cf6daf716d
Some progress on peers module
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Thu, 01 Oct 2009 18:24:07 +0900 |
parents | ef9ef3bf4752 |
children | 013ce9851131 |
rev | line source |
---|---|
0 | 1 /********************************************************************************************************* |
2 * Software License Agreement (BSD License) * | |
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> * | |
4 * * | |
5 * Copyright (c) 2009, WIDE Project and NICT * | |
6 * All rights reserved. * | |
7 * * | |
8 * Redistribution and use of this software in source and binary forms, with or without modification, are * | |
9 * permitted provided that the following conditions are met: * | |
10 * * | |
11 * * Redistributions of source code must retain the above * | |
12 * copyright notice, this list of conditions and the * | |
13 * following disclaimer. * | |
14 * * | |
15 * * Redistributions in binary form must reproduce the above * | |
16 * copyright notice, this list of conditions and the * | |
17 * following disclaimer in the documentation and/or other * | |
18 * materials provided with the distribution. * | |
19 * * | |
20 * * Neither the name of the WIDE Project or NICT nor the * | |
21 * names of its contributors may be used to endorse or * | |
22 * promote products derived from this software without * | |
23 * specific prior written permission of WIDE Project and * | |
24 * NICT. * | |
25 * * | |
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * | |
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * | |
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * | |
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * | |
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * | |
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * | |
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * | |
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | |
34 *********************************************************************************************************/ | |
35 | |
1
bafb831ba688
Fix names to proper case for freeDiameter
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
0
diff
changeset
|
36 #include "fD.h" |
0 | 37 |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
38 #include <signal.h> |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
39 #include <getopt.h> |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
40 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
41 /* forward declarations */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
42 static void * sig_hdl(void * arg); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
43 static int main_cmdline(int argc, char *argv[]); |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
44 static void main_version(void); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
45 static void main_help( void ); |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
46 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
47 /* The static configuration structure */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
48 static struct fd_config conf; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
49 struct fd_config * fd_g_config = &conf; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
50 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
51 /* freeDiameter starting point */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
52 int main(int argc, char * argv[]) |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
53 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
54 int ret; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
55 pthread_t sig_th; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
56 sigset_t sig_all; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
57 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
58 memset(fd_g_config, 0, sizeof(struct fd_config)); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
59 sigfillset(&sig_all); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
60 CHECK_POSIX( pthread_sigmask(SIG_BLOCK, &sig_all, NULL) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
61 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
62 /* Initialize the library */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
63 CHECK_FCT( fd_lib_init() ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
64 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
65 /* Name this thread */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
66 fd_log_threadname("Main"); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
67 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
68 /* Initialize the config */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
69 CHECK_FCT( fd_conf_init() ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
70 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
71 /* Parse the command-line */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
72 CHECK_FCT( main_cmdline(argc, argv) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
73 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
74 /* Allow SIGINT and SIGTERM from this point */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
75 CHECK_POSIX( pthread_create(&sig_th, NULL, sig_hdl, NULL) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
76 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
77 /* Add definitions of the base protocol */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
78 CHECK_FCT( fd_dict_base_protocol(fd_g_config->cnf_dict) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
79 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
80 /* Initialize other modules */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
81 CHECK_FCT( fd_queues_init() ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
82 CHECK_FCT( fd_msg_init() ); |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
83 CHECK_FCT( fd_p_expi_init() ); |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
84 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
85 /* Parse the configuration file */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
86 CHECK_FCT( fd_conf_parse() ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
87 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
88 /* Load the dynamic extensions */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
89 CHECK_FCT( fd_ext_load() ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
90 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
91 /* Start the peer state machines */ |
13
ef9ef3bf4752
Progress on peer state machine
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
12
diff
changeset
|
92 CHECK_FCT( fd_psm_start() ); |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
93 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
94 /* Now, just wait for events */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
95 TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon initialized."); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
96 fd_conf_dump(); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
97 while (1) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
98 int code; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
99 CHECK_FCT_DO( fd_event_get(fd_g_config->cnf_main_ev, &code, NULL), break ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
100 switch (code) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
101 case FDEV_DUMP_DICT: |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
102 fd_dict_dump(fd_g_config->cnf_dict); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
103 break; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
104 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
105 case FDEV_DUMP_EXT: |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
106 fd_ext_dump(); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
107 break; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
108 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
109 case FDEV_DUMP_QUEUES: |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
110 fd_fifo_dump(0, "Incoming messages", fd_g_incoming, fd_msg_dump_walk); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
111 fd_fifo_dump(0, "Outgoing messages", fd_g_outgoing, fd_msg_dump_walk); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
112 fd_fifo_dump(0, "Local messages", fd_g_local, fd_msg_dump_walk); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
113 break; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
114 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
115 case FDEV_DUMP_CONFIG: |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
116 fd_conf_dump(); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
117 break; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
118 |
11
6576ef5e01eb
Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
119 case FDEV_DUMP_PEERS: |
12
418d2ce80dc8
Added support in configuration file for peers declaration
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
120 fd_peer_dump_list(FULL); |
11
6576ef5e01eb
Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
121 break; |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
122 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
123 case FDEV_TERMINATE: |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
124 ret = 0; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
125 goto end; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
126 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
127 default: |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
128 TRACE_DEBUG(INFO, "Unexpected event in the daemon (%d), ignored.\n", code); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
129 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
130 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
131 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
132 end: |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
133 TRACE_DEBUG(INFO, FD_PROJECT_BINARY " daemon is stopping..."); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
134 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
135 /* cleanups */ |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
136 TODO("Stop dispatch thread(s) properly (no cancel yet)"); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
137 CHECK_FCT_DO( fd_peer_fini(), /* Stop all connections */ ); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
138 TODO("Stop dispatch & routing threads"); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
139 CHECK_FCT_DO( fd_ext_fini(), /* Cleaup all extensions */ ); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
140 TODO("Cleanup queues (dump all remaining messages ?)"); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
141 |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
142 CHECK_FCT_DO( fd_thr_term(&sig_th), /* continue */ ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
143 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
144 return ret; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
145 } |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
146 |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
147 const char * fd_ev_str(int event) |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
148 { |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
149 switch (event) { |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
150 #define case_str( _val )\ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
151 case _val : return #_val |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
152 case_str(FDEV_TERMINATE); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
153 case_str(FDEV_DUMP_DICT); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
154 case_str(FDEV_DUMP_EXT); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
155 case_str(FDEV_DUMP_QUEUES); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
156 case_str(FDEV_DUMP_CONFIG); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
157 case_str(FDEV_DUMP_PEERS); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
158 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
159 default: |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
160 TRACE_DEBUG(FULL, "Unknown event : %d", event); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
161 return "Unknown event"; |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
162 } |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
163 } |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
164 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
165 /* Parse the command-line */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
166 static int main_cmdline(int argc, char *argv[]) |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
167 { |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
168 int c; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
169 int option_index = 0; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
170 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
171 struct option long_options[] = { |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
172 { "help", 0, NULL, 'h' }, |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
173 { "version", 0, NULL, 'V' }, |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
174 { "config", 1, NULL, 'c' }, |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
175 { "debug", 0, NULL, 'd' }, |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
176 { "quiet", 0, NULL, 'q' }, |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
177 { NULL, 0, NULL, 0 } |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
178 }; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
179 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
180 TRACE_ENTRY("%d %p", argc, argv); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
181 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
182 /* Loop on arguments */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
183 while (1) { |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
184 c = getopt_long (argc, argv, "hVc:dq", long_options, &option_index); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
185 if (c == -1) |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
186 break; /* Exit from the loop. */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
187 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
188 switch (c) { |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
189 case 'h': /* Print help and exit. */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
190 main_help(); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
191 exit(0); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
192 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
193 case 'V': /* Print version and exit. */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
194 main_version(); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
195 exit(0); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
196 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
197 case 'c': /* Read configuration from this file instead of the default location.. */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
198 CHECK_PARAMS( optarg ); |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
199 fd_g_config->cnf_file = optarg; |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
200 break; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
201 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
202 case 'd': /* Increase verbosity of debug messages. */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
203 fd_g_debug_lvl++; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
204 break; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
205 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
206 case 'q': /* Decrease verbosity then remove debug messages. */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
207 fd_g_debug_lvl--; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
208 break; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
209 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
210 case '?': /* Invalid option. */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
211 /* `getopt_long' already printed an error message. */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
212 TRACE_DEBUG(INFO, "getopt_long found an invalid character\n"); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
213 return EINVAL; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
214 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
215 default: /* bug: option not considered. */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
216 TRACE_DEBUG(INFO, "A command-line option is missing in parser: %c\n", c); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
217 ASSERT(0); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
218 return EINVAL; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
219 } |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
220 } |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
221 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
222 return 0; |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
223 } |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
224 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
225 /* Display package version */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
226 static void main_version_core(void) |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
227 { |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
228 printf("%s, version %d.%d.%d" |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
229 #ifdef HG_VERSION |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
230 " (r%s" |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
231 # ifdef PACKAGE_HG_REVISION |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
232 "/%s" |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
233 # endif /* PACKAGE_HG_VERSION */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
234 ")" |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
235 #endif /* HG_VERSION */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
236 "\n", |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
237 FD_PROJECT_NAME, FD_PROJECT_VERSION_MAJOR, FD_PROJECT_VERSION_MINOR, FD_PROJECT_VERSION_REV |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
238 #ifdef HG_VERSION |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
239 , HG_VERSION |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
240 # ifdef PACKAGE_HG_REVISION |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
241 , PACKAGE_HG_REVISION |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
242 # endif /* PACKAGE_HG_VERSION */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
243 #endif /* HG_VERSION */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
244 ); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
245 } |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
246 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
247 /* Display package version and general info */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
248 static void main_version(void) |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
249 { |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
250 main_version_core(); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
251 printf( "%s\n", FD_PROJECT_COPYRIGHT); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
252 printf( "\nSee " FD_PROJECT_NAME " homepage at http://aaa.koganei.wide.ad.jp/\n" |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
253 " for information, updates and bug reports on this software.\n"); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
254 } |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
255 |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
256 /* Print command-line options */ |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
257 static void main_help( void ) |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
258 { |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
259 main_version_core(); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
260 printf( " This daemon is an implementation of the Diameter protocol\n" |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
261 " used for Authentication, Authorization, and Accounting (AAA).\n"); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
262 printf("\nUsage: " FD_PROJECT_BINARY " [OPTIONS]...\n"); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
263 printf( " -h, --help Print help and exit\n" |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
264 " -V, --version Print version and exit\n" |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
265 " -c, --config=filename Read configuration from this file instead of the \n" |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
266 " default location (%s).\n", DEFAULT_CONF_FILE); |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
267 printf( "\nDebug:\n" |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
268 " These options are mostly useful for developers\n" |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
269 " -d, --debug Increase verbosity of debug messages\n" |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
13
diff
changeset
|
270 " -q, --quiet Decrease verbosity then remove debug messages\n"); |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
271 } |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
272 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
273 #ifdef HAVE_SIGNALENT_H |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
274 const char *const signalstr[] = { |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
275 # include "signalent.h" |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
276 }; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
277 const int nsignalstr = sizeof signalstr / sizeof signalstr[0]; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
278 # define SIGNALSTR(sig) (((sig) < nsignalstr) ? signalstr[(sig)] : "unknown") |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
279 #else /* HAVE_SIGNALENT_H */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
280 # define SIGNALSTR(sig) ("") |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
281 #endif /* HAVE_SIGNALENT_H */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
282 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
283 /* signal handler */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
284 static void * sig_hdl(void * arg) |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
285 { |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
286 sigset_t sig_main; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
287 int sig = 0; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
288 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
289 TRACE_ENTRY(); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
290 fd_log_threadname("Main signal handler"); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
291 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
292 sigemptyset(&sig_main); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
293 sigaddset(&sig_main, SIGINT); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
294 sigaddset(&sig_main, SIGTERM); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
295 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
296 CHECK_SYS_DO( sigwait(&sig_main, &sig), TRACE_DEBUG(INFO, "Error in sigwait function") ); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
297 |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
298 TRACE_DEBUG(INFO, "Received signal %s (%d), exiting", SIGNALSTR(sig), sig); |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
9
diff
changeset
|
299 CHECK_FCT_DO( fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, NULL), exit(2) ); |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
300 return NULL; |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
301 } |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
302 |