ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/gvpe.C
(Generate patch)

Comparing gvpe/src/gvpe.C (file contents):
Revision 1.16 by pcg, Sun Jan 18 03:59:09 2009 UTC vs.
Revision 1.19 by root, Tue Feb 15 13:31:23 2011 UTC

1/* 1/*
2 gvpe.C -- the main file for gvpe 2 gvpe.C -- the main file for gvpe
3 Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl> 3 Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl>
4 2000-2002 Guus Sliepen <guus@sliepen.eu.org> 4 2000-2002 Guus Sliepen <guus@sliepen.eu.org>
5 2003-2008 Marc Lehmann <gvpe@schmorp.de> 5 2003-2011 Marc Lehmann <gvpe@schmorp.de>
6 6
7 This file is part of GVPE. 7 This file is part of GVPE.
8 8
9 GVPE is free software; you can redistribute it and/or modify it 9 GVPE is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the 10 under the terms of the GNU General Public License as published by the
75 75
76/* If zero, don't detach from the terminal. */ 76/* If zero, don't detach from the terminal. */
77static int do_detach = 1; 77static int do_detach = 1;
78 78
79static struct option const long_options[] = 79static struct option const long_options[] =
80 { 80{
81 {"config", required_argument, NULL, 'c'}, 81 {"config", required_argument, NULL, 'c'},
82 {"help", no_argument, &show_help, 1}, 82 {"help", no_argument, &show_help, 1},
83 {"version", no_argument, &show_version, 1}, 83 {"version", no_argument, &show_version, 1},
84 {"no-detach", no_argument, &do_detach, 0}, 84 {"no-detach", no_argument, &do_detach, 0},
85 {"log-level", required_argument, NULL, 'l'}, 85 {"log-level", required_argument, NULL, 'l'},
86 {"mlock", no_argument, &do_mlock, 1}, 86 {"mlock", no_argument, &do_mlock, 1},
87 {NULL, 0, NULL, 0} 87 {NULL, 0, NULL, 0}
88 }; 88};
89 89
90static void 90static void
91usage (int status) 91usage (int status)
92{ 92{
93 if (status != 0) 93 if (status != 0)
106 } 106 }
107 107
108 exit (status); 108 exit (status);
109} 109}
110 110
111void 111static void
112parse_options (int argc, char **argv, char **envp) 112parse_options (int argc, char **argv, char **envp)
113{ 113{
114 int r; 114 int r;
115 int option_index = 0; 115 int option_index = 0;
116 116
149 break; 149 break;
150 } 150 }
151 } 151 }
152} 152}
153 153
154/*
155 Close network connections, and terminate neatly 154// close network connections, and terminate neatly
156*/ 155static void
157void cleanup_and_exit(int c) 156cleanup_and_exit (int c)
158{ 157{
159 network.shutdown_all (); 158 network.shutdown_all ();
160 159
161 if (conf.pidfilename) 160 if (conf.pidfilename)
162 remove_pid (conf.pidfilename); 161 remove_pid (conf.pidfilename);
164 slog (L_INFO, _("terminating with exit code %d"), c); 163 slog (L_INFO, _("terminating with exit code %d"), c);
165 164
166 exit (c); 165 exit (c);
167} 166}
168 167
169/*
170 Signal handlers. 168// signal handlers
171*/ 169static RETSIGTYPE
172RETSIGTYPE
173sigterm_handler (int a) 170sigterm_handler (int a)
174{ 171{
175 network.events |= vpn::EVENT_SHUTDOWN; 172 network.events |= vpn::EVENT_SHUTDOWN;
176 network.event.start (); 173 network.event.start ();
177} 174}
178 175
179RETSIGTYPE 176static RETSIGTYPE
180sighup_handler (int a) 177sighup_handler (int a)
181{ 178{
182 network.events |= vpn::EVENT_RECONNECT; 179 network.events |= vpn::EVENT_RECONNECT;
183 network.event.start (); 180 network.event.start ();
184} 181}
185 182
186RETSIGTYPE 183static RETSIGTYPE
187sigusr1_handler (int a) 184sigusr1_handler (int a)
188{ 185{
189 network.dump_status (); 186 network.dump_status ();
190} 187}
191 188
192RETSIGTYPE 189static RETSIGTYPE
193sigusr2_handler (int a) 190sigusr2_handler (int a)
194{ 191{
195} 192}
196 193
197void 194static void
198setup_signals (void) 195setup_signals (void)
199{ 196{
200 struct sigaction act; 197 struct sigaction act;
201 198
202 sigfillset (&act.sa_mask); 199 sigfillset (&act.sa_mask);
293 { 290 {
294 ev_loop (EV_DEFAULT_ 0); 291 ev_loop (EV_DEFAULT_ 0);
295 cleanup_and_exit (EXIT_FAILURE); 292 cleanup_and_exit (EXIT_FAILURE);
296 } 293 }
297 294
298 slog (L_ERR, _("unable to setup network, unrecoverable error, exiting.")); 295 slog (L_ERR, _("unrecoverable error while setting up network, exiting."));
299 cleanup_and_exit (EXIT_FAILURE); 296 cleanup_and_exit (EXIT_FAILURE);
300} 297}
301 298

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines