… | |
… | |
8 | * Portions of this file were derived from sources bearing the following license: |
8 | * Portions of this file were derived from sources bearing the following license: |
9 | * Rights to this code are documented in doc/pod/license.pod. |
9 | * Rights to this code are documented in doc/pod/license.pod. |
10 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
10 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
11 | */ |
11 | */ |
12 | |
12 | |
13 | static char const rcsid[] = "$Id: main.C,v 1.9 2007/09/16 18:54:45 pippijn Exp $"; |
13 | static char const rcsid[] = "$Id: main.C,v 1.10 2007/09/22 14:27:30 pippijn Exp $"; |
14 | |
14 | |
15 | #include "atheme.h" |
15 | #include "atheme.h" |
|
|
16 | #include <libermyth.h> |
|
|
17 | #include <util/time.h> |
16 | #include "servers.h" |
18 | #include "servers.h" |
17 | #include <ermyth/database.h> |
19 | #include <ermyth/database.h> |
18 | #include <ermyth/module.h> |
20 | #include <ermyth/module.h> |
19 | #include <account/kline.h> |
21 | #include <account/kline.h> |
20 | #include <account/myuser.h> |
22 | #include <account/myuser.h> |
… | |
… | |
25 | #include "internal.h" |
27 | #include "internal.h" |
26 | #include "datastream.h" |
28 | #include "datastream.h" |
27 | #include "authcookie.h" |
29 | #include "authcookie.h" |
28 | #include "connection.h" |
30 | #include "connection.h" |
29 | #include "confparse.h" |
31 | #include "confparse.h" |
30 | #include <ermyth/shstr.h> |
|
|
31 | #include <common/random.h> |
32 | #include <util/random.h> |
32 | |
33 | |
33 | /* *INDENT-OFF* */ |
34 | /* *INDENT-OFF* */ |
34 | static void |
35 | static void |
35 | print_help (void) |
36 | print_help (void) |
36 | { |
37 | { |
… | |
… | |
84 | setlocale (LC_ALL, ""); |
85 | setlocale (LC_ALL, ""); |
85 | bindtextdomain (PACKAGE_NAME, LOCALEDIR); |
86 | bindtextdomain (PACKAGE_NAME, LOCALEDIR); |
86 | textdomain (PACKAGE_NAME); |
87 | textdomain (PACKAGE_NAME); |
87 | #endif |
88 | #endif |
88 | |
89 | |
89 | // set up shstr buckets |
|
|
90 | std::vector<shentry *> *shstr_buckets = new std::vector<shentry *> [shstr::bucketcnt ()]; |
|
|
91 | shstr::initbuckets (shstr_buckets); |
|
|
92 | |
|
|
93 | /* change to our local directory */ |
90 | /* change to our local directory */ |
94 | if (chdir (PREFIX) < 0) |
91 | if (chdir (PREFIX) < 0) |
95 | { |
92 | { |
96 | perror (PREFIX); |
93 | perror (PREFIX); |
97 | return 20; |
94 | return 20; |
… | |
… | |
318 | /* we're shutting down */ |
315 | /* we're shutting down */ |
319 | backend->save (); |
316 | backend->save (); |
320 | if (chansvs.me != NULL && chansvs.me->me != NULL) |
317 | if (chansvs.me != NULL && chansvs.me->me != NULL) |
321 | phandler->quit_sts (chansvs.me->me, "shutting down"); |
318 | phandler->quit_sts (chansvs.me->me, "shutting down"); |
322 | |
319 | |
|
|
320 | /* free used memory */ |
|
|
321 | modules::cleanup (); |
|
|
322 | operclass_cleanup (); |
|
|
323 | soper_cleanup (); |
|
|
324 | |
323 | remove (pidfilename); |
325 | remove (pidfilename); |
324 | errno = 0; |
326 | errno = 0; |
325 | if (curr_uplink != NULL && curr_uplink->conn != NULL) |
327 | if (curr_uplink != NULL && curr_uplink->conn != NULL) |
326 | sendq_flush (curr_uplink->conn); |
328 | sendq_flush (curr_uplink->conn); |
327 | connection_t::close_all (); |
329 | connection_t::close_all (); |
328 | |
330 | |
329 | me.connected = false; |
331 | me.connected = false; |
|
|
332 | |
|
|
333 | mynick_t::cleanup (); |
|
|
334 | myuser_t::cleanup (); // XXX: this currently breaks and I don't know why |
|
|
335 | mychan_t::cleanup (); |
|
|
336 | |
|
|
337 | chansvs.cleanup (); |
|
|
338 | globsvs.cleanup (); |
|
|
339 | opersvs.cleanup (); |
|
|
340 | memosvs.cleanup (); |
|
|
341 | gamesvs.cleanup (); |
|
|
342 | nicksvs.cleanup (); |
|
|
343 | saslsvs.cleanup (); |
330 | |
344 | |
|
|
345 | delete phandler; |
|
|
346 | delete backend; |
|
|
347 | uplink_cleanup (); |
|
|
348 | server_delete (me.me, true); |
|
|
349 | tld_cleanup (); |
|
|
350 | |
|
|
351 | conf_cleanup (); |
|
|
352 | sfree (config_file); |
|
|
353 | sfree (log_path); |
|
|
354 | |
|
|
355 | #ifdef HAVE_EXECVE |
331 | /* should we restart? */ |
356 | /* should we restart? */ |
332 | if (runflags & RF_RESTART) |
357 | if (runflags & RF_RESTART) |
333 | { |
358 | { |
334 | slog (LG_INFO, "main(): restarting"); |
359 | slog (LG_INFO, "main(): restarting"); |
|
|
360 | log_shutdown (); |
335 | |
361 | |
336 | #ifdef HAVE_EXECVE |
|
|
337 | execve (me.execname, argv, envp); |
362 | execve (me.execname, argv, envp); |
338 | #endif |
|
|
339 | } |
363 | } |
340 | |
364 | #endif |
|
|
365 | |
341 | slog (LG_INFO, "main(): shutting down"); |
366 | slog (LG_INFO, "main(): shutting down"); |
342 | |
|
|
343 | /* free used memory */ |
|
|
344 | shstr::cleanup (); |
|
|
345 | modules::cleanup (); |
|
|
346 | myuser_t::cleanup (); // XXX: this currently breaks and I don't know why |
|
|
347 | mynick_t::cleanup (); |
|
|
348 | mychan_t::cleanup (); |
|
|
349 | delete phandler; |
|
|
350 | deinit_conf (); |
|
|
351 | server_delete (me.me, true); |
|
|
352 | |
|
|
353 | log_shutdown (); |
367 | log_shutdown (); |
354 | |
368 | |
355 | return 0; |
369 | return 0; |
356 | } |
370 | } |