From: Jérémie Galarneau Date: Tue, 6 Mar 2018 16:35:23 +0000 (-0500) Subject: Fix: relayd send_command() util not logging on failure X-Git-Tag: v2.10.4~10 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6c1a60c61e5e06102bdd42f64075c3c754e324eb;p=lttng-tools.git Fix: relayd send_command() util not logging on failure 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 --- diff --git a/src/common/relayd/relayd.c b/src/common/relayd/relayd.c index 4cb1c1fd3..b936a4d3e 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: