And remove qnetd_ prefix from function names.
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
corosync_qnetd_SOURCES = corosync-qnetd.c \
dynar.c dynar.h msg.c msg.h msgio.c msgio.h \
nss-sock.c nss-sock.h qnetd-client.c qnetd-client.h \
- qnetd-client-list.c qnetd-client-list.h qnetd-log.c qnetd-log.h \
+ qnetd-client-list.c qnetd-client-list.h log.c log.h \
pr-poll-array.c pr-poll-array.h timer-list.c timer-list.h tlv.c tlv.h \
send-buffer-list.c send-buffer-list.h node-list.c node-list.h \
qnetd-algo-test.c qnetd-algo-test.h qnetd-algorithm.c qnetd-algorithm.h \
#include "dynar.h"
#include "dynar-str.h"
#include "dynar-getopt-lex.h"
+#include "log.h"
#include "nss-sock.h"
#include "pr-poll-array.h"
#include "qnetd-advanced-settings.h"
#include "qnetd-algorithm.h"
#include "qnetd-instance.h"
#include "qnetd-ipc.h"
-#include "qnetd-log.h"
#include "qnetd-client-net.h"
#include "qnetd-client-msg-received.h"
#include "qnetd-poll-array-user-data.h"
qnetd_err_nss(void)
{
- qnetd_log_nss(LOG_CRIT, "NSS error");
+ log_nss(LOG_CRIT, "NSS error");
exit(1);
}
qnetd_warn_nss(void)
{
- qnetd_log_nss(LOG_WARNING, "NSS warning");
+ log_nss(LOG_WARNING, "NSS warning");
}
static PRPollDesc *
user_data->type = QNETD_POLL_ARRAY_USER_DATA_TYPE_SOCKET;
if (qnetd_ipc_is_closed(instance)) {
- qnetd_log(LOG_DEBUG, "Listening socket is closed");
+ log(LOG_DEBUG, "Listening socket is closed");
return (NULL);
}
/*
* Poll write on listen socket -> fatal error
*/
- qnetd_log(LOG_CRIT, "POLL_WRITE on listening socket");
+ log(LOG_CRIT, "POLL_WRITE on listening socket");
return (-1);
break;
}
break;
case QNETD_POLL_ARRAY_USER_DATA_TYPE_IPC_SOCKET:
- qnetd_log(LOG_CRIT, "POLL_WRITE on listening IPC socket");
+ log(LOG_CRIT, "POLL_WRITE on listening IPC socket");
return (-1);
break;
case QNETD_POLL_ARRAY_USER_DATA_TYPE_IPC_CLIENT:
* Poll ERR on listening socket is fatal error.
* POLL_NVAL is used as a signal to quit poll loop.
*/
- qnetd_log(LOG_CRIT, "POLL_ERR (%u) on listening "
+ log(LOG_CRIT, "POLL_ERR (%u) on listening "
"socket", pfds[i].out_flags);
} else {
- qnetd_log(LOG_DEBUG, "Listening socket is closed");
+ log(LOG_DEBUG, "Listening socket is closed");
}
return (-1);
break;
case QNETD_POLL_ARRAY_USER_DATA_TYPE_CLIENT:
- qnetd_log(LOG_DEBUG, "POLL_ERR (%u) on client socket. "
+ log(LOG_DEBUG, "POLL_ERR (%u) on client socket. "
"Disconnecting.", pfds[i].out_flags);
client_disconnect = 1;
break;
case QNETD_POLL_ARRAY_USER_DATA_TYPE_IPC_CLIENT:
- qnetd_log(LOG_DEBUG, "POLL_ERR (%u) on ipc client socket."
+ log(LOG_DEBUG, "POLL_ERR (%u) on ipc client socket."
" Disconnecting.", pfds[i].out_flags);
client_disconnect = 1;
signal_int_handler(int sig)
{
- qnetd_log(LOG_DEBUG, "SIGINT received - closing server IPC socket");
+ log(LOG_DEBUG, "SIGINT received - closing server IPC socket");
qnetd_ipc_close(global_instance);
}
signal_term_handler(int sig)
{
- qnetd_log(LOG_DEBUG, "SIGTERM received - closing server IPC socket");
+ log(LOG_DEBUG, "SIGTERM received - closing server IPC socket");
qnetd_ipc_close(global_instance);
}
&tls_supported, &client_cert_required, &max_clients, &address_family, &advanced_settings);
if (foreground) {
- qnetd_log_init(QNETD_LOG_TARGET_STDERR);
+ log_init(QNETD_PROGRAM_NAME, LOG_TARGET_STDERR);
} else {
- qnetd_log_init(QNETD_LOG_TARGET_SYSLOG);
+ log_init(QNETD_PROGRAM_NAME, LOG_TARGET_SYSLOG);
}
- qnetd_log_set_debug(debug_log);
- qnetd_log_set_priority_bump(bump_log_priority);
+ log_set_debug(debug_log);
+ log_set_priority_bump(bump_log_priority);
/*
* Check that it's possible to open NSS dir if needed
*/
if (nss_sock_check_db_dir((tls_supported != TLV_TLS_UNSUPPORTED ?
advanced_settings.nss_db_dir : NULL)) != 0) {
- qnetd_log_err(LOG_ERR, "Can't open NSS DB directory");
+ log_err(LOG_ERR, "Can't open NSS DB directory");
exit (1);
}
if ((lock_file = utils_flock(advanced_settings.lock_file, getpid(),
&another_instance_running)) == -1) {
if (another_instance_running) {
- qnetd_log(LOG_ERR, "Another instance is running");
+ log(LOG_ERR, "Another instance is running");
} else {
- qnetd_log_err(LOG_ERR, "Can't acquire lock");
+ log_err(LOG_ERR, "Can't acquire lock");
}
exit(1);
}
- qnetd_log(LOG_DEBUG, "Initializing nss");
+ log(LOG_DEBUG, "Initializing nss");
if (nss_sock_init_nss((tls_supported != TLV_TLS_UNSUPPORTED ?
advanced_settings.nss_db_dir : NULL)) != 0) {
qnetd_err_nss();
if (qnetd_instance_init(&instance, tls_supported, client_cert_required,
max_clients, &advanced_settings) == -1) {
- qnetd_log(LOG_ERR, "Can't initialize qnetd");
+ log(LOG_ERR, "Can't initialize qnetd");
exit(1);
}
instance.host_addr = host_addr;
qnetd_err_nss();
}
- qnetd_log(LOG_DEBUG, "Initializing local socket");
+ log(LOG_DEBUG, "Initializing local socket");
if (qnetd_ipc_init(&instance) != 0) {
return (1);
}
- qnetd_log(LOG_DEBUG, "Creating listening socket");
+ log(LOG_DEBUG, "Creating listening socket");
instance.server.socket = nss_sock_create_listen_socket(instance.host_addr,
instance.host_port, address_family);
if (instance.server.socket == NULL) {
global_instance = &instance;
signal_handlers_register();
- qnetd_log(LOG_DEBUG, "Registering algorithms");
+ log(LOG_DEBUG, "Registering algorithms");
if (qnetd_algorithm_register_all() != 0) {
exit(1);
}
- qnetd_log(LOG_DEBUG, "QNetd ready to provide service");
+ log(LOG_DEBUG, "QNetd ready to provide service");
#ifdef HAVE_LIBSYSTEMD
sd_notify(0, "READY=1");
qnetd_warn_nss();
}
- qnetd_log_close();
+ log_close();
return (0);
}
--- /dev/null
+/*
+ * Copyright (c) 2015-2019 Red Hat, Inc.
+ *
+ * All rights reserved.
+ *
+ * Author: Jan Friesse (jfriesse@redhat.com)
+ *
+ * This software licensed under BSD license, the text of which follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the Red Hat, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <syslog.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#include "qnet-config.h"
+#include "log.h"
+
+static int log_config_target = 0;
+static int log_config_debug = 0;
+static int log_config_priority_bump = 0;
+static char *log_config_ident = NULL;
+
+static const char log_month_str[][4] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
+
+struct log_syslog_prio_to_str_item {
+ int priority;
+ const char *priority_str;
+};
+
+static struct log_syslog_prio_to_str_item syslog_prio_to_str_array[] = {
+ {LOG_EMERG, "emerg"},
+ {LOG_ALERT, "alert"},
+ {LOG_CRIT, "crit"},
+ {LOG_ERR, "error"},
+ {LOG_WARNING, "warning"},
+ {LOG_NOTICE, "notice"},
+ {LOG_INFO, "info"},
+ {LOG_DEBUG, "debug"},
+ {-1, NULL}};
+
+int
+log_init(const char *ident, int target)
+{
+
+ log_config_target = target;
+ log_config_ident = strdup(ident);
+
+ if (log_config_ident == NULL) {
+ return (-1);
+ }
+
+ if (log_config_target & LOG_TARGET_SYSLOG) {
+ openlog(QNETD_PROGRAM_NAME, LOG_PID, LOG_DAEMON);
+ }
+
+ return (0);
+}
+
+static const char *
+log_syslog_prio_to_str(int priority)
+{
+
+ if (priority >= LOG_EMERG && priority <= LOG_DEBUG) {
+ return (syslog_prio_to_str_array[priority].priority_str);
+ } else {
+ return ("none");
+ }
+}
+
+void
+log_vprintf(int priority, const char *format, va_list ap)
+{
+ time_t current_time;
+ struct tm tm_res;
+ int final_priority;
+ va_list ap_copy;
+
+ if (priority != LOG_DEBUG || (log_config_debug)) {
+ if (log_config_target & LOG_TARGET_STDERR) {
+ current_time = time(NULL);
+ localtime_r(¤t_time, &tm_res);
+
+ fprintf(stderr, "%s %02d %02d:%02d:%02d ",
+ log_month_str[tm_res.tm_mon], tm_res.tm_mday, tm_res.tm_hour,
+ tm_res.tm_min, tm_res.tm_sec);
+
+ fprintf(stderr, "%-7s ", log_syslog_prio_to_str(priority));
+
+ va_copy(ap_copy, ap);
+ vfprintf(stderr, format, ap_copy);
+ va_end(ap_copy);
+ fprintf(stderr, "\n");
+ }
+
+ if (log_config_target & LOG_TARGET_SYSLOG) {
+ final_priority = priority;
+ if (log_config_priority_bump && priority > LOG_INFO) {
+ final_priority = LOG_INFO;
+ }
+
+ va_copy(ap_copy, ap);
+ vsyslog(final_priority, format, ap);
+ va_end(ap_copy);
+ }
+ }
+}
+
+void
+log_printf(int priority, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+
+ log_vprintf(priority, format, ap);
+
+ va_end(ap);
+}
+
+void
+log_close(void)
+{
+
+ if (log_config_target & LOG_TARGET_SYSLOG) {
+ closelog();
+ }
+}
+
+void
+log_set_debug(int enabled)
+{
+
+ log_config_debug = enabled;
+}
+
+void
+log_set_priority_bump(int enabled)
+{
+
+ log_config_priority_bump = enabled;
+}
+
+void
+log_msg_decode_error(int ret)
+{
+
+ switch (ret) {
+ case -1:
+ log(LOG_WARNING, "Received message with option with invalid length");
+ break;
+ case -2:
+ log(LOG_CRIT, "Can't allocate memory");
+ break;
+ case -3:
+ log(LOG_WARNING, "Received inconsistent msg (tlv len > msg size)");
+ break;
+ case -4:
+ log(LOG_WARNING, "Received message with option with invalid value");
+ break;
+ default:
+ log(LOG_ERR, "Unknown error occurred when decoding message");
+ break;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015-2019 Red Hat, Inc.
+ *
+ * All rights reserved.
+ *
+ * Author: Jan Friesse (jfriesse@redhat.com)
+ *
+ * This software licensed under BSD license, the text of which follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the Red Hat, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LOG_H_
+#define _LOG_H_
+
+#include <syslog.h>
+#include <stdarg.h>
+#include <errno.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define LOG_TARGET_STDERR 1
+#define LOG_TARGET_SYSLOG 2
+
+#define log(...) log_printf(__VA_ARGS__)
+#define log_nss(priority, str) log_printf(priority, "%s (%d): %s", \
+ str, PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT));
+
+#define log_err(priority, str) log_printf(priority, "%s (%d): %s", \
+ str, errno, strerror(errno))
+
+extern int log_init(const char *ident, int target);
+
+extern void log_printf(int priority, const char *format, ...)
+ __attribute__((__format__(__printf__, 2, 3)));
+
+extern void log_vprintf(int priority, const char *format, va_list ap)
+ __attribute__((__format__(__printf__, 2, 0)));
+
+extern void log_close(void);
+
+extern void log_set_debug(int enabled);
+
+extern void log_set_priority_bump(int enabled);
+
+extern void log_msg_decode_error(int ret);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LOG_H_ */
/*
- * Copyright (c) 2015-2017 Red Hat, Inc.
+ * Copyright (c) 2015-2019 Red Hat, Inc.
*
* All rights reserved.
*
#include <string.h>
#include <limits.h>
+#include "log.h"
#include "qnetd-algo-2nodelms.h"
-#include "qnetd-log.h"
#include "qnetd-cluster-list.h"
#include "qnetd-algo-utils.h"
#include "utils.h"
node_count++;
}
info->num_config_nodes = node_count;
- qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s config_list has %d nodes", client->cluster_name, node_count);
+ log(LOG_DEBUG, "algo-2nodelms: cluster %s config_list has %d nodes", client->cluster_name, node_count);
if (node_count != 2) {
- qnetd_log(LOG_INFO, "algo-2nodelms: cluster %s does not have 2 configured nodes, it has %d", client->cluster_name, node_count);
+ log(LOG_INFO, "algo-2nodelms: cluster %s does not have 2 configured nodes, it has %d", client->cluster_name, node_count);
*result_vote = TLV_VOTE_NACK;
return (TLV_REPLY_ERROR_CODE_UNSUPPORTED_DECISION_ALGORITHM);
/* Don't save NACK, we need to know subsequently if we haven't been voting */
*result_vote = TLV_VOTE_NACK;
- qnetd_log(LOG_DEBUG, "algo-2nodelms: we are a new partition and another active partition exists. NACK");
+ log(LOG_DEBUG, "algo-2nodelms: we are a new partition and another active partition exists. NACK");
return (TLV_REPLY_ERROR_CODE_NO_ERROR);
}
}
node_count++;
}
- qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s (client %p nodeid "UTILS_PRI_NODE_ID") membership list has %d member nodes (ring ID "UTILS_PRI_RING_ID")", client->cluster_name, client, client->node_id, node_count, ring_id->node_id, ring_id->seq);
+ log(LOG_DEBUG, "algo-2nodelms: cluster %s (client %p nodeid "UTILS_PRI_NODE_ID") membership list has %d member nodes (ring ID "UTILS_PRI_RING_ID")", client->cluster_name, client, client->node_id, node_count, ring_id->node_id, ring_id->seq);
if (node_count == 2) {
- qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s running normally. Both nodes active", client->cluster_name);
+ log(LOG_DEBUG, "algo-2nodelms: cluster %s running normally. Both nodes active", client->cluster_name);
*result_vote = info->last_result = TLV_VOTE_ACK;
return (TLV_REPLY_ERROR_CODE_NO_ERROR);
}
TAILQ_FOREACH(other_client, &client->cluster->client_list, cluster_entries) {
node_count++;
- qnetd_log(LOG_DEBUG, "algo-2nodelms: seen nodeid "UTILS_PRI_NODE_ID" on client %p (ring ID "UTILS_PRI_RING_ID")", other_client->node_id, other_client, other_client->last_ring_id.node_id, other_client->last_ring_id.seq);
+ log(LOG_DEBUG, "algo-2nodelms: seen nodeid "UTILS_PRI_NODE_ID" on client %p (ring ID "UTILS_PRI_RING_ID")", other_client->node_id, other_client, other_client->last_ring_id.node_id, other_client->last_ring_id.seq);
if (other_client->node_id < low_node_id) {
low_node_id = other_client->node_id;
}
other_node_heuristics = other_client->last_heuristics;
}
}
- qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s %d nodes running independently", client->cluster_name, node_count);
+ log(LOG_DEBUG, "algo-2nodelms: cluster %s %d nodes running independently", client->cluster_name, node_count);
/* Only 1 node alive .. allow it to continue */
if (node_count == 1) {
- qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s running on 'last-man'", client->cluster_name);
+ log(LOG_DEBUG, "algo-2nodelms: cluster %s running on 'last-man'", client->cluster_name);
*result_vote = info->last_result = TLV_VOTE_ACK;
return (TLV_REPLY_ERROR_CODE_NO_ERROR);
}
case TLV_TIE_BREAKER_MODE_LOWEST:
if (client->node_id == low_node_id) {
- qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s running on low node-id %d", client->cluster_name, low_node_id);
+ log(LOG_DEBUG, "algo-2nodelms: cluster %s running on low node-id %d", client->cluster_name, low_node_id);
*result_vote = info->last_result = TLV_VOTE_ACK;
}
else {
- qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s node-id %d denied vote because low nodeid %d is active", client->cluster_name, client->node_id, low_node_id);
+ log(LOG_DEBUG, "algo-2nodelms: cluster %s node-id %d denied vote because low nodeid %d is active", client->cluster_name, client->node_id, low_node_id);
*result_vote = info->last_result = TLV_VOTE_NACK;
}
break;
case TLV_TIE_BREAKER_MODE_HIGHEST:
if (client->node_id == high_node_id) {
- qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s running on high node-id %d", client->cluster_name, high_node_id);
+ log(LOG_DEBUG, "algo-2nodelms: cluster %s running on high node-id %d", client->cluster_name, high_node_id);
*result_vote = info->last_result = TLV_VOTE_ACK;
}
else {
- qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s node-id %d denied vote because high nodeid %d is active", client->cluster_name, client->node_id, high_node_id);
+ log(LOG_DEBUG, "algo-2nodelms: cluster %s node-id %d denied vote because high nodeid %d is active", client->cluster_name, client->node_id, high_node_id);
*result_vote = info->last_result = TLV_VOTE_NACK;
}
break;
case TLV_TIE_BREAKER_MODE_NODE_ID:
if (client->node_id == client->tie_breaker.node_id) {
- qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s running on nominated tie-breaker node %d", client->cluster_name, client->tie_breaker.node_id);
+ log(LOG_DEBUG, "algo-2nodelms: cluster %s running on nominated tie-breaker node %d", client->cluster_name, client->tie_breaker.node_id);
*result_vote = info->last_result = TLV_VOTE_ACK;
}
else {
- qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s node-id %d denied vote because nominated tie-breaker nodeid %d is active", client->cluster_name, client->node_id, client->tie_breaker.node_id);
+ log(LOG_DEBUG, "algo-2nodelms: cluster %s node-id %d denied vote because nominated tie-breaker nodeid %d is active", client->cluster_name, client->node_id, client->tie_breaker.node_id);
*result_vote = info->last_result = TLV_VOTE_NACK;
}
break;
default:
- qnetd_log(LOG_DEBUG, "algo-2nodelms: cluster %s node-id %d denied vote because tie-breaker option is invalid: %d", client->cluster_name, client->node_id, client->tie_breaker.mode);
+ log(LOG_DEBUG, "algo-2nodelms: cluster %s node-id %d denied vote because tie-breaker option is invalid: %d", client->cluster_name, client->node_id, client->tie_breaker.mode);
*result_vote = info->last_result = TLV_VOTE_NACK;
}
void
qnetd_algo_2nodelms_client_disconnect(struct qnetd_client *client, int server_going_down)
{
- qnetd_log(LOG_INFO, "algo-2nodelms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
+ log(LOG_INFO, "algo-2nodelms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
"disconnect", client, client->cluster_name, client->node_id);
- qnetd_log(LOG_INFO, "algo-2nodelms: server going down %u", server_going_down);
+ log(LOG_INFO, "algo-2nodelms: server going down %u", server_going_down);
free(client->algorithm_data);
}
{
struct qnetd_algo_2nodelms_info *info = client->algorithm_data;
- qnetd_log(LOG_INFO, "algo-2nodelms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
+ log(LOG_INFO, "algo-2nodelms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
"asked for a vote", client, client->cluster_name, client->node_id);
if (info->last_result == 0) {
qnetd_algo_2nodelms_vote_info_reply_received(struct qnetd_client *client, uint32_t msg_seq_num)
{
- qnetd_log(LOG_INFO, "algo-2nodelms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
+ log(LOG_INFO, "algo-2nodelms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
"replied back to vote info message", client, client->cluster_name, client->node_id);
return (TLV_REPLY_ERROR_CODE_NO_ERROR);
enum tlv_heuristics heuristics, enum tlv_vote *result_vote)
{
- qnetd_log(LOG_INFO, "algo-2nodelms: heuristics change is not supported.");
+ log(LOG_INFO, "algo-2nodelms: heuristics change is not supported.");
*result_vote = TLV_VOTE_NO_CHANGE;
/*
- * Copyright (c) 2015-2017 Red Hat, Inc.
+ * Copyright (c) 2015-2019 Red Hat, Inc.
*
* All rights reserved.
*
#include <string.h>
+#include "log.h"
#include "qnetd-algo-ffsplit.h"
-#include "qnetd-log.h"
#include "qnetd-log-debug.h"
#include "qnetd-cluster-list.h"
#include "qnetd-cluster.h"
if (qnetd_cluster_size(client->cluster) == 1) {
cluster_data = malloc(sizeof(*cluster_data));
if (cluster_data == NULL) {
- qnetd_log(LOG_ERR, "ffsplit: Can't initialize cluster data for client %s",
+ log(LOG_ERR, "ffsplit: Can't initialize cluster data for client %s",
client->addr_str);
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
client_data = malloc(sizeof(*client_data));
if (client_data == NULL) {
- qnetd_log(LOG_ERR, "ffsplit: Can't initialize node data for client %s",
+ log(LOG_ERR, "ffsplit: Can't initialize node data for client %s",
client->addr_str);
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
}
if (!case_processed) {
- qnetd_log(LOG_CRIT, "qnetd_algo_ffsplit_is_preferred_partition unprocessed "
+ log(LOG_CRIT, "qnetd_algo_ffsplit_is_preferred_partition unprocessed "
"tie_breaker.mode");
exit(1);
}
exit_res:
if (res == -1) {
- qnetd_log(LOG_CRIT, "qnetd_algo_ffsplit_partition_cmp unhandled case");
+ log(LOG_CRIT, "qnetd_algo_ffsplit_partition_cmp unhandled case");
exit(1);
/* NOTREACHED */
}
/*
* Wait until membership is stable
*/
- qnetd_log(LOG_DEBUG, "ffsplit: Membership for cluster %s is not yet stable", client->cluster_name);
+ log(LOG_DEBUG, "ffsplit: Membership for cluster %s is not yet stable", client->cluster_name);
return (TLV_VOTE_WAIT_FOR_REPLY);
}
- qnetd_log(LOG_DEBUG, "ffsplit: Membership for cluster %s is now stable", client->cluster_name);
+ log(LOG_DEBUG, "ffsplit: Membership for cluster %s is now stable", client->cluster_name);
quorate_partition_node_list = qnetd_algo_ffsplit_select_partition(client, client_leaving,
config_node_list, membership_node_list, client_heuristics);
cluster_data->quorate_partition_node_list = quorate_partition_node_list;
if (quorate_partition_node_list == NULL) {
- qnetd_log(LOG_DEBUG, "ffsplit: No quorate partition was selected");
+ log(LOG_DEBUG, "ffsplit: No quorate partition was selected");
} else {
- qnetd_log(LOG_DEBUG, "ffsplit: Quorate partition selected");
+ log(LOG_DEBUG, "ffsplit: Quorate partition selected");
qnetd_log_debug_dump_node_list(client, quorate_partition_node_list);
}
cluster_data->cluster_state = QNETD_ALGO_FFSPLIT_CLUSTER_STATE_SENDING_NACKS;
if (qnetd_algo_ffsplit_send_votes(client, client_leaving, ring_id, 0) == 0) {
- qnetd_log(LOG_DEBUG, "ffsplit: No client gets NACK");
+ log(LOG_DEBUG, "ffsplit: No client gets NACK");
/*
* No one gets nack -> send acks
*/
cluster_data->cluster_state = QNETD_ALGO_FFSPLIT_CLUSTER_STATE_SENDING_ACKS;
if (qnetd_algo_ffsplit_send_votes(client, client_leaving, ring_id, 1) == 0) {
- qnetd_log(LOG_DEBUG, "ffsplit: No client gets ACK");
+ log(LOG_DEBUG, "ffsplit: No client gets ACK");
/*
* No one gets acks -> finished
*/
/*
* Empty node list shouldn't happen
*/
- qnetd_log(LOG_ERR, "ffsplit: Received empty config node list for client %s",
+ log(LOG_ERR, "ffsplit: Received empty config node list for client %s",
client->addr_str);
return (TLV_REPLY_ERROR_CODE_INVALID_CONFIG_NODE_LIST);
/*
* Current node is not in node list
*/
- qnetd_log(LOG_ERR, "ffsplit: Received config node list without client %s",
+ log(LOG_ERR, "ffsplit: Received config node list without client %s",
client->addr_str);
return (TLV_REPLY_ERROR_CODE_INVALID_CONFIG_NODE_LIST);
/*
* Empty node list shouldn't happen
*/
- qnetd_log(LOG_ERR, "ffsplit: Received empty membership node list for client %s",
+ log(LOG_ERR, "ffsplit: Received empty membership node list for client %s",
client->addr_str);
return (TLV_REPLY_ERROR_CODE_INVALID_MEMBERSHIP_NODE_LIST);
/*
* Current node is not in node list
*/
- qnetd_log(LOG_ERR, "ffsplit: Received membership node list without client %s",
+ log(LOG_ERR, "ffsplit: Received membership node list without client %s",
client->addr_str);
return (TLV_REPLY_ERROR_CODE_INVALID_MEMBERSHIP_NODE_LIST);
client_data = (struct qnetd_algo_ffsplit_client_data *)client->algorithm_data;
if (client_data->vote_info_expected_seq_num != msg_seq_num) {
- qnetd_log(LOG_DEBUG, "ffsplit: Received old vote info reply from client %s",
+ log(LOG_DEBUG, "ffsplit: Received old vote info reply from client %s",
client->addr_str);
return (TLV_REPLY_ERROR_CODE_NO_ERROR);
if (cluster_data->cluster_state == QNETD_ALGO_FFSPLIT_CLUSTER_STATE_SENDING_NACKS) {
if (qnetd_algo_ffsplit_no_clients_in_sending_state(client, 0) == 0) {
- qnetd_log(LOG_DEBUG, "ffsplit: All NACK votes sent for cluster %s",
+ log(LOG_DEBUG, "ffsplit: All NACK votes sent for cluster %s",
client->cluster_name);
cluster_data->cluster_state = QNETD_ALGO_FFSPLIT_CLUSTER_STATE_SENDING_ACKS;
if (qnetd_algo_ffsplit_send_votes(client, 0, &client->last_ring_id, 1) == 0) {
- qnetd_log(LOG_DEBUG, "ffsplit: No client gets ACK");
+ log(LOG_DEBUG, "ffsplit: No client gets ACK");
/*
* No one gets acks -> finished
*/
}
} else {
if (qnetd_algo_ffsplit_no_clients_in_sending_state(client, 1) == 0) {
- qnetd_log(LOG_DEBUG, "ffsplit: All ACK votes sent for cluster %s",
+ log(LOG_DEBUG, "ffsplit: All ACK votes sent for cluster %s",
client->cluster_name);
cluster_data->cluster_state = QNETD_ALGO_FFSPLIT_CLUSTER_STATE_WAITING_FOR_CHANGE;
/*
- * Copyright (c) 2015-2017 Red Hat, Inc.
+ * Copyright (c) 2015-2019 Red Hat, Inc.
*
* All rights reserved.
*
#include <string.h>
#include <limits.h>
+#include "log.h"
#include "qnetd-algo-lms.h"
-#include "qnetd-log.h"
#include "qnetd-cluster-list.h"
#include "qnetd-algo-utils.h"
#include "qnetd-client-algo-timer.h"
qnetd_client_algo_timer_abort(client);
if (qnetd_algo_all_ring_ids_match(client, ring_id) == -1) {
- qnetd_log(LOG_DEBUG, "algo-lms: nodeid %d: ring ID (" UTILS_PRI_RING_ID ") not unique in this membership, waiting",
+ log(LOG_DEBUG, "algo-lms: nodeid %d: ring ID (" UTILS_PRI_RING_ID ") not unique in this membership, waiting",
client->node_id, ring_id->node_id, ring_id->seq);
qnetd_client_algo_timer_schedule(client);
/* Create and count the number of separate partitions */
if ( (num_partitions = qnetd_algo_create_partitions(client, &info->partition_list, ring_id)) == -1) {
- qnetd_log(LOG_DEBUG, "algo-lms: Error creating partition list");
+ log(LOG_DEBUG, "algo-lms: Error creating partition list");
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
}
/* This can happen if we are first on the block */
if (num_partitions == 0) {
- qnetd_log(LOG_DEBUG, "algo-lms: No partitions found");
+ log(LOG_DEBUG, "algo-lms: No partitions found");
qnetd_client_algo_timer_schedule(client);
*result_vote = info->last_result = TLV_VOTE_WAIT_FOR_REPLY;
/* Only 1 partition - let votequorum sort it out */
if (num_partitions == 1) {
- qnetd_log(LOG_DEBUG, "algo-lms: Only 1 partition. This is votequorum's problem, not ours");
+ log(LOG_DEBUG, "algo-lms: Only 1 partition. This is votequorum's problem, not ours");
qnetd_algo_free_partitions(&info->partition_list);
*result_vote = info->last_result = TLV_VOTE_ACK;
return (TLV_REPLY_ERROR_CODE_NO_ERROR);
/* Don't save NACK, we need to know subsequently if we haven't been voting */
*result_vote = TLV_VOTE_NACK;
- qnetd_log(LOG_DEBUG, "algo-lms: we are a new partition and another active partition exists. NACK");
+ log(LOG_DEBUG, "algo-lms: we are a new partition and another active partition exists. NACK");
return (TLV_REPLY_ERROR_CODE_NO_ERROR);
}
}
best_score_partition = cur_partition;
}
}
- qnetd_log(LOG_DEBUG, "algo-lms: best score partition is (" UTILS_PRI_RING_ID ") with score %d",
+ log(LOG_DEBUG, "algo-lms: best score partition is (" UTILS_PRI_RING_ID ") with score %d",
best_score_partition->ring_id.node_id, best_score_partition->ring_id.seq, best_score_partition->score);
/* Now check if it's really the highest score, and not just the joint-highest */
if (!joint_leader) {
/* Partition with highest score is unique, allow us to run if we're in that partition. */
if (tlv_ring_id_eq(&best_score_partition->ring_id, ring_id)) {
- qnetd_log(LOG_DEBUG, "algo-lms: We are in the best score partition. ACK");
+ log(LOG_DEBUG, "algo-lms: We are in the best score partition. ACK");
*result_vote = info->last_result = TLV_VOTE_ACK;
}
else {
- qnetd_log(LOG_DEBUG, "algo-lms: We are NOT in the best score partition. NACK");
+ log(LOG_DEBUG, "algo-lms: We are NOT in the best score partition. NACK");
*result_vote = info->last_result = TLV_VOTE_NACK;
}
}
}
- qnetd_log(LOG_DEBUG, "algo-lms: largest partition is (" UTILS_PRI_RING_ID ") with %d nodes",
+ log(LOG_DEBUG, "algo-lms: largest partition is (" UTILS_PRI_RING_ID ") with %d nodes",
largest_partition->ring_id.node_id, largest_partition->ring_id.seq, largest_partition->num_nodes);
/* Now check if it's really the largest, and not just the joint-largest */
if (!joint_leader) {
/* Largest partition is unique, allow us to run if we're in that partition. */
if (tlv_ring_id_eq(&largest_partition->ring_id, ring_id)) {
- qnetd_log(LOG_DEBUG, "algo-lms: We are in the largest partition. ACK");
+ log(LOG_DEBUG, "algo-lms: We are in the largest partition. ACK");
*result_vote = info->last_result = TLV_VOTE_ACK;
}
else {
- qnetd_log(LOG_DEBUG, "algo-lms: We are NOT in the largest partition. NACK");
+ log(LOG_DEBUG, "algo-lms: We are NOT in the largest partition. NACK");
*result_vote = info->last_result = TLV_VOTE_NACK;
}
}
tb_node_id = client->tie_breaker.node_id;
}
else {
- qnetd_log(LOG_DEBUG, "algo-lms: denied vote because tie-breaker option is invalid: %d",
+ log(LOG_DEBUG, "algo-lms: denied vote because tie-breaker option is invalid: %d",
client->tie_breaker.mode);
tb_node_id = -1;
}
if (other_client->node_id < tb_node_id) {
tb_node_id = other_client->node_id;
memcpy(&tb_node_ring_id, &other_client->last_ring_id, sizeof(struct tlv_ring_id));
- qnetd_log(LOG_DEBUG, "algo-lms: Looking for low node ID. found %d (" UTILS_PRI_RING_ID ")",
+ log(LOG_DEBUG, "algo-lms: Looking for low node ID. found %d (" UTILS_PRI_RING_ID ")",
tb_node_id, tb_node_ring_id.node_id, tb_node_ring_id.seq);
}
break;
if (other_client->node_id > tb_node_id) {
tb_node_id = other_client->node_id;
memcpy(&tb_node_ring_id, &other_client->last_ring_id, sizeof(struct tlv_ring_id));
- qnetd_log(LOG_DEBUG, "algo-lms: Looking for high node ID. found %d (" UTILS_PRI_RING_ID ")",
+ log(LOG_DEBUG, "algo-lms: Looking for high node ID. found %d (" UTILS_PRI_RING_ID ")",
tb_node_id, tb_node_ring_id.node_id, tb_node_ring_id.seq);
}
break;
case TLV_TIE_BREAKER_MODE_NODE_ID:
if (client->tie_breaker.node_id == client->node_id) {
memcpy(&tb_node_ring_id, &other_client->last_ring_id, sizeof(struct tlv_ring_id));
- qnetd_log(LOG_DEBUG, "algo-lms: Looking for nominated node ID. found %d (" UTILS_PRI_RING_ID ")",
+ log(LOG_DEBUG, "algo-lms: Looking for nominated node ID. found %d (" UTILS_PRI_RING_ID ")",
tb_node_id, tb_node_ring_id.node_id, tb_node_ring_id.seq);
}
break;
default:
- qnetd_log(LOG_DEBUG, "algo-lms: denied vote because tie-breaker option is invalid: %d",
+ log(LOG_DEBUG, "algo-lms: denied vote because tie-breaker option is invalid: %d",
client->tie_breaker.mode);
memset(&tb_node_ring_id, 0, sizeof(struct tlv_ring_id));
}
}
if (client->node_id == tb_node_id || tlv_ring_id_eq(&tb_node_ring_id, ring_id)) {
- qnetd_log(LOG_DEBUG, "algo-lms: We are in the same partition (" UTILS_PRI_RING_ID ") as tie-breaker node id %d. ACK",
+ log(LOG_DEBUG, "algo-lms: We are in the same partition (" UTILS_PRI_RING_ID ") as tie-breaker node id %d. ACK",
tb_node_ring_id.node_id, tb_node_ring_id.seq, tb_node_id);
*result_vote = info->last_result = TLV_VOTE_ACK;
}
else {
- qnetd_log(LOG_DEBUG, "algo-lms: We are NOT in the same partition (" UTILS_PRI_RING_ID ") as tie-breaker node id %d. NACK",
+ log(LOG_DEBUG, "algo-lms: We are NOT in the same partition (" UTILS_PRI_RING_ID ") as tie-breaker node id %d. NACK",
tb_node_ring_id.node_id, tb_node_ring_id.seq, tb_node_id);
*result_vote = info->last_result = TLV_VOTE_NACK;
}
node_count++;
}
info->num_config_nodes = node_count;
- qnetd_log(LOG_DEBUG, "algo-lms: cluster %s config_list has %d nodes", client->cluster_name, node_count);
+ log(LOG_DEBUG, "algo-lms: cluster %s config_list has %d nodes", client->cluster_name, node_count);
*result_vote = TLV_VOTE_NO_CHANGE;
uint32_t msg_seq_num, const struct tlv_ring_id *ring_id,
const struct node_list *nodes, enum tlv_heuristics heuristics, enum tlv_vote *result_vote)
{
- qnetd_log(LOG_DEBUG, " ");
- qnetd_log(LOG_DEBUG, "algo-lms: membership list from node %d partition (" UTILS_PRI_RING_ID ")", client->node_id, ring_id->node_id, ring_id->seq);
+ log(LOG_DEBUG, " ");
+ log(LOG_DEBUG, "algo-lms: membership list from node %d partition (" UTILS_PRI_RING_ID ")", client->node_id, ring_id->node_id, ring_id->seq);
return do_lms_algorithm(client, ring_id, result_vote);
}
qnetd_algo_lms_quorum_node_list_received(struct qnetd_client *client,
uint32_t msg_seq_num, enum tlv_quorate quorate, const struct node_list *nodes, enum tlv_vote *result_vote)
{
- qnetd_log(LOG_DEBUG, " ");
- qnetd_log(LOG_DEBUG, "algo-lms: quorum node list from node %d partition (" UTILS_PRI_RING_ID ")", client->node_id, client->last_ring_id.node_id, client->last_ring_id.seq);
+ log(LOG_DEBUG, " ");
+ log(LOG_DEBUG, "algo-lms: quorum node list from node %d partition (" UTILS_PRI_RING_ID ")", client->node_id, client->last_ring_id.node_id, client->last_ring_id.seq);
return do_lms_algorithm(client, &client->last_ring_id, result_vote);
}
void
qnetd_algo_lms_client_disconnect(struct qnetd_client *client, int server_going_down)
{
- qnetd_log(LOG_DEBUG, "algo-lms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
+ log(LOG_DEBUG, "algo-lms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
"disconnect", client, client->cluster_name, client->node_id);
- qnetd_log(LOG_INFO, "algo-lms: server going down %u", server_going_down);
+ log(LOG_INFO, "algo-lms: server going down %u", server_going_down);
free(client->algorithm_data);
}
qnetd_algo_lms_ask_for_vote_received(struct qnetd_client *client, uint32_t msg_seq_num,
enum tlv_vote *result_vote)
{
- qnetd_log(LOG_DEBUG, " ");
- qnetd_log(LOG_DEBUG, "algo-lms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
+ log(LOG_DEBUG, " ");
+ log(LOG_DEBUG, "algo-lms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
"asked for a vote", client, client->cluster_name, client->node_id);
return do_lms_algorithm(client, &client->last_ring_id, result_vote);
enum tlv_reply_error_code
qnetd_algo_lms_vote_info_reply_received(struct qnetd_client *client, uint32_t msg_seq_num)
{
- qnetd_log(LOG_DEBUG, "algo-lms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
+ log(LOG_DEBUG, "algo-lms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
"replied back to vote info message", client, client->cluster_name, client->node_id);
return (TLV_REPLY_ERROR_CODE_NO_ERROR);
enum tlv_heuristics heuristics, enum tlv_vote *result_vote)
{
- qnetd_log(LOG_INFO, "algo-lms: heuristics change is not supported.");
+ log(LOG_INFO, "algo-lms: heuristics change is not supported.");
*result_vote = TLV_VOTE_NO_CHANGE;
{
enum tlv_reply_error_code ret;
- qnetd_log(LOG_DEBUG, "algo-lms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
+ log(LOG_DEBUG, "algo-lms: Client %p (cluster %s, node_id "UTILS_PRI_NODE_ID") "
"Timer callback", client, client->cluster_name, client->node_id);
ret = do_lms_algorithm(client, &client->last_ring_id, result_vote);
/*
- * Copyright (c) 2015-2017 Red Hat, Inc.
+ * Copyright (c) 2015-2019 Red Hat, Inc.
*
* All rights reserved.
*
#include <string.h>
+#include "log.h"
#include "qnetd-algo-test.h"
-#include "qnetd-log.h"
#include "qnetd-cluster-list.h"
#include "qnetd-client-send.h"
#include "qnetd-log-debug.h"
{
int *algo_data;
- qnetd_log(LOG_WARNING, "algo-test: Client %s (cluster = '%s', node_id = "
+ log(LOG_WARNING, "algo-test: Client %s (cluster = '%s', node_id = "
UTILS_PRI_NODE_ID") initiated test algorithm. It's not recommended to use test "
"algorithm because it can create multiple quorate partitions!", client->addr_str,
client->cluster_name, client->node_id);
- qnetd_log(LOG_INFO, "algo-test: client_init");
+ log(LOG_INFO, "algo-test: client_init");
client->algorithm_data = malloc(sizeof(int));
if (client->algorithm_data == NULL) {
/*
* First client in the cluster
*/
- qnetd_log(LOG_INFO, "algo-test: Initializing cluster->algorithm data");
+ log(LOG_INFO, "algo-test: Initializing cluster->algorithm data");
client->cluster->algorithm_data = malloc(sizeof(int));
if (client->cluster->algorithm_data == NULL) {
const struct node_list *nodes, int initial, enum tlv_vote *result_vote)
{
- qnetd_log(LOG_INFO, "algo-test: node_list_received");
+ log(LOG_INFO, "algo-test: node_list_received");
*result_vote = TLV_VOTE_NO_CHANGE;
const struct node_list *nodes, enum tlv_heuristics heuristics, enum tlv_vote *result_vote)
{
- qnetd_log(LOG_INFO, "algo-test: membership_node_list_received");
+ log(LOG_INFO, "algo-test: membership_node_list_received");
*result_vote = TLV_VOTE_ACK;
enum tlv_vote *result_vote)
{
- qnetd_log(LOG_INFO, "algo-test: quorum_node_list_received");
+ log(LOG_INFO, "algo-test: quorum_node_list_received");
*result_vote = TLV_VOTE_NO_CHANGE;
qnetd_algo_test_client_disconnect(struct qnetd_client *client, int server_going_down)
{
- qnetd_log(LOG_INFO, "algo-test: client_disconnect");
+ log(LOG_INFO, "algo-test: client_disconnect");
free(client->algorithm_data);
/*
* Last client in the cluster
*/
- qnetd_log(LOG_INFO, "algo-test: Finalizing cluster->algorithm data");
+ log(LOG_INFO, "algo-test: Finalizing cluster->algorithm data");
free(client->cluster->algorithm_data);
}
enum tlv_vote *result_vote)
{
- qnetd_log(LOG_INFO, "algo-test: ask_for_vote_received");
+ log(LOG_INFO, "algo-test: ask_for_vote_received");
*result_vote = TLV_VOTE_ACK;
qnetd_algo_test_vote_info_reply_received(struct qnetd_client *client, uint32_t msg_seq_num)
{
- qnetd_log(LOG_INFO, "algo-test: vote_info_reply_received");
+ log(LOG_INFO, "algo-test: vote_info_reply_received");
return (TLV_REPLY_ERROR_CODE_NO_ERROR);
}
enum tlv_heuristics heuristics, enum tlv_vote *result_vote)
{
- qnetd_log(LOG_INFO, "algo-test: heuristics_change_received");
+ log(LOG_INFO, "algo-test: heuristics_change_received");
*result_vote = TLV_VOTE_NO_CHANGE;
/*
- * Copyright (c) 2016 Red Hat, Inc.
+ * Copyright (c) 2016-2019 Red Hat, Inc.
*
* All rights reserved.
*
#include <sys/types.h>
#include <string.h>
-#include "qnetd-log.h"
+#include "log.h"
#include "qnetd-cluster-list.h"
#include "qnetd-algo-utils.h"
#include "utils.h"
if (other_client == client) {
continue; /* We've seen our membership list */
}
- qnetd_log(LOG_DEBUG, "algo-util: all_ring_ids_match: seen nodeid %d (client %p) ring_id (" UTILS_PRI_RING_ID ")", other_client->node_id, other_client, other_client->last_ring_id.node_id, other_client->last_ring_id.seq);
+ log(LOG_DEBUG, "algo-util: all_ring_ids_match: seen nodeid %d (client %p) ring_id (" UTILS_PRI_RING_ID ")", other_client->node_id, other_client, other_client->last_ring_id.node_id, other_client->last_ring_id.seq);
/* Look down our node list and see if this client is known to us */
TAILQ_FOREACH(node_info, &client->last_membership_node_list, entries) {
* we need to wait until they have all caught up before making a decision
*/
if (in_our_partition && !tlv_ring_id_eq(ring_id, &other_client->last_ring_id)) {
- qnetd_log(LOG_DEBUG, "algo-util: nodeid %d in our partition has different ring_id (" UTILS_PRI_RING_ID ") to us (" UTILS_PRI_RING_ID ")", other_client->node_id, other_client->last_ring_id.node_id, other_client->last_ring_id.seq, ring_id->node_id, ring_id->seq);
+ log(LOG_DEBUG, "algo-util: nodeid %d in our partition has different ring_id (" UTILS_PRI_RING_ID ") to us (" UTILS_PRI_RING_ID ")", other_client->node_id, other_client->last_ring_id.node_id, other_client->last_ring_id.seq, ring_id->node_id, ring_id->seq);
return (-1); /* ring IDs don't match */
}
}
struct qnetd_algo_partition *partition;
TAILQ_FOREACH(partition, partitions_list, entries) {
- qnetd_log(LOG_DEBUG, "algo-util: partition (" UTILS_PRI_RING_ID ") (%p) has %d nodes",
+ log(LOG_DEBUG, "algo-util: partition (" UTILS_PRI_RING_ID ") (%p) has %d nodes",
partition->ring_id.node_id, partition->ring_id.seq, partition, partition->num_nodes);
}
}
#include <sys/types.h>
+#include "log.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];
{
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");
+ log(LOG_CRIT, "qnetd_algorithm_client_init unhandled decision algorithm");
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
}
{
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
- qnetd_log(LOG_CRIT, "qnetd_algorithm_config_node_list_received unhandled "
+ log(LOG_CRIT, "qnetd_algorithm_config_node_list_received unhandled "
"decision algorithm");
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
}
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
- qnetd_log(LOG_CRIT, "qnetd_algorithm_membership_node_list_received unhandled "
+ log(LOG_CRIT, "qnetd_algorithm_membership_node_list_received unhandled "
"decision algorithm");
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
}
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
- qnetd_log(LOG_CRIT, "algorithm_quorum_node_list_received unhandled "
+ log(LOG_CRIT, "algorithm_quorum_node_list_received unhandled "
"decision algorithm");
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
}
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
- qnetd_log(LOG_CRIT, "qnetd_algorithm_client_disconnect unhandled decision "
+ log(LOG_CRIT, "qnetd_algorithm_client_disconnect unhandled decision "
"algorithm");
return;
}
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
- qnetd_log(LOG_CRIT, "qnetd_algorithm_ask_for_vote_received unhandled "
+ log(LOG_CRIT, "qnetd_algorithm_ask_for_vote_received unhandled "
"decision algorithm");
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
}
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
- qnetd_log(LOG_CRIT, "qnetd_algorithm_vote_info_reply_received unhandled decision algorithm");
+ log(LOG_CRIT, "qnetd_algorithm_vote_info_reply_received unhandled decision algorithm");
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
}
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
- qnetd_log(LOG_CRIT, "qnetd_algorithm_ask_for_vote_received unhandled "
+ log(LOG_CRIT, "qnetd_algorithm_ask_for_vote_received unhandled "
"decision algorithm");
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
}
if (client->decision_algorithm >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE ||
qnetd_algorithm_array[client->decision_algorithm] == NULL) {
- qnetd_log(LOG_CRIT, "qnetd_algorithm_timer_callback unhandled decision algorithm");
+ log(LOG_CRIT, "qnetd_algorithm_timer_callback unhandled decision algorithm");
return (TLV_REPLY_ERROR_CODE_INTERNAL_ERROR);
}
{
if (algorithm_number >= QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE) {
- qnetd_log(LOG_CRIT, "Failed to register unsupported decision algorithm %u",
+ log(LOG_CRIT, "Failed to register unsupported decision algorithm %u",
algorithm_number);
return (-1);
}
if (qnetd_algorithm_array[algorithm_number] != NULL) {
- qnetd_log(LOG_CRIT, "Failed to register decision algorithm %u, "
+ log(LOG_CRIT, "Failed to register decision algorithm %u, "
"it's already registered.", algorithm_number);
return (-1);
}
{
if (qnetd_algo_test_register() != 0) {
- qnetd_log(LOG_CRIT, "Failed to register decision algorithm 'test'");
+ log(LOG_CRIT, "Failed to register decision algorithm 'test'");
return (-1);
}
if (qnetd_algo_ffsplit_register() != 0) {
- qnetd_log(LOG_CRIT, "Failed to register decision algorithm 'ffsplit'");
+ log(LOG_CRIT, "Failed to register decision algorithm 'ffsplit'");
return (-1);
}
if (qnetd_algo_2nodelms_register() != 0) {
- qnetd_log(LOG_CRIT, "Failed to register decision algorithm '2nodelms'");
+ log(LOG_CRIT, "Failed to register decision algorithm '2nodelms'");
return (-1);
}
if (qnetd_algo_lms_register() != 0) {
- qnetd_log(LOG_CRIT, "Failed to register decision algorithm 'lms'");
+ log(LOG_CRIT, "Failed to register decision algorithm 'lms'");
return (-1);
}
/*
- * Copyright (c) 2015-2016 Red Hat, Inc.
+ * Copyright (c) 2015-2019 Red Hat, Inc.
*
* All rights reserved.
*
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "qnetd-log.h"
+#include "log.h"
#include "qnetd-client-algo-timer.h"
#include "qnetd-client-send.h"
#include "qnetd-algorithm.h"
&send_vote, &result_vote);
if (reply_error_code != TLV_REPLY_ERROR_CODE_NO_ERROR) {
- qnetd_log(LOG_ERR, "Algorithm for client %s returned error code. "
+ log(LOG_ERR, "Algorithm for client %s returned error code. "
"Sending error reply.", client->addr_str);
if (qnetd_client_send_err(client, 0, 0, reply_error_code) != 0) {
return (0);
} else {
- qnetd_log(LOG_DEBUG, "Algorithm for client %s decided to %s timer and %s vote "
+ log(LOG_DEBUG, "Algorithm for client %s decided to %s timer and %s vote "
"with value %s", client->addr_str,
(reschedule_timer ? "reschedule" : "not reschedule"),
(send_vote ? "send" : "not send"),
if (qnetd_client_algo_timer_is_scheduled(client)) {
if (qnetd_client_algo_timer_abort(client) != 0) {
- qnetd_log(LOG_ERR, "Can't abort algo timer");
+ log(LOG_ERR, "Can't abort algo timer");
return (-1);
}
client->algo_timer = timer_list_add(client->main_timer_list, timeout,
qnetd_client_algo_timer_callback, (void *)client, NULL);
if (client->algo_timer == NULL) {
- qnetd_log(LOG_ERR, "Can't schedule algo timer");
+ log(LOG_ERR, "Can't schedule algo timer");
return (-1);
}
/*
- * Copyright (c) 2015-2017 Red Hat, Inc.
+ * Copyright (c) 2015-2019 Red Hat, Inc.
*
* All rights reserved.
*
#include <sys/types.h>
+#include "log.h"
#include "qnetd-algorithm.h"
#include "qnetd-instance.h"
-#include "qnetd-log.h"
#include "qnetd-log-debug.h"
#include "qnetd-client-send.h"
#include "msg.h"
}
if (!case_processed) {
- qnetd_log(LOG_ERR, "Unhandled instance tls supported %u", instance->tls_supported);
+ log(LOG_ERR, "Unhandled instance tls supported %u", instance->tls_supported);
exit(1);
}
if (tls_required && !client->tls_started) {
- qnetd_log(LOG_ERR, "TLS is required but doesn't started yet. "
+ log(LOG_ERR, "TLS is required but doesn't started yet. "
"Sending back error message");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
peer_cert = SSL_PeerCertificate(client->socket);
if (peer_cert == NULL) {
- qnetd_log(LOG_ERR, "Client doesn't sent valid certificate. "
+ log(LOG_ERR, "Client doesn't sent valid certificate. "
"Disconnecting client");
return (-1);
}
if (CERT_VerifyCertName(peer_cert, client->cluster_name) != SECSuccess) {
- qnetd_log(LOG_ERR, "Client doesn't sent certificate with valid CN. "
+ log(LOG_ERR, "Client doesn't sent certificate with valid CN. "
"Disconnecting client");
CERT_DestroyCertificate(peer_cert);
struct send_buffer_list_entry *send_buffer;
if (msg->cluster_name == NULL) {
- qnetd_log(LOG_ERR, "Received preinit message without cluster name. "
+ log(LOG_ERR, "Received preinit message without cluster name. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
client->cluster_name = malloc(msg->cluster_name_len + 1);
if (client->cluster_name == NULL) {
- qnetd_log(LOG_ERR, "Can't allocate cluster name. Sending error reply.");
+ log(LOG_ERR, "Can't allocate cluster name. Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
TLV_REPLY_ERROR_CODE_INTERNAL_ERROR) != 0) {
send_buffer = send_buffer_list_get_new(&client->send_buffer_list);
if (send_buffer == NULL) {
- qnetd_log(LOG_ERR, "Can't alloc preinit reply msg from list. "
+ log(LOG_ERR, "Can't alloc preinit reply msg from list. "
"Disconnecting client connection.");
return (-1);
if (msg_create_preinit_reply(&send_buffer->buffer, msg->seq_number_set, msg->seq_number,
instance->tls_supported, instance->tls_client_cert_required) == 0) {
- qnetd_log(LOG_ERR, "Can't alloc preinit reply msg. "
+ log(LOG_ERR, "Can't alloc preinit reply msg. "
"Disconnecting client connection.");
send_buffer_list_discard_new(&client->send_buffer_list, send_buffer);
const struct msg_decoded *msg, const char *msg_str)
{
- qnetd_log(LOG_ERR, "Received %s message. Sending back error message", msg_str);
+ log(LOG_ERR, "Received %s message. Sending back error message", msg_str);
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
TLV_REPLY_ERROR_CODE_UNEXPECTED_MESSAGE) != 0) {
PRFileDesc *new_pr_fd;
if (!client->preinit_received) {
- qnetd_log(LOG_ERR, "Received starttls before preinit message. "
+ log(LOG_ERR, "Received starttls before preinit message. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
if ((new_pr_fd = nss_sock_start_ssl_as_server(client->socket, instance->server.cert,
instance->server.private_key, instance->tls_client_cert_required, 0, NULL)) == NULL) {
- qnetd_log_nss(LOG_ERR, "Can't start TLS. Disconnecting client.");
+ log_nss(LOG_ERR, "Can't start TLS. Disconnecting client.");
return (-1);
}
TAILQ_FOREACH(client, &cluster->client_list, cluster_entries) {
if (!tlv_tie_breaker_eq(&new_client->tie_breaker, &client->tie_breaker)) {
- qnetd_log(LOG_ERR, "Received init message contains tie-breaker which "
+ log(LOG_ERR, "Received init message contains tie-breaker which "
"differs from rest of cluster. Sending error reply");
return (TLV_REPLY_ERROR_CODE_TIE_BREAKER_DIFFERS_FROM_OTHER_NODES);
}
if (new_client->decision_algorithm != client->decision_algorithm) {
- qnetd_log(LOG_ERR, "Received init message contains algorithm which "
+ log(LOG_ERR, "Received init message contains algorithm which "
"differs from rest of cluster. Sending error reply");
return (TLV_REPLY_ERROR_CODE_ALGORITHM_DIFFERS_FROM_OTHER_NODES);
}
if (new_client->node_id == client->node_id) {
- qnetd_log(LOG_ERR, "Received init message contains node id which is "
+ log(LOG_ERR, "Received init message contains node id which is "
"duplicate of other node in cluster. Sending error reply");
return (TLV_REPLY_ERROR_CODE_DUPLICATE_NODE_ID);
}
if (!client->preinit_received) {
- qnetd_log(LOG_ERR, "Received init before preinit message. Sending error reply.");
+ log(LOG_ERR, "Received init before preinit message. Sending error reply.");
reply_error_code = TLV_REPLY_ERROR_CODE_PREINIT_REQUIRED;
}
if (reply_error_code == TLV_REPLY_ERROR_CODE_NO_ERROR && !msg->node_id_set) {
- qnetd_log(LOG_ERR, "Received init message without node id set. "
+ log(LOG_ERR, "Received init message without node id set. "
"Sending error reply.");
reply_error_code = TLV_REPLY_ERROR_CODE_DOESNT_CONTAIN_REQUIRED_OPTION;
}
if (reply_error_code == TLV_REPLY_ERROR_CODE_NO_ERROR && !msg->ring_id_set) {
- qnetd_log(LOG_ERR, "Received init message without ring id set. "
+ log(LOG_ERR, "Received init message without ring id set. "
"Sending error reply.");
reply_error_code = TLV_REPLY_ERROR_CODE_DOESNT_CONTAIN_REQUIRED_OPTION;
}
if (reply_error_code == TLV_REPLY_ERROR_CODE_NO_ERROR && !msg->heartbeat_interval_set) {
- qnetd_log(LOG_ERR, "Received init message without heartbeat interval set. "
+ log(LOG_ERR, "Received init message without heartbeat interval set. "
"Sending error reply.");
reply_error_code = TLV_REPLY_ERROR_CODE_DOESNT_CONTAIN_REQUIRED_OPTION;
} else {
if (msg->heartbeat_interval < instance->advanced_settings->heartbeat_interval_min ||
msg->heartbeat_interval > instance->advanced_settings->heartbeat_interval_max) {
- qnetd_log(LOG_ERR, "Client requested invalid heartbeat interval %u. "
+ log(LOG_ERR, "Client requested invalid heartbeat interval %u. "
"Sending error reply.", msg->heartbeat_interval);
reply_error_code = TLV_REPLY_ERROR_CODE_INVALID_HEARTBEAT_INTERVAL;
}
if (reply_error_code == TLV_REPLY_ERROR_CODE_NO_ERROR && !msg->tie_breaker_set) {
- qnetd_log(LOG_ERR, "Received init message without tie-breaker set. "
+ log(LOG_ERR, "Received init message without tie-breaker set. "
"Sending error reply.");
reply_error_code = TLV_REPLY_ERROR_CODE_DOESNT_CONTAIN_REQUIRED_OPTION;
*/
/*
for (i = 0; i < msg->no_supported_messages; i++) {
- qnetd_log(LOG_DEBUG, "Client supports %u message",
+ log(LOG_DEBUG, "Client supports %u message",
(int)msg->supported_messages[i]);
}
*/
*/
/*
for (i = 0; i < msg->no_supported_options; i++) {
- qnetd_log(LOG_DEBUG, "Client supports %u option",
+ log(LOG_DEBUG, "Client supports %u option",
(int)msg->supported_messages[i]);
}
*/
}
if (reply_error_code == TLV_REPLY_ERROR_CODE_NO_ERROR && !msg->decision_algorithm_set) {
- qnetd_log(LOG_ERR, "Received init message without decision algorithm. "
+ log(LOG_ERR, "Received init message without decision algorithm. "
"Sending error reply.");
reply_error_code = TLV_REPLY_ERROR_CODE_DOESNT_CONTAIN_REQUIRED_OPTION;
}
if (!res) {
- qnetd_log(LOG_ERR, "Client requested unsupported decision algorithm %u. "
+ log(LOG_ERR, "Client requested unsupported decision algorithm %u. "
"Sending error reply.", msg->decision_algorithm);
reply_error_code = TLV_REPLY_ERROR_CODE_UNSUPPORTED_DECISION_ALGORITHM;
if (reply_error_code == TLV_REPLY_ERROR_CODE_NO_ERROR) {
cluster = qnetd_cluster_list_add_client(&instance->clusters, client);
if (cluster == NULL) {
- qnetd_log(LOG_ERR, "Can't add client to cluster list. "
+ log(LOG_ERR, "Can't add client to cluster list. "
"Sending error reply.");
reply_error_code = TLV_REPLY_ERROR_CODE_INTERNAL_ERROR;
*/
client->init_received = 1;
} else {
- qnetd_log(LOG_ERR, "Algorithm returned error code. Sending error reply.");
+ log(LOG_ERR, "Algorithm returned error code. Sending error reply.");
}
send_buffer = send_buffer_list_get_new(&client->send_buffer_list);
if (send_buffer == NULL) {
- qnetd_log(LOG_ERR, "Can't alloc init reply msg from list. "
+ log(LOG_ERR, "Can't alloc init reply msg from list. "
"Disconnecting client connection.");
return (-1);
instance->advanced_settings->max_client_send_size,
qnetd_static_supported_decision_algorithms,
QNETD_STATIC_SUPPORTED_DECISION_ALGORITHMS_SIZE) == 0) {
- qnetd_log(LOG_ERR, "Can't alloc init reply msg. Disconnecting client connection.");
+ log(LOG_ERR, "Can't alloc init reply msg. Disconnecting client connection.");
send_buffer_list_discard_new(&client->send_buffer_list, send_buffer);
}
if (!client->init_received) {
- qnetd_log(LOG_ERR, "Received set option message before init message. "
+ log(LOG_ERR, "Received set option message before init message. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
*/
if (msg->heartbeat_interval < instance->advanced_settings->heartbeat_interval_min ||
msg->heartbeat_interval > instance->advanced_settings->heartbeat_interval_max) {
- qnetd_log(LOG_ERR, "Client requested invalid heartbeat interval %u. "
+ log(LOG_ERR, "Client requested invalid heartbeat interval %u. "
"Sending error reply.", msg->heartbeat_interval);
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
send_buffer = send_buffer_list_get_new(&client->send_buffer_list);
if (send_buffer == NULL) {
- qnetd_log(LOG_ERR, "Can't alloc set option reply msg from list. "
+ log(LOG_ERR, "Can't alloc set option reply msg from list. "
"Disconnecting client connection.");
return (-1);
if (msg_create_set_option_reply(&send_buffer->buffer, msg->seq_number_set, msg->seq_number,
client->heartbeat_interval) == 0) {
- qnetd_log(LOG_ERR, "Can't alloc set option reply msg. "
+ log(LOG_ERR, "Can't alloc set option reply msg. "
"Disconnecting client connection.");
send_buffer_list_discard_new(&client->send_buffer_list, send_buffer);
}
if (!client->init_received) {
- qnetd_log(LOG_ERR, "Received echo request before init message. "
+ log(LOG_ERR, "Received echo request before init message. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
send_buffer = send_buffer_list_get_new(&client->send_buffer_list);
if (send_buffer == NULL) {
- qnetd_log(LOG_ERR, "Can't alloc echo reply msg from list. "
+ log(LOG_ERR, "Can't alloc echo reply msg from list. "
"Disconnecting client connection.");
return (-1);
}
if (msg_create_echo_reply(&send_buffer->buffer, msg_orig) == 0) {
- qnetd_log(LOG_ERR, "Can't alloc echo reply msg. Disconnecting client connection.");
+ log(LOG_ERR, "Can't alloc echo reply msg. Disconnecting client connection.");
send_buffer_list_discard_new(&client->send_buffer_list, send_buffer);
}
if (!client->init_received) {
- qnetd_log(LOG_ERR, "Received node list message before init message. "
+ log(LOG_ERR, "Received node list message before init message. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
}
if (!msg->node_list_type_set) {
- qnetd_log(LOG_ERR, "Received node list message without node list type set. "
+ log(LOG_ERR, "Received node list message without node list type set. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
}
if (!msg->seq_number_set) {
- qnetd_log(LOG_ERR, "Received node list message without seq number set. "
+ log(LOG_ERR, "Received node list message without seq number set. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
case TLV_NODE_LIST_TYPE_MEMBERSHIP:
case_processed = 1;
if (!msg->ring_id_set) {
- qnetd_log(LOG_ERR, "Received node list message without ring id number set. "
+ log(LOG_ERR, "Received node list message without ring id number set. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
case TLV_NODE_LIST_TYPE_QUORUM:
case_processed = 1;
if (!msg->quorate_set) {
- qnetd_log(LOG_ERR, "Received quorum list message without quorate set. "
+ log(LOG_ERR, "Received quorum list message without quorate set. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
}
if (!case_processed) {
- qnetd_log(LOG_ERR, "qnetd_client_msg_received_node_list fatal error. "
+ log(LOG_ERR, "qnetd_client_msg_received_node_list fatal error. "
"Unhandled node_list_type");
exit(1);
}
if (reply_error_code != TLV_REPLY_ERROR_CODE_NO_ERROR) {
- qnetd_log(LOG_ERR, "Algorithm returned error code. "
+ log(LOG_ERR, "Algorithm returned error code. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
return (0);
} else {
- qnetd_log(LOG_DEBUG, "Algorithm result vote is %s", tlv_vote_to_str(result_vote));
+ log(LOG_DEBUG, "Algorithm result vote is %s", tlv_vote_to_str(result_vote));
}
/*
case_processed = 1;
node_list_free(&client->configuration_node_list);
if (node_list_clone(&client->configuration_node_list, &msg->nodes) == -1) {
- qnetd_log(LOG_ERR, "Can't alloc config node list clone. "
+ log(LOG_ERR, "Can't alloc config node list clone. "
"Disconnecting client connection.");
return (-1);
case_processed = 1;
node_list_free(&client->last_membership_node_list);
if (node_list_clone(&client->last_membership_node_list, &msg->nodes) == -1) {
- qnetd_log(LOG_ERR, "Can't alloc membership node list clone. "
+ log(LOG_ERR, "Can't alloc membership node list clone. "
"Disconnecting client connection.");
return (-1);
case_processed = 1;
node_list_free(&client->last_quorum_node_list);
if (node_list_clone(&client->last_quorum_node_list, &msg->nodes) == -1) {
- qnetd_log(LOG_ERR, "Can't alloc quorum node list clone. "
+ log(LOG_ERR, "Can't alloc quorum node list clone. "
"Disconnecting client connection.");
return (-1);
}
if (!case_processed) {
- qnetd_log(LOG_ERR, "qnetd_client_msg_received_node_list fatal error. "
+ log(LOG_ERR, "qnetd_client_msg_received_node_list fatal error. "
"Unhandled node_list_type");
exit(1);
}
send_buffer = send_buffer_list_get_new(&client->send_buffer_list);
if (send_buffer == NULL) {
- qnetd_log(LOG_ERR, "Can't alloc node list reply msg from list. "
+ log(LOG_ERR, "Can't alloc node list reply msg from list. "
"Disconnecting client connection.");
return (-1);
if (msg_create_node_list_reply(&send_buffer->buffer, msg->seq_number, msg->node_list_type,
&client->last_ring_id, result_vote) == 0) {
- qnetd_log(LOG_ERR, "Can't alloc node list reply msg. "
+ log(LOG_ERR, "Can't alloc node list reply msg. "
"Disconnecting client connection.");
send_buffer_list_discard_new(&client->send_buffer_list, send_buffer);
}
if (!client->init_received) {
- qnetd_log(LOG_ERR, "Received ask for vote message before init message. "
+ log(LOG_ERR, "Received ask for vote message before init message. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
}
if (!msg->seq_number_set) {
- qnetd_log(LOG_ERR, "Received ask for vote message without seq number set. "
+ log(LOG_ERR, "Received ask for vote message without seq number set. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
&result_vote);
if (reply_error_code != TLV_REPLY_ERROR_CODE_NO_ERROR) {
- qnetd_log(LOG_ERR, "Algorithm returned error code. "
+ log(LOG_ERR, "Algorithm returned error code. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
return (0);
} else {
- qnetd_log(LOG_DEBUG, "Algorithm result vote is %s", tlv_vote_to_str(result_vote));
+ log(LOG_DEBUG, "Algorithm result vote is %s", tlv_vote_to_str(result_vote));
}
/*
send_buffer = send_buffer_list_get_new(&client->send_buffer_list);
if (send_buffer == NULL) {
- qnetd_log(LOG_ERR, "Can't alloc ask for vote reply msg from list. "
+ log(LOG_ERR, "Can't alloc ask for vote reply msg from list. "
"Disconnecting client connection.");
return (-1);
if (msg_create_ask_for_vote_reply(&send_buffer->buffer, msg->seq_number,
&client->last_ring_id, result_vote) == 0) {
- qnetd_log(LOG_ERR, "Can't alloc ask for vote reply msg. "
+ log(LOG_ERR, "Can't alloc ask for vote reply msg. "
"Disconnecting client connection.");
send_buffer_list_discard_new(&client->send_buffer_list, send_buffer);
}
if (!client->init_received) {
- qnetd_log(LOG_ERR, "Received vote info reply before init message. "
+ log(LOG_ERR, "Received vote info reply before init message. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
}
if (!msg->seq_number_set) {
- qnetd_log(LOG_ERR, "Received vote info reply message without seq number set. "
+ log(LOG_ERR, "Received vote info reply message without seq number set. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
reply_error_code = qnetd_algorithm_vote_info_reply_received(client, msg->seq_number);
if (reply_error_code != TLV_REPLY_ERROR_CODE_NO_ERROR) {
- qnetd_log(LOG_ERR, "Algorithm returned error code. "
+ log(LOG_ERR, "Algorithm returned error code. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
}
if (!client->init_received) {
- qnetd_log(LOG_ERR, "Received heuristics change message before init message. "
+ log(LOG_ERR, "Received heuristics change message before init message. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
}
if (!msg->seq_number_set || msg->heuristics == TLV_HEURISTICS_UNDEFINED) {
- qnetd_log(LOG_ERR, "Received heuristics change message without seq number set or "
+ log(LOG_ERR, "Received heuristics change message without seq number set or "
"with undefined heuristics. Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
msg->heuristics, &result_vote);
if (reply_error_code != TLV_REPLY_ERROR_CODE_NO_ERROR) {
- qnetd_log(LOG_ERR, "Algorithm returned error code. "
+ log(LOG_ERR, "Algorithm returned error code. "
"Sending error reply.");
if (qnetd_client_send_err(client, msg->seq_number_set, msg->seq_number,
return (0);
} else {
- qnetd_log(LOG_DEBUG, "Algorithm result vote is %s", tlv_vote_to_str(result_vote));
+ log(LOG_DEBUG, "Algorithm result vote is %s", tlv_vote_to_str(result_vote));
}
/*
send_buffer = send_buffer_list_get_new(&client->send_buffer_list);
if (send_buffer == NULL) {
- qnetd_log(LOG_ERR, "Can't alloc heuristics change reply msg from list. "
+ log(LOG_ERR, "Can't alloc heuristics change reply msg from list. "
"Disconnecting client connection.");
return (-1);
if (msg_create_heuristics_change_reply(&send_buffer->buffer, msg->seq_number,
&client->last_ring_id, msg->heuristics, result_vote) == 0) {
- qnetd_log(LOG_ERR, "Can't alloc heuristics change reply msg. "
+ log(LOG_ERR, "Can't alloc heuristics change reply msg. "
"Disconnecting client connection.");
send_buffer_list_discard_new(&client->send_buffer_list, send_buffer);
/*
* Error occurred. Send server error.
*/
- qnetd_log_msg_decode_error(res);
- qnetd_log(LOG_INFO, "Sending back error message");
+ log_msg_decode_error(res);
+ log(LOG_INFO, "Sending back error message");
if (qnetd_client_send_err(client, msg.seq_number_set, msg.seq_number,
TLV_REPLY_ERROR_CODE_ERROR_DECODING_MSG) != 0) {
}
if (!msg_processed) {
- qnetd_log(LOG_ERR, "Unsupported message %u received from client. "
+ log(LOG_ERR, "Unsupported message %u received from client. "
"Sending back error message", msg.type);
if (qnetd_client_send_err(client, msg.seq_number_set, msg.seq_number,
/*
- * Copyright (c) 2015-2016 Red Hat, Inc.
+ * Copyright (c) 2015-2019 Red Hat, Inc.
*
* All rights reserved.
*
#include <sys/types.h>
+#include "log.h"
#include "msgio.h"
#include "msg.h"
#include "nss-sock.h"
-#include "qnetd-log.h"
#include "qnetd-client-net.h"
#include "qnetd-client-send.h"
#include "qnetd-client-msg-received.h"
send_buffer = send_buffer_list_get_active(&client->send_buffer_list);
if (send_buffer == NULL) {
- qnetd_log_nss(LOG_CRIT, "send_buffer_list_get_active returned NULL");
+ log_nss(LOG_CRIT, "send_buffer_list_get_active returned NULL");
return (-1);
}
}
if (res == -1) {
- qnetd_log_nss(LOG_CRIT, "PR_Send returned 0");
+ log_nss(LOG_CRIT, "PR_Send returned 0");
return (-1);
}
if (res == -2) {
- qnetd_log_nss(LOG_ERR, "Unhandled error when sending message to client");
+ log_nss(LOG_ERR, "Unhandled error when sending message to client");
return (-1);
}
&client->msg_already_received_bytes, &client->skipping_msg);
if (!orig_skipping_msg && client->skipping_msg) {
- qnetd_log(LOG_DEBUG, "msgio_read set skipping_msg");
+ log(LOG_DEBUG, "msgio_read set skipping_msg");
}
ret_val = 0;
*/
break;
case -1:
- qnetd_log(LOG_DEBUG, "Client closed connection");
+ log(LOG_DEBUG, "Client closed connection");
ret_val = -1;
break;
case -2:
- qnetd_log_nss(LOG_ERR, "Unhandled error when reading from client. "
+ log_nss(LOG_ERR, "Unhandled error when reading from client. "
"Disconnecting client");
ret_val = -1;
break;
case -3:
- qnetd_log(LOG_ERR, "Can't store message header from client. Disconnecting client");
+ log(LOG_ERR, "Can't store message header from client. Disconnecting client");
ret_val = -1;
break;
case -4:
- qnetd_log(LOG_ERR, "Can't store message from client. Skipping message");
+ log(LOG_ERR, "Can't store message from client. Skipping message");
client->skipping_msg_reason = TLV_REPLY_ERROR_CODE_ERROR_DECODING_MSG;
break;
case -5:
- qnetd_log(LOG_WARNING, "Client sent unsupported msg type %u. Skipping message",
+ log(LOG_WARNING, "Client sent unsupported msg type %u. Skipping message",
msg_get_type(&client->receive_buffer));
client->skipping_msg_reason = TLV_REPLY_ERROR_CODE_UNSUPPORTED_MESSAGE;
break;
case -6:
- qnetd_log(LOG_WARNING,
+ log(LOG_WARNING,
"Client wants to send too long message %u bytes. Skipping message",
msg_get_len(&client->receive_buffer));
client->skipping_msg_reason = TLV_REPLY_ERROR_CODE_MESSAGE_TOO_LONG;
dynar_clean(&client->receive_buffer);
break;
default:
- qnetd_log(LOG_ERR, "Unhandled msgio_read error %d\n", res);
+ log(LOG_ERR, "Unhandled msgio_read error %d\n", res);
exit(1);
break;
}
if ((client_socket = PR_Accept(instance->server.socket, &client_addr,
PR_INTERVAL_NO_TIMEOUT)) == NULL) {
- qnetd_log_nss(LOG_ERR, "Can't accept connection");
+ log_nss(LOG_ERR, "Can't accept connection");
return (-1);
}
if (nss_sock_set_non_blocking(client_socket) != 0) {
- qnetd_log_nss(LOG_ERR, "Can't set client socket to non blocking mode");
+ log_nss(LOG_ERR, "Can't set client socket to non blocking mode");
goto exit_close;
}
if (instance->max_clients != 0 &&
qnetd_client_list_no_clients(&instance->clients) >= instance->max_clients) {
- qnetd_log(LOG_ERR, "Maximum clients reached. Not accepting connection");
+ log(LOG_ERR, "Maximum clients reached. Not accepting connection");
goto exit_close;
}
client_addr_str = malloc(CLIENT_ADDR_STR_LEN);
if (client_addr_str == NULL) {
- qnetd_log(LOG_ERR, "Can't alloc client addr str memory. Not accepting connection");
+ log(LOG_ERR, "Can't alloc client addr str memory. Not accepting connection");
goto exit_close;
}
if (PR_NetAddrToString(&client_addr, client_addr_str, CLIENT_ADDR_STR_LEN) != PR_SUCCESS) {
- qnetd_log_nss(LOG_ERR, "Can't convert client address to string. Not accepting connection");
+ log_nss(LOG_ERR, "Can't convert client address to string. Not accepting connection");
goto exit_close;
}
if (snprintf(client_addr_str + strlen(client_addr_str),
CLIENT_ADDR_STR_LEN_COLON_PORT, ":%"PRIu16,
ntohs(client_addr.ipv6.port)) >= CLIENT_ADDR_STR_LEN_COLON_PORT) {
- qnetd_log(LOG_ERR, "Can't store port to client addr str. Not accepting connection");
+ log(LOG_ERR, "Can't store port to client addr str. Not accepting connection");
goto exit_close;
}
instance->advanced_settings->max_client_send_buffers,
instance->advanced_settings->max_client_send_size, &instance->main_timer_list);
if (client == NULL) {
- qnetd_log(LOG_ERR, "Can't add client to list");
+ log(LOG_ERR, "Can't add client to list");
res_err = -2;
goto exit_close;
}
/*
- * Copyright (c) 2015-2016 Red Hat, Inc.
+ * Copyright (c) 2015-2019 Red Hat, Inc.
*
* All rights reserved.
*
#include <string.h>
+#include "log.h"
#include "qnetd-client-send.h"
-#include "qnetd-log.h"
#include "qnetd-log-debug.h"
#include "msg.h"
send_buffer = send_buffer_list_get_new(&client->send_buffer_list);
if (send_buffer == NULL) {
- qnetd_log(LOG_ERR, "Can't alloc server error msg from list. "
+ log(LOG_ERR, "Can't alloc server error msg from list. "
"Disconnecting client connection.");
return (-1);
if (msg_create_server_error(&send_buffer->buffer, add_msg_seq_number,
msg_seq_number, reply) == 0) {
- qnetd_log(LOG_ERR, "Can't alloc server error msg. "
+ log(LOG_ERR, "Can't alloc server error msg. "
"Disconnecting client connection.");
send_buffer_list_discard_new(&client->send_buffer_list, send_buffer);
send_buffer = send_buffer_list_get_new(&client->send_buffer_list);
if (send_buffer == NULL) {
- qnetd_log(LOG_ERR, "Can't alloc vote info msg from list. "
+ log(LOG_ERR, "Can't alloc vote info msg from list. "
"Disconnecting client connection.");
return (-1);
}
if (msg_create_vote_info(&send_buffer->buffer, msg_seq_number, ring_id, vote) == 0) {
- qnetd_log(LOG_ERR, "Can't alloc vote info msg. "
+ log(LOG_ERR, "Can't alloc vote info msg. "
"Disconnecting client connection.");
send_buffer_list_discard_new(&client->send_buffer_list, send_buffer);
* THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "log.h"
#include "qnetd-dpd-timer.h"
-#include "qnetd-log.h"
static int
qnetd_dpd_timer_cb(void *data1, void *data2)
if (client->dpd_time_since_last_check > (client->heartbeat_interval * 2)) {
if (!client->dpd_msg_received_since_last_check) {
- qnetd_log(LOG_WARNING, "Client %s doesn't sent any message during "
+ log(LOG_WARNING, "Client %s doesn't sent any message during "
"%"PRIu32"ms. Disconnecting",
client->addr_str, client->dpd_time_since_last_check);
instance->advanced_settings->dpd_interval,
qnetd_dpd_timer_cb, (void *)instance, NULL);
if (instance->dpd_timer == NULL) {
- qnetd_log(LOG_ERR, "Can't initialize dpd timer");
+ log(LOG_ERR, "Can't initialize dpd timer");
return (-1);
}
/*
- * Copyright (c) 2015-2016 Red Hat, Inc.
+ * Copyright (c) 2015-2019 Red Hat, Inc.
*
* All rights reserved.
*
/*
- * Copyright (c) 2015-2016 Red Hat, Inc.
+ * Copyright (c) 2015-2019 Red Hat, Inc.
*
* All rights reserved.
*
* THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "log.h"
#include "dynar-str.h"
#include "qnetd-ipc-cmd.h"
-#include "qnetd-log.h"
#include "utils.h"
int
/*
- * Copyright (c) 2015-2016 Red Hat, Inc.
+ * Copyright (c) 2015-2019 Red Hat, Inc.
*
* All rights reserved.
*
* THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "log.h"
#include "qnet-config.h"
#include "qnetd-ipc.h"
#include "qnetd-ipc-cmd.h"
-#include "qnetd-log.h"
#include "unix-socket-ipc.h"
#include "dynar-simple-lex.h"
#include "dynar-str.h"
instance->advanced_settings->ipc_max_clients,
instance->advanced_settings->ipc_max_receive_size,
instance->advanced_settings->ipc_max_send_size) != 0) {
- qnetd_log_err(LOG_ERR, "Can't create unix socket");
+ log_err(LOG_ERR, "Can't create unix socket");
return (-1);
}
if ((instance->ipc_socket_poll_fd = PR_CreateSocketPollFd(instance->local_ipc.socket)) == NULL) {
- qnetd_log_nss(LOG_CRIT, "Can't create NSPR IPC socket poll fd");
+ log_nss(LOG_CRIT, "Can't create NSPR IPC socket poll fd");
return (-1);
}
res = unix_socket_ipc_close(&instance->local_ipc);
if (res != 0) {
- qnetd_log_err(LOG_WARNING, "Can't close local IPC");
+ log_err(LOG_WARNING, "Can't close local IPC");
}
return (res);
}
if (PR_DestroySocketPollFd(instance->ipc_socket_poll_fd) != PR_SUCCESS) {
- qnetd_log_nss(LOG_WARNING, "Unable to destroy IPC poll socket fd");
+ log_nss(LOG_WARNING, "Unable to destroy IPC poll socket fd");
}
res = unix_socket_ipc_destroy(&instance->local_ipc);
if (res != 0) {
- qnetd_log_err(LOG_WARNING, "Can't destroy local IPC");
+ log_err(LOG_WARNING, "Can't destroy local IPC");
}
return (res);
switch (accept_res) {
case -1:
- qnetd_log_err(LOG_ERR, "Can't accept local IPC connection");
+ log_err(LOG_ERR, "Can't accept local IPC connection");
res = -1;
goto return_res;
break;
case -2:
- qnetd_log(LOG_ERR, "Maximum IPC clients reached. Not accepting connection");
+ log(LOG_ERR, "Maximum IPC clients reached. Not accepting connection");
res = -1;
goto return_res;
break;
case -3:
- qnetd_log(LOG_ERR, "Can't add client to list");
+ log(LOG_ERR, "Can't add client to list");
res = -1;
goto return_res;
break;
(*res_client)->user_data = malloc(sizeof(struct qnetd_ipc_user_data));
if ((*res_client)->user_data == NULL) {
- qnetd_log(LOG_ERR, "Can't alloc IPC client user data");
+ log(LOG_ERR, "Can't alloc IPC client user data");
res = -1;
qnetd_ipc_client_disconnect(instance, *res_client);
prfd = PR_CreateSocketPollFd((*res_client)->socket);
if (prfd == NULL) {
- qnetd_log_nss(LOG_CRIT, "Can't create NSPR poll fd for IPC client. Disconnecting client");
+ log_nss(LOG_CRIT, "Can't create NSPR poll fd for IPC client. Disconnecting client");
qnetd_ipc_client_disconnect(instance, *res_client);
res = -1;
if ((struct qnetd_ipc_user_data *)(client)->user_data != NULL &&
PR_DestroySocketPollFd(
((struct qnetd_ipc_user_data *)(client)->user_data)->nspr_poll_fd) != PR_SUCCESS) {
- qnetd_log_nss(LOG_WARNING, "Unable to destroy client IPC poll socket fd");
+ log_nss(LOG_WARNING, "Unable to destroy client IPC poll socket fd");
}
free(client->user_data);
if (res) {
unix_socket_client_write_buffer(client, 1);
} else {
- qnetd_log(LOG_ERR, "Can't send ipc error to client (buffer too small)");
+ log(LOG_ERR, "Can't send ipc error to client (buffer too small)");
}
return (res ? 0 : -1);
{
if (dynar_str_prepend(&client->send_buffer, "OK\n") != 0) {
- qnetd_log(LOG_ERR, "Can't send ipc message to client (buffer too small)");
+ log(LOG_ERR, "Can't send ipc message to client (buffer too small)");
if (qnetd_ipc_send_error(instance, client, "Internal IPC buffer too small") != 0) {
return (-1);
str = dynar_data(token);
if (strcasecmp(str, "") == 0) {
- qnetd_log(LOG_DEBUG, "IPC client doesn't send command");
+ log(LOG_DEBUG, "IPC client doesn't send command");
if (qnetd_ipc_send_error(instance, client, "No command specified") != 0) {
client->schedule_disconnect = 1;
}
} else if (strcasecmp(str, "shutdown") == 0) {
- qnetd_log(LOG_DEBUG, "IPC client requested shutdown");
+ log(LOG_DEBUG, "IPC client requested shutdown");
ipc_user_data->shutdown_requested = 1;
free(cluster_name); cluster_name = NULL;
} else {
- qnetd_log(LOG_DEBUG, "IPC client sent unknown command");
+ log(LOG_DEBUG, "IPC client sent unknown command");
if (qnetd_ipc_send_error(instance, client, "Unknown command '%s'", str) != 0) {
client->schedule_disconnect = 1;
}
exit_err_low_mem:
free(cluster_name); cluster_name = NULL;
- qnetd_log(LOG_ERR, "Can't alloc memory for simple lex");
+ log(LOG_ERR, "Can't alloc memory for simple lex");
if (qnetd_ipc_send_error(instance, client, "Command too long") != 0) {
client->schedule_disconnect = 1;
*/
break;
case -1:
- qnetd_log(LOG_DEBUG, "IPC client closed connection");
+ log(LOG_DEBUG, "IPC client closed connection");
client->schedule_disconnect = 1;
break;
case -2:
- qnetd_log(LOG_ERR, "Can't store message from IPC client. Disconnecting client.");
+ log(LOG_ERR, "Can't store message from IPC client. Disconnecting client.");
client->schedule_disconnect = 1;
break;
case -3:
- qnetd_log_err(LOG_ERR, "Can't receive message from IPC client. Disconnecting client.");
+ log_err(LOG_ERR, "Can't receive message from IPC client. Disconnecting client.");
client->schedule_disconnect = 1;
break;
case 1:
*/
break;
case -1:
- qnetd_log(LOG_DEBUG, "IPC client closed connection");
+ log(LOG_DEBUG, "IPC client closed connection");
client->schedule_disconnect = 1;
break;
case -2:
- qnetd_log_err(LOG_ERR, "Can't send message to IPC client. Disconnecting client");
+ log_err(LOG_ERR, "Can't send message to IPC client. Disconnecting client");
client->schedule_disconnect = 1;
break;
case 1:
/*
- * Copyright (c) 2015-2017 Red Hat, Inc.
+ * Copyright (c) 2015-2019 Red Hat, Inc.
*
* All rights reserved.
*
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "qnetd-log.h"
+#include "log.h"
#include "qnetd-log-debug.h"
#include "utils.h"
{
struct qnetd_client *client;
- qnetd_log(LOG_DEBUG, " cluster dump:");
+ log(LOG_DEBUG, " cluster dump:");
TAILQ_FOREACH(client, &cluster->client_list, cluster_entries) {
- qnetd_log(LOG_DEBUG, " client = %s, node_id = "UTILS_PRI_NODE_ID,
+ log(LOG_DEBUG, " client = %s, node_id = "UTILS_PRI_NODE_ID,
client->addr_str, client->node_id);
}
}
qnetd_log_debug_new_client_connected(struct qnetd_client *client)
{
- qnetd_log(LOG_DEBUG, "New client connected");
- qnetd_log(LOG_DEBUG, " cluster name = %s", client->cluster_name);
- qnetd_log(LOG_DEBUG, " tls started = %u", client->tls_started);
- qnetd_log(LOG_DEBUG, " tls peer certificate verified = %u",
+ log(LOG_DEBUG, "New client connected");
+ log(LOG_DEBUG, " cluster name = %s", client->cluster_name);
+ log(LOG_DEBUG, " tls started = %u", client->tls_started);
+ log(LOG_DEBUG, " tls peer certificate verified = %u",
client->tls_peer_certificate_verified);
- qnetd_log(LOG_DEBUG, " node_id = "UTILS_PRI_NODE_ID, client->node_id);
- qnetd_log(LOG_DEBUG, " pointer = %p", client);
- qnetd_log(LOG_DEBUG, " addr_str = %s", client->addr_str);
- qnetd_log(LOG_DEBUG, " ring id = (" UTILS_PRI_RING_ID ")", client->last_ring_id.node_id,
+ log(LOG_DEBUG, " node_id = "UTILS_PRI_NODE_ID, client->node_id);
+ log(LOG_DEBUG, " pointer = %p", client);
+ log(LOG_DEBUG, " addr_str = %s", client->addr_str);
+ log(LOG_DEBUG, " ring id = (" UTILS_PRI_RING_ID ")", client->last_ring_id.node_id,
client->last_ring_id.seq);
qnetd_log_debug_dump_cluster(client->cluster);
{
struct node_list_entry *node_info;
- qnetd_log(LOG_DEBUG, " node list:");
+ log(LOG_DEBUG, " node list:");
TAILQ_FOREACH(node_info, nodes, entries) {
- qnetd_log(LOG_DEBUG, " node_id = "UTILS_PRI_NODE_ID", "
+ log(LOG_DEBUG, " node_id = "UTILS_PRI_NODE_ID", "
"data_center_id = "UTILS_PRI_DATACENTER_ID", "
"node_state = %s", node_info->node_id, node_info->data_center_id,
tlv_node_state_to_str(node_info->node_state));
const struct node_list *nodes, int initial)
{
- qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
+ log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
"sent %s node list.", client->addr_str, client->cluster_name, client->node_id,
(initial ? "initial" : "changed"));
- qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
+ log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
if (config_version_set) {
- qnetd_log(LOG_DEBUG, " config version = " UTILS_PRI_CONFIG_VERSION, config_version);
+ log(LOG_DEBUG, " config version = " UTILS_PRI_CONFIG_VERSION, config_version);
}
qnetd_log_debug_dump_node_list(client, nodes);
uint32_t msg_seq_num, const struct tlv_ring_id *ring_id,
enum tlv_heuristics heuristics, const struct node_list *nodes)
{
- qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
+ log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
"sent membership node list.", client->addr_str, client->cluster_name, client->node_id);
- qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
+ log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
- qnetd_log(LOG_DEBUG, " ring id = (" UTILS_PRI_RING_ID ")", ring_id->node_id, ring_id->seq);
+ log(LOG_DEBUG, " ring id = (" UTILS_PRI_RING_ID ")", ring_id->node_id, ring_id->seq);
- qnetd_log(LOG_DEBUG, " heuristics = %s ", tlv_heuristics_to_str(heuristics));
+ log(LOG_DEBUG, " heuristics = %s ", tlv_heuristics_to_str(heuristics));
qnetd_log_debug_dump_node_list(client, nodes);
}
uint32_t msg_seq_num, enum tlv_quorate quorate, const struct node_list *nodes)
{
- qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
+ log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
"sent quorum node list.", client->addr_str, client->cluster_name, client->node_id);
- qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
- qnetd_log(LOG_DEBUG, " quorate = %u", quorate);
+ log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
+ log(LOG_DEBUG, " quorate = %u", quorate);
qnetd_log_debug_dump_node_list(client, nodes);
}
qnetd_log_debug_client_disconnect(struct qnetd_client *client, int server_going_down)
{
- qnetd_log(LOG_DEBUG, "Client %s (init_received %u, cluster %s, node_id "
+ log(LOG_DEBUG, "Client %s (init_received %u, cluster %s, node_id "
UTILS_PRI_NODE_ID") disconnect%s", client->addr_str, client->init_received,
client->cluster_name, client->node_id,
(server_going_down ? " (server is going down)" : ""));
qnetd_log_debug_ask_for_vote_received(struct qnetd_client *client, uint32_t msg_seq_num)
{
- qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
+ log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
"asked for a vote", client->addr_str, client->cluster_name, client->node_id);
- qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
+ log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
}
void
qnetd_log_debug_vote_info_reply_received(struct qnetd_client *client, uint32_t msg_seq_num)
{
- qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
+ log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
"replied back to vote info message", client->addr_str, client->cluster_name,
client->node_id);
- qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
+ log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
}
void
qnetd_log_debug_send_vote_info(struct qnetd_client *client, uint32_t msg_seq_num, enum tlv_vote vote)
{
- qnetd_log(LOG_DEBUG, "Sending vote info to client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") ",
+ log(LOG_DEBUG, "Sending vote info to client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") ",
client->addr_str, client->cluster_name, client->node_id);
- qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
- qnetd_log(LOG_DEBUG, " vote = %s", tlv_vote_to_str(vote));
+ log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
+ log(LOG_DEBUG, " vote = %s", tlv_vote_to_str(vote));
}
void
enum tlv_heuristics heuristics)
{
- qnetd_log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
+ log(LOG_DEBUG, "Client %s (cluster %s, node_id "UTILS_PRI_NODE_ID") "
"sent heuristics change", client->addr_str, client->cluster_name, client->node_id);
- qnetd_log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
- qnetd_log(LOG_DEBUG, " heuristics = %s", tlv_heuristics_to_str(heuristics));
+ log(LOG_DEBUG, " msg seq num = "UTILS_PRI_MSG_SEQ, msg_seq_num);
+ log(LOG_DEBUG, " heuristics = %s", tlv_heuristics_to_str(heuristics));
}
+++ /dev/null
-/*
- * Copyright (c) 2015-2016 Red Hat, Inc.
- *
- * All rights reserved.
- *
- * Author: Jan Friesse (jfriesse@redhat.com)
- *
- * This software licensed under BSD license, the text of which follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the Red Hat, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <syslog.h>
-#include <stdio.h>
-#include <time.h>
-
-#include "qnet-config.h"
-#include "qnetd-log.h"
-
-static int qnetd_log_config_target = 0;
-static int qnetd_log_config_debug = 0;
-static int qnetd_log_config_priority_bump = 0;
-
-static const char qnetd_log_month_str[][4] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
-};
-
-struct qnetd_log_syslog_prio_to_str_item {
- int priority;
- const char *priority_str;
-};
-
-static struct qnetd_log_syslog_prio_to_str_item qnetd_syslog_prio_to_str_array[] = {
- {LOG_EMERG, "emerg"},
- {LOG_ALERT, "alert"},
- {LOG_CRIT, "crit"},
- {LOG_ERR, "error"},
- {LOG_WARNING, "warning"},
- {LOG_NOTICE, "notice"},
- {LOG_INFO, "info"},
- {LOG_DEBUG, "debug"},
- {-1, NULL}};
-
-void
-qnetd_log_init(int target)
-{
-
- qnetd_log_config_target = target;
-
- if (qnetd_log_config_target & QNETD_LOG_TARGET_SYSLOG) {
- openlog(QNETD_PROGRAM_NAME, LOG_PID, LOG_DAEMON);
- }
-}
-
-static const char *
-qnetd_log_syslog_prio_to_str(int priority)
-{
-
- if (priority >= LOG_EMERG && priority <= LOG_DEBUG) {
- return (qnetd_syslog_prio_to_str_array[priority].priority_str);
- } else {
- return ("none");
- }
-}
-
-void
-qnetd_log_vprintf(int priority, const char *format, va_list ap)
-{
- time_t current_time;
- struct tm tm_res;
- int final_priority;
- va_list ap_copy;
-
- if (priority != LOG_DEBUG || (qnetd_log_config_debug)) {
- if (qnetd_log_config_target & QNETD_LOG_TARGET_STDERR) {
- current_time = time(NULL);
- localtime_r(¤t_time, &tm_res);
-
- fprintf(stderr, "%s %02d %02d:%02d:%02d ",
- qnetd_log_month_str[tm_res.tm_mon], tm_res.tm_mday, tm_res.tm_hour,
- tm_res.tm_min, tm_res.tm_sec);
-
- fprintf(stderr, "%-7s ", qnetd_log_syslog_prio_to_str(priority));
-
- va_copy(ap_copy, ap);
- vfprintf(stderr, format, ap_copy);
- va_end(ap_copy);
- fprintf(stderr, "\n");
- }
-
- if (qnetd_log_config_target & QNETD_LOG_TARGET_SYSLOG) {
- final_priority = priority;
- if (qnetd_log_config_priority_bump && priority > LOG_INFO) {
- final_priority = LOG_INFO;
- }
-
- va_copy(ap_copy, ap);
- vsyslog(final_priority, format, ap);
- va_end(ap_copy);
- }
- }
-}
-
-void
-qnetd_log_printf(int priority, const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
-
- qnetd_log_vprintf(priority, format, ap);
-
- va_end(ap);
-}
-
-void
-qnetd_log_close(void)
-{
-
- if (qnetd_log_config_target & QNETD_LOG_TARGET_SYSLOG) {
- closelog();
- }
-}
-
-void
-qnetd_log_set_debug(int enabled)
-{
-
- qnetd_log_config_debug = enabled;
-}
-
-void
-qnetd_log_set_priority_bump(int enabled)
-{
-
- qnetd_log_config_priority_bump = enabled;
-}
-
-void
-qnetd_log_msg_decode_error(int ret)
-{
-
- switch (ret) {
- case -1:
- qnetd_log(LOG_WARNING, "Received message with option with invalid length");
- break;
- case -2:
- qnetd_log(LOG_CRIT, "Can't allocate memory");
- break;
- case -3:
- qnetd_log(LOG_WARNING, "Received inconsistent msg (tlv len > msg size)");
- break;
- case -4:
- qnetd_log(LOG_WARNING, "Received message with option with invalid value");
- break;
- default:
- qnetd_log(LOG_ERR, "Unknown error occurred when decoding message");
- break;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015-2016 Red Hat, Inc.
- *
- * All rights reserved.
- *
- * Author: Jan Friesse (jfriesse@redhat.com)
- *
- * This software licensed under BSD license, the text of which follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the Red Hat, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _QNETD_LOG_H_
-#define _QNETD_LOG_H_
-
-#include <syslog.h>
-#include <stdarg.h>
-#include <errno.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define QNETD_LOG_TARGET_STDERR 1
-#define QNETD_LOG_TARGET_SYSLOG 2
-
-#define qnetd_log(...) qnetd_log_printf(__VA_ARGS__)
-#define qnetd_log_nss(priority, str) qnetd_log_printf(priority, "%s (%d): %s", \
- str, PR_GetError(), PR_ErrorToString(PR_GetError(), PR_LANGUAGE_I_DEFAULT));
-
-#define qnetd_log_err(priority, str) qnetd_log_printf(priority, "%s (%d): %s", \
- str, errno, strerror(errno))
-
-extern void qnetd_log_init(int target);
-
-extern void qnetd_log_printf(int priority, const char *format, ...)
- __attribute__((__format__(__printf__, 2, 3)));
-
-extern void qnetd_log_vprintf(int priority, const char *format, va_list ap)
- __attribute__((__format__(__printf__, 2, 0)));
-
-extern void qnetd_log_close(void);
-
-extern void qnetd_log_set_debug(int enabled);
-
-extern void qnetd_log_set_priority_bump(int enabled);
-
-extern void qnetd_log_msg_decode_error(int ret);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _QNETD_LOG_H_ */