Exemplo n.º 1
0
void
do_off(void)
{
	if (debug_mode == 1) {
		cl_log(LOG_ERR, "Request to power-off changed to kdump due to DEBUG MODE!");
		watchdog_close();
		sysrq_trigger('c');
		exit(0);
	} else 	if (debug_mode == 2) {
		cl_log(LOG_ERR, "Skipping request to power-off due to DEBUG MODE!");
		watchdog_close();
		exit(0);
	} else if (debug_mode == 3) {
		/* The idea is to give the system some time to flush
		 * logs to disk before rebooting. */
		cl_log(LOG_ERR, "Delaying request to power-off by 10s due to DEBUG MODE!");
		watchdog_close();
		sync();
		sync();
		sleep(10);
		cl_log(LOG_ERR, "Debug mode is now becoming real ...");
	}
	sysrq_trigger('o');
	cl_reboot(5, "sbd is self-fencing (power-off)");
	sleep(timeout_watchdog * 2);
	exit(1);
}
Exemplo n.º 2
0
int main(int argc, char *argv[]) {
        usec_t t;
        unsigned i, count;
        int r;
        bool slow;

        log_set_max_level(LOG_DEBUG);
        log_parse_environment();

        r = getenv_bool("SYSTEMD_SLOW_TESTS");
        slow = r >= 0 ? r : SYSTEMD_SLOW_TESTS_DEFAULT;

        t = slow ? 10 * USEC_PER_SEC : 1 * USEC_PER_SEC;
        count = slow ? 5 : 3;

        r = watchdog_set_timeout(&t);
        if (r < 0)
                log_warning_errno(r, "Failed to open watchdog: %m");
        if (r == -EPERM)
                t = 0;

        for (i = 0; i < count; i++) {
                log_info("Pinging...");
                r = watchdog_ping();
                if (r < 0)
                        log_warning_errno(r, "Failed to ping watchdog: %m");

                usleep(t/2);
        }

        watchdog_close(true);
        return 0;
}
Exemplo n.º 3
0
/**
 * close onet layer
 */
void onet_closelay( void )
{
	onet_t	*onet	= onet_main;
	GList	*elem;
	// close all tunnel
	while( (elem = onet->tunnel_list) ){
		onet_tunnel_t	*tunnel = elem->data;
		onet_tunnel_close( tunnel );
	}
	// close all pending ns_req_dst_iaddr
	while( (elem = onet->ns_req_dst_iaddr_list) ){
		onet_ns_req_dst_iaddr_t	*ns_req_dst_iaddr = elem->data;
		onet_ns_req_dst_iaddr_del( ns_req_dst_iaddr );
	}
	// close the iaddr_log_client if it is still running
	if( ip_addr_is_null(&onet->ip_iaddr) ){
		iaddr_log_client_close( &onet->iaddr_log_client );
	}else{
		// delete the handler in httpd
		httpd_handler_del_by_path( "/neoip_router" );		
		// vdev_unregister_callback( vdev, onet_vdev_in );
		vdev_close( &onet->vdev );
		// stop responder
		resp_stop(onet->resp);
		// stop the dnsgrab layer	
		if( prop_get_bool_dfl( "neoip_router", "debug:dnsgrab", 1) ){
			dnsgrab_stop();
			watchdog_close();
		}
	}
	// open the dst_iaddr_negcache
	dst_iaddr_negcache_close( onet->dst_iaddr_negcache );
	// free the memory
	nipmem_free( onet );
	onet_main = NULL;
}
Exemplo n.º 4
0
int main(int argc, char *argv[]) {
        usec_t t = 10 * USEC_PER_SEC;
        unsigned i;
        int r;

        log_set_max_level(LOG_DEBUG);
        log_parse_environment();

        r = watchdog_set_timeout(&t);
        if (r < 0)
                log_warning_errno(r, "Failed to open watchdog: %m");

        for (i = 0; i < 5; i++) {
                log_info("Pinging...");
                r = watchdog_ping();
                if (r < 0)
                        log_warning_errno(r, "Failed to ping watchdog: %m");

                usleep(t/2);
        }

        watchdog_close(true);
        return 0;
}
Exemplo n.º 5
0
static void
do_exit(char kind) 
{
    /* TODO: Turn debug_mode into a bit field? Delay + kdump for example */
    const char *reason = NULL;

    if (kind == 'c') {
        cl_log(LOG_NOTICE, "Initiating kdump");

    } else if (debug_mode == 1) {
        cl_log(LOG_WARNING, "Initiating kdump instead of panicing the node (debug mode)");
        kind = 'c';
    }

    if (debug_mode == 2) {
        cl_log(LOG_WARNING, "Shutting down SBD instead of panicing the node (debug mode)");
        watchdog_close(true);
        exit(0);
    }

    if (debug_mode == 3) {
        /* Give the system some time to flush logs to disk before rebooting. */
        cl_log(LOG_WARNING, "Delaying node panic by 10s (debug mode)");

        watchdog_close(true);
        sync();

        sleep(10);
    }

    switch(kind) {
        case 'b':
            reason = "reboot";
            break;
        case 'c':
            reason = "crashdump";
            break;
        case 'o':
            reason = "off";
            break;
        default:
            reason = "unknown";
            break;
    }

    cl_log(LOG_EMERG, "Rebooting system: %s", reason);
    sync();

    if(kind == 'c') {
        watchdog_close(true);
        sysrq_trigger(kind);

    } else {
        watchdog_close(false);
        sysrq_trigger(kind);
        if(reboot(RB_AUTOBOOT) < 0) {
            cl_perror("Reboot failed");
        }
    }

    exit(1);
}