From: Julien Desfossez Date: Wed, 14 Feb 2018 21:32:44 +0000 (-0500) Subject: Fix: error handling on relay version check X-Git-Tag: v2.10.3~6 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=84a1ef69143f198278fb8fc2cf66dcd1da82a70e;p=lttng-tools.git Fix: error handling on relay version check If a network error occurs 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. LTTNG_ERR_RELAYD_VERSION_FAIL is now returned by relayd_version_check() when the daemons are not compatible while a negative value is returned if sendmsg()/recvmsg() fail on network errors. Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 1a3c22a6c..9d7425368 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 2adcbe415..4cb1c1fd3 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;