[lttng-dev] [PATCH lttng-tools 1/2] Fix: error handling on relay version check
Julien Desfossez
jdesfossez at efficios.com
Wed Feb 14 16:32:44 EST 2018
If we have a network error while performing the version check between
the session daemon and the relay, we should not report to the user that
there is a version mismatch. We now return LTTNG_ERR_RELAYD_VERSION_FAIL
on relayd_version_check() when the daemons are not compatible and the
negative value from sendmsg/recvmsg on network errors.
Signed-off-by: Julien Desfossez <jdesfossez at efficios.com>
---
src/bin/lttng-sessiond/cmd.c | 7 +++++--
src/common/relayd/relayd.c | 5 +++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c
index 1edcffe..0317d52 100644
--- a/src/bin/lttng-sessiond/cmd.c
+++ b/src/bin/lttng-sessiond/cmd.c
@@ -877,8 +877,11 @@ static int create_connect_relayd(struct lttng_uri *uri,
/* Check relayd version */
ret = relayd_version_check(rsock);
- if (ret < 0) {
- ret = LTTNG_ERR_RELAYD_VERSION_FAIL;
+ if (ret == LTTNG_ERR_RELAYD_VERSION_FAIL) {
+ goto close_sock;
+ } else if (ret < 0) {
+ ERR("Unable to reach lttng-relayd");
+ ret = LTTNG_ERR_RELAYD_CONNECT_FAIL;
goto close_sock;
}
consumer->relay_major_version = rsock->major;
diff --git a/src/common/relayd/relayd.c b/src/common/relayd/relayd.c
index 2adcbe4..4cb1c1f 100644
--- a/src/common/relayd/relayd.c
+++ b/src/common/relayd/relayd.c
@@ -378,7 +378,8 @@ end:
* If major versions are compatible, we assign minor_to_use to the
* minor version of the procotol we are going to use for this session.
*
- * Return 0 if compatible else negative value.
+ * Return 0 if the two daemons are compatible, LTTNG_ERR_RELAYD_VERSION_FAIL
+ * otherwise, or a negative value on network errors.
*/
int relayd_version_check(struct lttcomm_relayd_sock *rsock)
{
@@ -420,7 +421,7 @@ int relayd_version_check(struct lttcomm_relayd_sock *rsock)
*/
if (msg.major != rsock->major) {
/* Not compatible */
- ret = -1;
+ ret = LTTNG_ERR_RELAYD_VERSION_FAIL;
DBG2("Relayd version is NOT compatible. Relayd version %u != %u (us)",
msg.major, rsock->major);
goto error;
--
2.7.4
More information about the lttng-dev
mailing list