/*
- * Copyright (c) 2015-2016 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
};
enum qdevice_tool_exit_code {
- QDEVICE_TOOL_EXIT_CODE_NO_ERROR = 0,
+ QDEVICE_TOOL_EXIT_CODE_NO_ERROR = EXIT_SUCCESS,
QDEVICE_TOOL_EXIT_CODE_USAGE = 1,
QDEVICE_TOOL_EXIT_CODE_INTERNAL_ERROR = 2,
QDEVICE_TOOL_EXIT_CODE_SOCKET_CONNECT = 3,
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
dynar_init(&dynar_long_opt, strlen(long_opt) + 1);
if (dynar_str_cpy(&dynar_long_opt, long_opt) != 0) {
- errx(1, "Can't alloc memory for long option");
+ errx(EXIT_FAILURE, "Can't alloc memory for long option");
}
dynar_getopt_lex_init(&lex, &dynar_long_opt);
res = qdevice_advanced_settings_set(advanced_settings, opt, val);
switch (res) {
case -1:
- errx(1, "Unknown option '%s'", opt);
+ errx(EXIT_FAILURE, "Unknown option '%s'", opt);
break;
case -2:
- errx(1, "Invalid value '%s' for option '%s'", val, opt);
+ errx(EXIT_FAILURE, "Invalid value '%s' for option '%s'", val, opt);
break;
}
}
case 'h':
case '?':
usage();
- exit(1);
+ exit(EXIT_FAILURE);
break;
}
}
int model_run_res;
if (qdevice_advanced_settings_init(&advanced_settings) != 0) {
- errx(1, "Can't alloc memory for advanced settings");
+ errx(EXIT_FAILURE, "Can't alloc memory for advanced settings");
}
cli_parse(argc, argv, &foreground, &force_debug, &bump_log_priority, &advanced_settings);
qdevice_cmap_init(&instance);
if (qdevice_log_init(&instance, foreground, force_debug, bump_log_priority) == -1) {
- errx(1, "Can't initialize logging");
+ errx(EXIT_FAILURE, "Can't initialize logging");
}
/*
log_err(LOG_ERR, "Can't acquire lock");
}
- exit(1);
+ return (EXIT_FAILURE);
}
log(LOG_DEBUG, "Initializing votequorum");
log(LOG_DEBUG, "Initializing local socket");
if (qdevice_ipc_init(&instance) != 0) {
- return (1);
+ return (EXIT_FAILURE);
}
log(LOG_DEBUG, "Registering qdevice models");
log(LOG_DEBUG, "Configuring qdevice");
if (qdevice_instance_configure_from_cmap(&instance) != 0) {
- return (1);
+ return (EXIT_FAILURE);
}
log(LOG_DEBUG, "Configuring master_wins");
if (qdevice_votequorum_master_wins(&instance, (advanced_settings.master_wins ==
QDEVICE_ADVANCED_SETTINGS_MASTER_WINS_FORCE_ON ? 1 : 0)) != 0) {
- return (1);
+ return (EXIT_FAILURE);
}
log(LOG_DEBUG, "Getting configuration node list");
if (qdevice_cmap_store_config_node_list(&instance) != 0) {
- return (1);
+ return (EXIT_FAILURE);
}
log(LOG_DEBUG, "Initializing qdevice model");
if (qdevice_model_init(&instance) != 0) {
- return (1);
+ return (EXIT_FAILURE);
}
log(LOG_DEBUG, "Initializing cmap tracking");
if (qdevice_cmap_add_track(&instance) != 0) {
- return (1);
+ return (EXIT_FAILURE);
}
log(LOG_DEBUG, "Waiting for ring id");
if (qdevice_votequorum_wait_for_ring_id(&instance) != 0) {
- return (1);
+ return (EXIT_FAILURE);
}
log(LOG_DEBUG, "Waiting for initial heuristics exec result");
if (qdevice_heuristics_wait_for_initial_exec_result(&instance.heuristics_instance) != 0) {
- return (1);
+ return (EXIT_FAILURE);
}
global_instance = &instance;
qdevice_advanced_settings_destroy(&advanced_settings);
- return (model_run_res == 0 ? 0 : 2);
+ return (model_run_res == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
/*
- * Copyright (c) 2015-2016 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
};
enum qnetd_tool_exit_code {
- QNETD_TOOL_EXIT_CODE_NO_ERROR = 0,
+ QNETD_TOOL_EXIT_CODE_NO_ERROR = EXIT_SUCCESS,
QNETD_TOOL_EXIT_CODE_USAGE = 1,
QNETD_TOOL_EXIT_CODE_INTERNAL_ERROR = 2,
QNETD_TOOL_EXIT_CODE_SOCKET_CONNECT = 3,
log_nss(LOG_CRIT, "NSS error");
- exit(1);
+ exit(EXIT_FAILURE);
}
static void
dynar_init(&dynar_long_opt, strlen(long_opt) + 1);
if (dynar_str_cpy(&dynar_long_opt, long_opt) != 0) {
- errx(1, "Can't alloc memory for long option");
+ errx(EXIT_FAILURE, "Can't alloc memory for long option");
}
dynar_getopt_lex_init(&lex, &dynar_long_opt);
res = qnetd_advanced_settings_set(advanced_settings, opt, val);
switch (res) {
case -1:
- errx(1, "Unknown option '%s'", opt);
+ errx(EXIT_FAILURE, "Unknown option '%s'", opt);
break;
case -2:
- errx(1, "Invalid value '%s' for option '%s'", val, opt);
+ errx(EXIT_FAILURE, "Invalid value '%s' for option '%s'", val, opt);
break;
}
}
break;
case 'c':
if ((*client_cert_required = utils_parse_bool_str(optarg)) == -1) {
- errx(1, "client_cert_required should be on/yes/1, off/no/0");
+ errx(EXIT_FAILURE, "client_cert_required should be on/yes/1, off/no/0");
}
break;
case 'l':
free(*host_addr);
*host_addr = strdup(optarg);
if (*host_addr == NULL) {
- errx(1, "Can't alloc memory for host addr string");
+ errx(EXIT_FAILURE, "Can't alloc memory for host addr string");
}
break;
case 'm':
if (utils_strtonum(optarg, 0, LLONG_MAX, &tmpll) == -1) {
- errx(1, "max clients value %s is invalid", optarg);
+ errx(EXIT_FAILURE, "max clients value %s is invalid", optarg);
}
*max_clients = (size_t)tmpll;
break;
case 'p':
if (utils_strtonum(optarg, 1, UINT16_MAX, &tmpll) == -1) {
- errx(1, "host port must be in range 1-%u", UINT16_MAX);
+ errx(EXIT_FAILURE, "host port must be in range 1-%u", UINT16_MAX);
}
*host_port = tmpll;
} else if (strcasecmp(optarg, "req") == 0) {
*tls_supported = TLV_TLS_REQUIRED;
} else {
- errx(1, "tls must be one of on, off, req");
+ errx(EXIT_FAILURE, "tls must be one of on, off, req");
}
break;
case 'v':
display_version();
- exit(1);
+ exit(EXIT_FAILURE);
break;
case 'h':
case '?':
usage();
- exit(1);
+ exit(EXIT_FAILURE);
break;
}
}
int poll_res;
if (qnetd_advanced_settings_init(&advanced_settings) != 0) {
- errx(1, "Can't alloc memory for advanced settings");
+ errx(EXIT_FAILURE, "Can't alloc memory for advanced settings");
}
cli_parse(argc, argv, &host_addr, &host_port, &foreground, &debug_log, &bump_log_priority,
}
if (log_init(QNETD_PROGRAM_NAME, log_target, LOG_DAEMON) == -1) {
- errx(1, "Can't initialize logging");
+ errx(EXIT_FAILURE, "Can't initialize logging");
}
log_set_debug(debug_log);
advanced_settings.nss_db_dir : NULL)) != 0) {
log_err(LOG_ERR, "Can't open NSS DB directory");
- return (1);
+ return (EXIT_FAILURE);
}
/*
log_err(LOG_ERR, "Can't acquire lock");
}
- return (1);
+ return (EXIT_FAILURE);
}
log(LOG_DEBUG, "Initializing nss");
if (qnetd_instance_init(&instance, tls_supported, client_cert_required,
max_clients, &advanced_settings) == -1) {
log(LOG_ERR, "Can't initialize qnetd");
- return (1);
+ return (EXIT_FAILURE);
}
instance.host_addr = host_addr;
instance.host_port = host_port;
log(LOG_DEBUG, "Initializing local socket");
if (qnetd_ipc_init(&instance) != 0) {
- return (1);
+ return (EXIT_FAILURE);
}
log(LOG_DEBUG, "Creating listening socket");
&instance, NULL) != 0) {
log(LOG_ERR, "Can't add server socket to main poll loop");
- return (1);
+ return (EXIT_FAILURE);
}
global_instance = &instance;
log(LOG_DEBUG, "Registering algorithms");
if (qnetd_algorithm_register_all() != 0) {
- return (1);
+ return (EXIT_FAILURE);
}
log(LOG_DEBUG, "QNetd ready to provide service");
if (poll_res == -2) {
log(LOG_CRIT, "pr_poll_loop_exec returned -2 - internal error");
- return (1);
+ return (EXIT_FAILURE);
}
/*
log(LOG_DEBUG, "Closing log");
log_close();
- return (0);
+ return (EXIT_SUCCESS);
}
/*
- * Copyright (c) 2015-2016 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
devnull = open("/dev/null", O_RDWR);
if (devnull == -1) {
- err(1, "Can't open /dev/null");
+ err(EXIT_FAILURE, "Can't open /dev/null");
}
if (dup2(devnull, 0) < 0 || dup2(devnull, 1) < 0 || dup2(devnull, 2) < 0) {
close(devnull);
- err(1, "Can't dup2 stdin/out/err to /dev/null");
+ err(EXIT_FAILURE, "Can't dup2 stdin/out/err to /dev/null");
}
close(devnull);
/*
* Exec returned -> exec failed
*/
- err(1, "Can't execute command %s (%s)", entry->name, entry->exec_argv[0]);
+ err(EXIT_FAILURE, "Can't execute command %s (%s)", entry->name, entry->exec_argv[0]);
} else {
entry->pid = pid;
entry->state = PROCESS_LIST_ENTRY_STATE_RUNNING;
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
}
if (res != CS_OK) {
- errx(1, "Failed to initialize the cmap API. Error %s", cs_strerror(res));
+ errx(EXIT_FAILURE, "Failed to initialize the cmap API. Error %s", cs_strerror(res));
}
if ((res = cmap_context_set(instance->cmap_handle, (void *)instance)) != CS_OK) {
- errx(1, "Can't set cmap context. Error %s", cs_strerror(res));
+ errx(EXIT_FAILURE, "Can't set cmap context. Error %s", cs_strerror(res));
}
cmap_fd_get(instance->cmap_handle, &instance->cmap_poll_fd);
if (qdevice_model_get_config_node_list_failed(instance) != 0) {
log(LOG_DEBUG, "qdevice_model_get_config_node_list_failed returned error -> exit");
- exit(2);
+ exit(EXIT_FAILURE);
}
return ;
if (qdevice_model_config_node_list_changed(instance, &nlist,
config_version_set, config_version) != 0) {
log(LOG_DEBUG, "qdevice_model_config_node_list_changed returned error -> exit");
- exit(2);
+ exit(EXIT_FAILURE);
}
node_list_free(&instance->config_node_list);
if (qdevice_model_get_config_node_list_failed(instance) != 0) {
log(LOG_DEBUG, "qdevice_model_get_config_node_list_failed returned error -> exit");
- exit(2);
+ exit(EXIT_FAILURE);
}
return ;
log(LOG_DEBUG, "Heuristics configuration possibly changed");
if (qdevice_instance_configure_from_cmap_heuristics(instance) != 0) {
log(LOG_DEBUG, "qdevice_instance_configure_from_cmap_heuristics returned error -> exit");
- exit(2);
+ exit(EXIT_FAILURE);
}
}
if (cmap_context_get(cmap_handle, (const void **)&instance) != CS_OK) {
log(LOG_ERR, "Fatal error. Can't get cmap context");
- exit(1);
+ exit(EXIT_FAILURE);
}
/*
*/
if (qdevice_model_cmap_changed(instance, &events) != 0) {
log(LOG_DEBUG, "qdevice_model_cmap_changed returned error -> exit");
- exit(2);
+ exit(EXIT_FAILURE);
}
}
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
pid_t pid;
if (pipe(pipe_cmd_in) != 0) {
- err(1, "Can't create command input pipe");
+ err(EXIT_FAILURE, "Can't create command input pipe");
}
if (pipe(pipe_cmd_out) != 0) {
- err(1, "Can't create command output pipe");
+ err(EXIT_FAILURE, "Can't create command output pipe");
}
if (pipe(pipe_log_out) != 0) {
- err(1, "Can't create logging output pipe");
+ err(EXIT_FAILURE, "Can't create logging output pipe");
}
pid = fork();
if (pid == -1) {
- err(1, "Can't create child process");
+ err(EXIT_FAILURE, "Can't create child process");
} else if (pid == 0) {
/*
* Child
*/
(void)setsid();
if (dup2(pipe_cmd_in[0], 0) == -1) {
- err(1, "Can't dup2 command input pipe");
+ err(EXIT_FAILURE, "Can't dup2 command input pipe");
}
close(pipe_cmd_in[1]);
close(pipe_cmd_in[0]);
if (utils_fd_set_non_blocking(0) == -1) {
- err(1, "Can't set non blocking flag on command input pipe");
+ err(EXIT_FAILURE, "Can't set non blocking flag on command input pipe");
}
if (dup2(pipe_cmd_out[1], 1) == -1) {
- err(1, "Can't dup2 command output pipe");
+ err(EXIT_FAILURE, "Can't dup2 command output pipe");
}
close(pipe_cmd_out[0]);
close(pipe_cmd_out[1]);
if (dup2(pipe_log_out[1], 2) == -1) {
- err(1, "Can't dup2 logging output pipe");
+ err(EXIT_FAILURE, "Can't dup2 logging output pipe");
}
close(pipe_log_out[0]);
close(pipe_log_out[1]);
qdevice_advanced_settings_destroy(advanced_settings);
- exit(0);
+ exit(EXIT_SUCCESS);
} else {
close(pipe_cmd_in[0]);
close(pipe_cmd_out[1]);
instance->pipe_cmd_send = pipe_cmd_in[1];
if (utils_fd_set_non_blocking(instance->pipe_cmd_send) == -1) {
- err(1, "Can't set non blocking flag on command input pipe");
+ err(EXIT_FAILURE, "Can't set non blocking flag on command input pipe");
}
instance->pipe_cmd_recv = pipe_cmd_out[0];
if (utils_fd_set_non_blocking(instance->pipe_cmd_recv) == -1) {
- err(1, "Can't set non blocking flag on command output pipe");
+ err(EXIT_FAILURE, "Can't set non blocking flag on command output pipe");
}
instance->pipe_log_recv = pipe_log_out[0];
if (utils_fd_set_non_blocking(instance->pipe_cmd_recv) == -1) {
- err(1, "Can't set non blocking flag on logging output pipe");
+ err(EXIT_FAILURE, "Can't set non blocking flag on logging output pipe");
}
instance->worker_pid = pid;
if (!case_processed) {
log(LOG_CRIT, "Unhandled read on poll descriptor %u", i);
- exit(1);
+ exit(EXIT_FAILURE);
}
}
if (!case_processed) {
log(LOG_CRIT, "Unhandled write on poll descriptor %u", i);
- exit(1);
+ exit(EXIT_FAILURE);
}
}
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
} else {
log(LOG_CRIT, "Undefined heuristics mode");
- exit(1);
+ exit(EXIT_FAILURE);
}
if (send_exec_list) {
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
default:
log(LOG_ERR, "qdevice_ipc_cmd_vq_nodestate_to_str: Unhandled votequorum "
"node state %"PRIu32, state);
- exit(1);
+ exit(EXIT_FAILURE);
break;
}
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
if (instance->model_type >= QDEVICE_MODEL_TYPE_ARRAY_SIZE ||
qdevice_model_array[instance->model_type] == NULL) {
log(LOG_CRIT, "qdevice_model_init unhandled model");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_model_array[instance->model_type]->init(instance));
if (instance->model_type >= QDEVICE_MODEL_TYPE_ARRAY_SIZE ||
qdevice_model_array[instance->model_type] == NULL) {
log(LOG_CRIT, "qdevice_model_destroy unhandled model");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_model_array[instance->model_type]->destroy(instance));
if (instance->model_type >= QDEVICE_MODEL_TYPE_ARRAY_SIZE ||
qdevice_model_array[instance->model_type] == NULL) {
log(LOG_CRIT, "qdevice_model_run unhandled model");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_model_array[instance->model_type]->run(instance));
if (instance->model_type >= QDEVICE_MODEL_TYPE_ARRAY_SIZE ||
qdevice_model_array[instance->model_type] == NULL) {
log(LOG_CRIT, "qdevice_model_run unhandled model");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_model_array[instance->model_type]->get_config_node_list_failed(instance));
if (instance->model_type >= QDEVICE_MODEL_TYPE_ARRAY_SIZE ||
qdevice_model_array[instance->model_type] == NULL) {
log(LOG_CRIT, "qdevice_model_run unhandled model");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_model_array[instance->model_type]->
if (instance->model_type >= QDEVICE_MODEL_TYPE_ARRAY_SIZE ||
qdevice_model_array[instance->model_type] == NULL) {
log(LOG_CRIT, "qdevice_model_votequorum_quorum_notify unhandled model");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_model_array[instance->model_type]->
if (instance->model_type >= QDEVICE_MODEL_TYPE_ARRAY_SIZE ||
qdevice_model_array[instance->model_type] == NULL) {
log(LOG_CRIT, "qdevice_model_votequorum_node_list_notify unhandled model");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_model_array[instance->model_type]->
if (instance->model_type >= QDEVICE_MODEL_TYPE_ARRAY_SIZE ||
qdevice_model_array[instance->model_type] == NULL) {
log(LOG_CRIT, "qdevice_model_votequorum_node_list_heuristics_notify unhandled model");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_model_array[instance->model_type]->
if (instance->model_type >= QDEVICE_MODEL_TYPE_ARRAY_SIZE ||
qdevice_model_array[instance->model_type] == NULL) {
log(LOG_CRIT, "qdevice_model_votequorum_expected_votes_notify unhandled model");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_model_array[instance->model_type]->
if (instance->model_type >= QDEVICE_MODEL_TYPE_ARRAY_SIZE ||
qdevice_model_array[instance->model_type] == NULL) {
log(LOG_CRIT, "qdevice_model_ipc_cmd_status unhandled model");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_model_array[instance->model_type]->
if (instance->model_type >= QDEVICE_MODEL_TYPE_ARRAY_SIZE ||
qdevice_model_array[instance->model_type] == NULL) {
log(LOG_CRIT, "qdevice_model_cmap_chaged unhandled model");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_model_array[instance->model_type]->
if (qdevice_model_net_register() != 0) {
log(LOG_CRIT, "Failed to register model 'net' ");
- exit(1);
+ exit(EXIT_FAILURE);
}
}
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
if (instance->decision_algorithm >= QDEVICE_NET_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_init unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->init(instance));
if (instance->decision_algorithm >= QDEVICE_NET_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_connected unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->connected(instance,
if (instance->decision_algorithm >= QDEVICE_NET_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_connected unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_votequorum_node_list_notify "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->votequorum_node_list_notify(
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_votequorum_node_list_heuristics_notify "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_votequorum_quorum_notify "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_votequorum_expected_votes_notify "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_config_node_list_reply_received "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_membership_node_list_reply_received "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_quorum_node_list_reply_received "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_ask_for_vote_reply_received "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_vote_info_received "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_echo_reply_received "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_echo_reply_not_received "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_heuristics_change "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_heuristics_change_reply_received "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_disconnected "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
qdevice_net_algorithm_array[instance->decision_algorithm] == NULL) {
log(LOG_CRIT, "qdevice_net_algorithm_destroy "
"unhandled decision algorithm");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (qdevice_net_algorithm_array[instance->decision_algorithm]->
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
if (!case_processed) {
log(LOG_CRIT, "qdevice_net_timer_cast_vote: Unhandled cast_vote_timer_vote %u\n",
instance->cast_vote_timer_vote);
- exit(1);
+ exit(EXIT_FAILURE);
}
if (qdevice_votequorum_poll(instance->qdevice_instance_ptr, cast_vote) != 0) {
if (!case_processed) {
log(LOG_CRIT, "qdevice_net_cast_vote_timer_update_vote: Unhandled vote parameter %u\n",
vote);
- exit(1);
+ exit(EXIT_FAILURE);
}
instance->cast_vote_timer_vote = vote;
/*
- * Copyright (c) 2017-2019 Red Hat, Inc.
+ * Copyright (c) 2017-2020 Red Hat, Inc.
*
* All rights reserved.
*
log(LOG_ERR, "qdevice_net_heuristics_exec_result_to_tlv: Unhandled "
"heuristics exec result %s",
qdevice_heuristics_exec_result_to_str(exec_result));
- exit(1);
+ exit(EXIT_FAILURE);
break;
}
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
if (str == NULL) {
log(LOG_CRIT, "qdevice_net_msg_received_node_list_reply fatal error. "
"Unhandled node_list_type (debug output)");
- exit(1);
+ exit(EXIT_FAILURE);
}
log(LOG_DEBUG, "Received %s node list reply", str);
if (!case_processed) {
log(LOG_CRIT, "qdevice_net_msg_received_node_list_reply fatal error. "
"Unhandled node_list_type (algorithm call)");
- exit(1);
+ exit(EXIT_FAILURE);
}
if (res != 0) {
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
}
} else {
log(LOG_CRIT, "Unhandled nss_sock_non_blocking_client_succeeded");
- exit(1);
+ exit(EXIT_FAILURE);
}
} else {
if (qdevice_net_socket_write(instance) == -1) {
if (!case_processed) {
log(LOG_CRIT, "Unhandled read on poll descriptor %zu", i);
- exit(1);
+ exit(EXIT_FAILURE);
}
}
if (!case_processed) {
log(LOG_CRIT, "Unhandled write on poll descriptor %zu", i);
- exit(1);
+ exit(EXIT_FAILURE);
}
}
if (pfds[i].out_flags != PR_POLL_NVAL) {
log(LOG_CRIT, "POLLERR (%u) on local socket",
pfds[i].out_flags);
- exit(1);
+ exit(EXIT_FAILURE);
} else {
log(LOG_DEBUG, "Local socket is closed");
instance->schedule_disconnect = 1;
if (!case_processed) {
log(LOG_CRIT, "Unhandled error on poll descriptor %zu", i);
- exit(1);
+ exit(EXIT_FAILURE);
}
}
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
}
} else {
log(LOG_CRIT, "net_socket_read in skipping msg state");
- exit(1);
+ exit(EXIT_FAILURE);
}
instance->skipping_msg = 0;
break;
default:
log(LOG_CRIT, "qdevice_net_socket_read unhandled error %d", res);
- exit(1);
+ exit(EXIT_FAILURE);
break;
}
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
default:
log(LOG_ERR, "qdevice_net_votequorum_node_state_to_tlv: Unhandled votequorum "
"node state %"PRIu32, votequorum_node_state);
- exit(1);
+ exit(EXIT_FAILURE);
break;
}
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
if (votequorum_context_get(votequorum_handle, (void **)&instance) != CS_OK) {
log(LOG_CRIT, "Fatal error. Can't get votequorum context");
- exit(1);
+ exit(EXIT_FAILURE);
}
instance->sync_in_progress = 0;
if (qdevice_model_votequorum_quorum_notify(instance, quorate, node_list_entries,
node_list) != 0) {
log(LOG_DEBUG, "qdevice_model_votequorum_quorum_notify returned error -> exit");
- exit(2);
+ exit(EXIT_FAILURE);
}
instance->vq_quorum_quorate = quorate;
instance->vq_quorum_node_list = malloc(sizeof(*node_list) * node_list_entries);
if (instance->vq_quorum_node_list == NULL) {
log(LOG_CRIT, "Can't alloc votequorum node list memory");
- exit(1);
+ exit(EXIT_FAILURE);
}
memcpy(instance->vq_quorum_node_list, node_list, sizeof(*node_list) * node_list_entries);
}
&instance->heuristics_instance.exec_result_notifier_list,
qdevice_votequorum_heuristics_exec_result_callback, 0) != 0) {
log(LOG_CRIT, "Can't deactivate votequrorum heuristics exec callback notifier");
- exit(2);
+ exit(EXIT_FAILURE);
}
log(LOG_DEBUG, "Votequorum heuristics exec result callback:");
if (qdevice_model_votequorum_node_list_heuristics_notify(instance, instance->vq_node_list_ring_id,
instance->vq_node_list_entries, instance->vq_node_list, exec_result) != 0) {
log(LOG_DEBUG, "qdevice_votequorum_node_list_heuristics_notify_callback returned error -> exit");
- exit(2);
+ exit(EXIT_FAILURE);
}
instance->vq_node_list_initial_heuristics_finished = 1;
if (votequorum_context_get(votequorum_handle, (void **)&instance) != CS_OK) {
log(LOG_CRIT, "Fatal error. Can't get votequorum context");
- exit(1);
+ exit(EXIT_FAILURE);
}
instance->sync_in_progress = 1;
if (qdevice_model_votequorum_node_list_notify(instance, votequorum_ring_id, node_list_entries,
node_list) != 0) {
log(LOG_DEBUG, "qdevice_votequorum_node_list_notify_callback returned error -> exit");
- exit(2);
+ exit(EXIT_FAILURE);
}
if (qdevice_heuristics_result_notifier_list_set_active(
&instance->heuristics_instance.exec_result_notifier_list,
qdevice_votequorum_heuristics_exec_result_callback, 1) != 0) {
log(LOG_CRIT, "Can't activate votequrorum heuristics exec callback notifier");
- exit(2);
+ exit(EXIT_FAILURE);
}
if (qdevice_heuristics_exec(&instance->heuristics_instance, instance->sync_in_progress) != 0) {
log(LOG_CRIT, "Can't start heuristics -> exit");
- exit(2);
+ exit(EXIT_FAILURE);
}
instance->vq_node_list_initial_ring_id_set = 1;
instance->vq_node_list = malloc(sizeof(*node_list) * node_list_entries);
if (instance->vq_node_list == NULL) {
log(LOG_CRIT, "Can't alloc votequorum node list memory");
- exit(1);
+ exit(EXIT_FAILURE);
}
memcpy(instance->vq_node_list, node_list, sizeof(*node_list) * node_list_entries);
}
if (votequorum_context_get(votequorum_handle, (void **)&instance) != CS_OK) {
log(LOG_CRIT, "Fatal error. Can't get votequorum context");
- exit(1);
+ exit(EXIT_FAILURE);
}
log(LOG_DEBUG, "Votequorum expected_votes notify callback:");
if (qdevice_model_votequorum_expected_votes_notify(instance, expected_votes) != 0) {
log(LOG_DEBUG, "qdevice_votequorum_expected_votes_notify_callback returned error -> exit");
- exit(2);
+ exit(EXIT_FAILURE);
}
instance->vq_expected_votes = expected_votes;
if (res != CS_OK) {
log(LOG_CRIT, "Failed to initialize the votequorum API. Error %s", cs_strerror(res));
- exit(1);
+ exit(EXIT_FAILURE);
}
if ((res = votequorum_qdevice_register(votequorum_handle,
instance->advanced_settings->votequorum_device_name)) != CS_OK) {
log(LOG_CRIT, "Can't register votequorum device. Error %s", cs_strerror(res));
- exit(1);
+ exit(EXIT_FAILURE);
}
if ((res = votequorum_context_set(votequorum_handle, (void *)instance)) != CS_OK) {
log(LOG_CRIT, "Can't set votequorum context. Error %s", cs_strerror(res));
- exit(1);
+ exit(EXIT_FAILURE);
}
if ((res = votequorum_getinfo(votequorum_handle, VOTEQUORUM_QDEVICE_NODEID,
&vq_info)) != CS_OK) {
log(LOG_CRIT, "Can't get votequorum information. Error %s", cs_strerror(res));
- exit(1);
+ exit(EXIT_FAILURE);
}
instance->vq_expected_votes = vq_info.node_expected_votes;
CS_TRACK_CHANGES)) != CS_OK) {
log(LOG_CRIT, "Can't start tracking votequorum changes. Error %s",
cs_strerror(res));
- exit(1);
+ exit(EXIT_FAILURE);
}
if (qdevice_heuristics_result_notifier_list_add(&instance->heuristics_instance.exec_result_notifier_list,
qdevice_votequorum_heuristics_exec_result_callback) == NULL) {
log(LOG_CRIT, "Can't add votequrorum heuristics exec callback into notifier");
- exit(1);
+ exit(EXIT_FAILURE);
}
}
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
if (!case_processed) {
log(LOG_CRIT, "qnetd_algo_ffsplit_is_preferred_partition unprocessed "
"tie_breaker.mode");
- exit(1);
+ exit(EXIT_FAILURE);
}
return (node_list_find_node_id(membership_node_list, preferred_node_id) != NULL);
exit_res:
if (res == -1) {
log(LOG_CRIT, "qnetd_algo_ffsplit_partition_cmp unhandled case");
- exit(1);
+ exit(EXIT_FAILURE);
/* NOTREACHED */
}
/*
- * Copyright (c) 2015-2019 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
if (!case_processed) {
log(LOG_ERR, "Unhandled instance tls supported %u", instance->tls_supported);
- exit(1);
+ exit(EXIT_FAILURE);
}
if (tls_required && !client->tls_started) {
if (!case_processed) {
log(LOG_ERR, "qnetd_client_msg_received_node_list fatal error. "
"Unhandled node_list_type");
- exit(1);
+ exit(EXIT_FAILURE);
}
if (reply_error_code != TLV_REPLY_ERROR_CODE_NO_ERROR) {
if (!case_processed) {
log(LOG_ERR, "qnetd_client_msg_received_node_list fatal error. "
"Unhandled node_list_type");
- exit(1);
+ exit(EXIT_FAILURE);
}
/*
break;
default:
log(LOG_ERR, "Unhandled msgio_read error %d\n", res);
- exit(1);
+ exit(EXIT_FAILURE);
break;
}
/*
- * Copyright (c) 2015-2018 Red Hat, Inc.
+ * Copyright (c) 2015-2020 Red Hat, Inc.
*
* All rights reserved.
*
switch (fork()) {
case -1:
- err(1, "Can't create child process");
+ err(EXIT_FAILURE, "Can't create child process");
break;
case 0:
break;
default:
- exit(0);
+ exit(EXIT_SUCCESS);
break;
}
*/
devnull = open("/dev/null", O_RDWR);
if (devnull == -1) {
- err(1, "Can't open /dev/null");
+ err(EXIT_FAILURE, "Can't open /dev/null");
}
if (dup2(devnull, 0) < 0 || dup2(devnull, 1) < 0
|| dup2(devnull, 2) < 0) {
close(devnull);
- err(1, "Can't dup2 stdin/out/err to /dev/null");
+ err(EXIT_FAILURE, "Can't dup2 stdin/out/err to /dev/null");
}
close(devnull);
}