… | |
… | |
508 | write_book_archive (); |
508 | write_book_archive (); |
509 | |
509 | |
510 | LOG (llevDebug, "emergency save done.\n"); |
510 | LOG (llevDebug, "emergency save done.\n"); |
511 | } |
511 | } |
512 | |
512 | |
|
|
513 | // send all clients some informational text |
|
|
514 | static void |
|
|
515 | cleanup_inform (const char *cause, bool make_core) |
|
|
516 | { |
|
|
517 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 0, 0, "The server will now shutdown.\n"); |
|
|
518 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 0, 0, "Cause for this shtudown: %s\n", cause); |
|
|
519 | |
|
|
520 | if (make_core) |
|
|
521 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 0, 0, "This is considered a crash.\n"); |
|
|
522 | else |
|
|
523 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 0, 0, "This is considered to be a clean shutdown.\n"); |
|
|
524 | |
|
|
525 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 0, 0, "%s\n", CLEANUP_MESSAGE); |
|
|
526 | |
|
|
527 | flush_sockets (); |
|
|
528 | } |
|
|
529 | |
513 | /* clean up everything before exiting */ |
530 | /* clean up everything before exiting */ |
514 | void |
531 | void |
515 | cleanup (bool make_core) |
532 | cleanup (const char *cause, bool make_core) |
516 | { |
533 | { |
|
|
534 | LOG (llevError, "cleanup cause: %s\n", cause); |
|
|
535 | |
|
|
536 | if (!make_core) |
|
|
537 | cleanup_inform (cause, make_core); |
|
|
538 | |
517 | LOG (llevDebug, "cleanup begin.\n"); |
539 | LOG (llevDebug, "cleanup begin.\n"); |
518 | |
540 | |
519 | if (init_done && !in_cleanup) |
541 | if (init_done && !in_cleanup) |
520 | { |
542 | { |
521 | in_cleanup = true; |
543 | in_cleanup = true; |
… | |
… | |
528 | INVOKE_GLOBAL (CLEANUP); |
550 | INVOKE_GLOBAL (CLEANUP); |
529 | |
551 | |
530 | LOG (llevDebug, "cleanup done.\n"); |
552 | LOG (llevDebug, "cleanup done.\n"); |
531 | |
553 | |
532 | if (make_core) |
554 | if (make_core) |
|
|
555 | { |
|
|
556 | cleanup_inform (cause, make_core); |
533 | abort (); |
557 | abort (); |
|
|
558 | } |
534 | else |
559 | else |
535 | _exit (0); |
560 | _exit (0); |
536 | } |
561 | } |
537 | |
562 | |
538 | int |
563 | int |
… | |
… | |
652 | |
677 | |
653 | initPlugins (); |
678 | initPlugins (); |
654 | |
679 | |
655 | for (;;) |
680 | for (;;) |
656 | cfperl_main (); |
681 | cfperl_main (); |
657 | |
|
|
658 | cleanup (true); |
|
|
659 | } |
682 | } |
660 | |
683 | |