Exemplo n.º 1
0
static gboolean try_heartbeat(int command)
{
    crm_debug("Attempting to process %c command", command);
    
    if(command == 'i') {
	if(read_local_hb_uuid()) {
	    exit(0);
	}
	
    } else if(ccm_age_connect(&ccm_fd)) {
	int rc = 0;
	fd_set rset;	
	while (1) {
	    
	    sleep(1);
	    FD_ZERO(&rset);
	    FD_SET(ccm_fd, &rset);
	    
	    errno = 0;
	    rc = select(ccm_fd + 1, &rset, NULL,NULL,NULL);
	    
	    if(rc > 0 && oc_ev_handle_event(ccm_token) != 0) {
		crm_err("oc_ev_handle_event failed");
		exit(1);
		
	    } else if(rc < 0 && errno != EINTR) {
		crm_perror(LOG_ERR, "select failed");
		exit(1);
	    }
	    
	}
    }
    return FALSE;
}
Exemplo n.º 2
0
int
main(int argc, char **argv)
{
    int flag;
    int rc = 0;
    int index = 0;

    if (argc == 1) {
        /* no arguments specified, default to read */
        rc = read_local_hb_uuid();
        return rc;
    }

    crm_log_init(NULL, LOG_ERR, FALSE, FALSE, argc, argv);
    crm_set_options(NULL, " [-r|-w new_ascii_value]",
                    long_options, "A tool for manipulating Heartbeat's UUID file");

    while (1) {
        flag = crm_get_option(argc, argv, &index);
        if (flag == -1)
            break;

        switch (flag) {
            case '?':
            case '$':
                crm_help(flag, LSB_EXIT_OK);
                break;
            case 'r':
                rc = read_local_hb_uuid();
                break;
            case 'w':
                rc = write_local_hb_uuid(optarg);
                break;
            default:
                crm_help('?', LSB_EXIT_GENERIC);
                break;
        }
    }
    return rc;
}