Fix: check the lttng-relayd protocol version
authorJulien Desfossez <jdesfossez@efficios.com>
Mon, 14 Jul 2014 21:11:30 +0000 (17:11 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 14 Jul 2014 21:27:09 +0000 (17:27 -0400)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/lttng-live/lttng-live-comm.c
formats/lttng-live/lttng-live.h

index f6f14ab0cb0014e4a4316828e2c3ba73513104a7..a855891a8ff162b93ed6ab6b32bbc166bf8dbd61 100644 (file)
@@ -201,6 +201,18 @@ int lttng_live_establish_connection(struct lttng_live_ctx *ctx)
                        be64toh(connect.viewer_session_id));
        printf_verbose("Relayd version : %u.%u\n", be32toh(connect.major),
                        be32toh(connect.minor));
+
+       if (LTTNG_LIVE_MAJOR != be32toh(connect.major)) {
+               fprintf(stderr, "[error] Incompatible lttng-relayd protocol\n");
+               goto error;
+       }
+       /* Use the smallest protocol version implemented. */
+       if (LTTNG_LIVE_MINOR > be32toh(connect.minor)) {
+               ctx->minor =  be32toh(connect.minor);
+       } else {
+               ctx->minor =  LTTNG_LIVE_MINOR;
+       }
+       ctx->major = LTTNG_LIVE_MAJOR;
        ret = 0;
 end:
        return ret;
index cf47437bbd03e83f55331d2637833c987d1ae7ec..d7b0e860b14786950ca5dee227447d6b8dd35a83 100644 (file)
@@ -37,6 +37,9 @@ struct lttng_live_ctx {
        char relay_hostname[NAME_MAX];
        int control_sock;
        int port;
+       /* Protocol version to use for this connection. */
+       uint32_t major;
+       uint32_t minor;
        struct lttng_live_session *session;
        struct bt_context *bt_ctx;
        GArray *session_ids;
This page took 0.026237 seconds and 4 git commands to generate.