mirror of
https://git.proxmox.com/git/mirror_corosync-qdevice
synced 2025-04-28 16:33:21 +00:00
qdevice: Merge msg_decode_error functions
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
This commit is contained in:
parent
313d42d1e1
commit
fed67019b4
@ -50,6 +50,7 @@ corosync_qnetd_SOURCES = corosync-qnetd.c \
|
||||
nss-sock.c nss-sock.h qnetd-client.c qnetd-client.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 \
|
||||
log-common.c log-common.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 \
|
||||
qnetd-algo-utils.c qnetd-algo-utils.h \
|
||||
|
@ -54,3 +54,26 @@ log_common_debug_dump_node_list(const struct node_list *nlist)
|
||||
zi++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
log_common_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;
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ extern "C" {
|
||||
|
||||
extern void log_common_debug_dump_node_list(const struct node_list *nlist);
|
||||
|
||||
extern void log_common_msg_decode_error(int ret);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -178,26 +178,3 @@ log_set_target(int target, int syslog_facility)
|
||||
openlog(log_config_ident, LOG_PID, log_config_syslog_facility);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -69,8 +69,6 @@ extern void log_set_priority_bump(int enabled);
|
||||
|
||||
extern void log_set_target(int target, int syslog_facility);
|
||||
|
||||
extern void log_msg_decode_error(int ret);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include "log-common.h"
|
||||
#include "qdevice-net-algorithm.h"
|
||||
#include "qdevice-net-cast-vote-timer.h"
|
||||
#include "qdevice-net-heuristics.h"
|
||||
@ -83,29 +84,6 @@ qdevice_net_msg_received_check_tls_compatibility(enum tlv_tls_supported server_t
|
||||
return (res);
|
||||
}
|
||||
|
||||
static void
|
||||
qdevice_net_msg_received_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_ERR, "Received message with option with invalid value");
|
||||
break;
|
||||
default:
|
||||
log(LOG_ERR, "Unknown error occurred when decoding message");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
qdevice_net_msg_received_unexpected_msg(struct qdevice_net_instance *instance,
|
||||
const struct msg_decoded *msg, const char *msg_str)
|
||||
@ -881,7 +859,7 @@ qdevice_net_msg_received(struct qdevice_net_instance *instance)
|
||||
/*
|
||||
* Error occurred. Disconnect.
|
||||
*/
|
||||
qdevice_net_msg_received_log_msg_decode_error(res);
|
||||
log_common_msg_decode_error(res);
|
||||
log(LOG_ERR, "Disconnecting from server");
|
||||
instance->disconnect_reason = QDEVICE_NET_DISCONNECT_REASON_MSG_DECODE_ERROR;
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "log-common.h"
|
||||
#include "qnetd-algorithm.h"
|
||||
#include "qnetd-instance.h"
|
||||
#include "qnetd-log-debug.h"
|
||||
@ -1142,7 +1143,7 @@ qnetd_client_msg_received(struct qnetd_instance *instance, struct qnetd_client *
|
||||
/*
|
||||
* Error occurred. Send server error.
|
||||
*/
|
||||
log_msg_decode_error(res);
|
||||
log_common_msg_decode_error(res);
|
||||
log(LOG_INFO, "Sending back error message");
|
||||
|
||||
if (qnetd_client_send_err(client, msg.seq_number_set, msg.seq_number,
|
||||
|
Loading…
Reference in New Issue
Block a user