|
|
@@ -34,14 +34,13 @@
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
-#include <err.h>
|
|
|
-
|
|
|
#include "qnet-config.h"
|
|
|
#include "qnetd-algorithm.h"
|
|
|
#include "qnetd-algo-test.h"
|
|
|
#include "qnetd-algo-ffsplit.h"
|
|
|
#include "qnetd-algo-2nodelms.h"
|
|
|
#include "qnetd-algo-lms.h"
|
|
|
+#include "qnetd-log.h"
|
|
|
|
|
|
static struct qnetd_algorithm *qnetd_algorithm_array[QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE];
|
|
|
|
|
|
@@ -50,8 +49,8 @@ qnetd_algorithm_client_init(struct qnetd_client *client)
|
|
|
{
|
|
|
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
|
|
|
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
|
|
|
+ qnetd_log(LOG_CRIT, "qnetd_algorithm_client_init unhandled decision algorithm");
|
|
|
|
|
|
- errx(1, "qnetd_algorithm_client_init unhandled decision algorithm");
|
|
|
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
|
|
|
}
|
|
|
|
|
|
@@ -65,8 +64,7 @@ qnetd_algorithm_config_node_list_received(struct qnetd_client *client,
|
|
|
{
|
|
|
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
|
|
|
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
|
|
|
-
|
|
|
- errx(1, "qnetd_algorithm_config_node_list_received unhandled "
|
|
|
+ qnetd_log(LOG_CRIT, "qnetd_algorithm_config_node_list_received unhandled "
|
|
|
"decision algorithm");
|
|
|
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
|
|
|
}
|
|
|
@@ -84,8 +82,7 @@ qnetd_algorithm_membership_node_list_received(struct qnetd_client *client,
|
|
|
|
|
|
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
|
|
|
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
|
|
|
-
|
|
|
- errx(1, "qnetd_algorithm_membership_node_list_received unhandled "
|
|
|
+ qnetd_log(LOG_CRIT, "qnetd_algorithm_membership_node_list_received unhandled "
|
|
|
"decision algorithm");
|
|
|
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
|
|
|
}
|
|
|
@@ -103,8 +100,7 @@ qnetd_algorithm_quorum_node_list_received(struct qnetd_client *client,
|
|
|
|
|
|
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
|
|
|
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
|
|
|
-
|
|
|
- errx(1, "qnetd_algorithm_quorum_node_list_received unhandled "
|
|
|
+ qnetd_log(LOG_CRIT, "algorithm_quorum_node_list_received unhandled "
|
|
|
"decision algorithm");
|
|
|
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
|
|
|
}
|
|
|
@@ -119,8 +115,8 @@ qnetd_algorithm_client_disconnect(struct qnetd_client *client, int server_going_
|
|
|
|
|
|
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
|
|
|
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
|
|
|
-
|
|
|
- errx(1, "qnetd_algorithm_client_disconnect unhandled decision algorithm");
|
|
|
+ qnetd_log(LOG_CRIT, "qnetd_algorithm_client_disconnect unhandled decision "
|
|
|
+ "algorithm");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -134,8 +130,8 @@ qnetd_algorithm_ask_for_vote_received(struct qnetd_client *client, uint32_t msg_
|
|
|
|
|
|
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
|
|
|
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
|
|
|
-
|
|
|
- errx(1, "qnetd_algorithm_ask_for_vote_received unhandled decision algorithm");
|
|
|
+ qnetd_log(LOG_CRIT, "qnetd_algorithm_ask_for_vote_received unhandled "
|
|
|
+ "decision algorithm");
|
|
|
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
|
|
|
}
|
|
|
|
|
|
@@ -149,7 +145,7 @@ qnetd_algorithm_vote_info_reply_received(struct qnetd_client *client, uint32_t m
|
|
|
|
|
|
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
|
|
|
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
|
|
|
- errx(1, "qnetd_algorithm_vote_info_reply_received unhandled decision algorithm");
|
|
|
+ qnetd_log(LOG_CRIT, "qnetd_algorithm_vote_info_reply_received unhandled decision algorithm");
|
|
|
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
|
|
|
}
|
|
|
|
|
|
@@ -165,7 +161,7 @@ qnetd_algorithm_timer_callback(struct qnetd_client *client, int *reschedule_time
|
|
|
|
|
|
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
|
|
|
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
|
|
|
- errx(1, "qnetd_algorithm_timer_callback unhandled decision algorithm");
|
|
|
+ qnetd_log(LOG_CRIT, "qnetd_algorithm_timer_callback unhandled decision algorithm");
|
|
|
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
|
|
|
}
|
|
|
|
|
|
@@ -173,38 +169,48 @@ qnetd_algorithm_timer_callback(struct qnetd_client *client, int *reschedule_time
|
|
|
client, reschedule_timer, send_vote, result_vote));
|
|
|
}
|
|
|
|
|
|
-enum tlv_reply_error_code
|
|
|
+int
|
|
|
qnetd_algorithm_register(enum tlv_decision_algorithm_type algorithm_number,
|
|
|
struct qnetd_algorithm *algorithm)
|
|
|
{
|
|
|
|
|
|
if (algorithm_number >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE) {
|
|
|
- return (TLV_REPLY_ERROR_CODE_UNSUPPORTED_DECISION_ALGORITHM);
|
|
|
+ qnetd_log(LOG_CRIT, "Failed to register unsupported decision algorithm %u",
|
|
|
+ algorithm_number);
|
|
|
+ return (-1);
|
|
|
}
|
|
|
|
|
|
if (qnetd_algorithm_array[algorithm_number] != NULL) {
|
|
|
- return (TLV_REPLY_ERROR_CODE_DECISION_ALGORITHM_ALREADY_REGISTERED);
|
|
|
+ qnetd_log(LOG_CRIT, "Failed to register decision algorithm %u, "
|
|
|
+ "it's already registered.", algorithm_number);
|
|
|
+ return (-1);
|
|
|
}
|
|
|
|
|
|
qnetd_algorithm_array[algorithm_number] = algorithm;
|
|
|
|
|
|
- return (TLV_REPLY_ERROR_CODE_NO_ERROR);
|
|
|
+ return (0);
|
|
|
}
|
|
|
|
|
|
-void
|
|
|
+int
|
|
|
qnetd_algorithm_register_all(void)
|
|
|
{
|
|
|
|
|
|
- if (qnetd_algo_test_register() != TLV_REPLY_ERROR_CODE_NO_ERROR) {
|
|
|
- errx(1, "Failed to register decision algorithm 'test' ");
|
|
|
+ if (qnetd_algo_test_register() != 0) {
|
|
|
+ qnetd_log(LOG_CRIT, "Failed to register decision algorithm 'test'");
|
|
|
+ return (-1);
|
|
|
}
|
|
|
- if (qnetd_algo_ffsplit_register() != TLV_REPLY_ERROR_CODE_NO_ERROR) {
|
|
|
- errx(1, "Failed to register decision algorithm 'ffsplit' ");
|
|
|
+ if (qnetd_algo_ffsplit_register() != 0) {
|
|
|
+ qnetd_log(LOG_CRIT, "Failed to register decision algorithm 'ffsplit'");
|
|
|
+ return (-1);
|
|
|
}
|
|
|
- if (qnetd_algo_2nodelms_register() != TLV_REPLY_ERROR_CODE_NO_ERROR) {
|
|
|
- errx(1, "Failed to register decision algorithm '2nodelms' ");
|
|
|
+ if (qnetd_algo_2nodelms_register() != 0) {
|
|
|
+ qnetd_log(LOG_CRIT, "Failed to register decision algorithm '2nodelms'");
|
|
|
+ return (-1);
|
|
|
}
|
|
|
- if (qnetd_algo_lms_register() != TLV_REPLY_ERROR_CODE_NO_ERROR) {
|
|
|
- errx(1, "Failed to register decision algorithm 'lms' ");
|
|
|
+ if (qnetd_algo_lms_register() != 0) {
|
|
|
+ qnetd_log(LOG_CRIT, "Failed to register decision algorithm 'lms'");
|
|
|
+ return (-1);
|
|
|
}
|
|
|
+
|
|
|
+ return (0);
|
|
|
}
|