From 06586bbe5daca94845ab53f177883eb97e56bf50 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 6 Mar 2018 11:35:23 -0500 Subject: [PATCH] Fix: relayd send_command() util not logging on failure MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit send_command() only logs if it succeeds in sending a command to the relay daemon. This commit makes the helper log _before_ sending the command so that errors can be associated back to the command being sent. Moreover, PERROR() is used to log errors returned by sendmsg(). Signed-off-by: Jérémie Galarneau --- src/common/relayd/relayd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/relayd/relayd.c b/src/common/relayd/relayd.c index c3ad597ed..7e6520d29 100644 --- a/src/common/relayd/relayd.c +++ b/src/common/relayd/relayd.c @@ -72,14 +72,14 @@ static int send_command(struct lttcomm_relayd_sock *rsock, memcpy(buf + sizeof(header), data, size); } + DBG3("Relayd sending command %d of size %" PRIu64, (int) cmd, buf_size); ret = rsock->sock.ops->sendmsg(&rsock->sock, buf, buf_size, flags); if (ret < 0) { + PERROR("Failed to send command %d of size %" PRIu64, + (int) cmd, buf_size); ret = -errno; goto error; } - - DBG3("Relayd sending command %d of size %" PRIu64, cmd, buf_size); - error: free(buf); alloc_error: -- 2.34.1