using namespace std;
Updater::Ptr updater;
-volatile bool is_online = false;
-volatile bool webcheck_enabled = false;
volatile bool need_config_reload = false;
volatile bool exit_now = false;
+volatile bool caught_sig_usr1 = false;
+volatile bool caught_sig_usr2 = false;
+volatile bool caught_sig_rtmin1 = false;
+
/**
* Checks if a bpdyndnsd process is already running.
* @param updater Shared Pointer to updater, needed for logging.
*/
void switch_to_offline(int param)
{
- updater->get_logger()->print_caught_siguser1();
- is_online = false;
+ caught_sig_usr1 = true;
} /*lint !e715 */
*/
void switch_to_online(int param)
{
- updater->get_logger()->print_caught_siguser2();
- is_online = true;
- webcheck_enabled = false;
+ caught_sig_usr2 = true;
} /*lint !e715 */
*/
void switch_to_online_webcheck(int param)
{
- updater->get_logger()->print_caught_sigrtmin();
- is_online = true;
- webcheck_enabled = true;
+ caught_sig_rtmin1 = true;
} /*lint !e715 */
return -1;
// Should we start in offline mode?
- is_online = !updater->get_config()->get_start_offline();
- webcheck_enabled = updater->get_config()->get_webcheck_enabled();
+ bool is_online = !updater->get_config()->get_start_offline();
+ bool webcheck_enabled = updater->get_config()->get_webcheck_enabled();
// One shot run if daemon mode is disabled
if (updater->get_config()->get_daemon_mode() != 1)
// service processing starts here
do
{
+ // Signal processing
+ if (caught_sig_usr1)
+ {
+ caught_sig_usr1 = false;
+ updater->get_logger()->print_caught_siguser1();
+
+ // Go offline
+ is_online = false;
+ } else if (caught_sig_usr2)
+ {
+ caught_sig_usr2 = false;
+ updater->get_logger()->print_caught_siguser2();
+
+ // Go online
+ is_online = true;
+ webcheck_enabled = false;
+ } else if (caught_sig_rtmin1)
+ {
+ caught_sig_rtmin1 = false;
+ updater->get_logger()->print_caught_sigrtmin();
+
+ // Go online - with webcheck
+ is_online = true;
+ webcheck_enabled = true;
+ }
+
+ // State handling
if ( is_online == true )
{
// Check if webcheck_enabled differs due to caught singnal then set it in config correspondingly