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 <jeremie.galarneau@efficios.com>
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: