Live: viewer: check trace format support based on protocol.
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 20 May 2022 19:49:37 +0000 (15:49 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 19 Aug 2022 16:04:23 +0000 (12:04 -0400)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Ia73157ba3e72c821c3da19537e093c2c11490914

src/bin/lttng-relayd/live.cpp

index abbec8c20e89e02253a0dce83a38a138909b9dff..0eb7f68f6af359d539425af2313ffd5e3f646b95 100644 (file)
@@ -1328,6 +1328,24 @@ error:
        return ret;
 }
 
+static bool viewer_supports_trace_format(
+               const relay_connection *connection, const relay_session *session)
+{
+       LTTNG_ASSERT(connection);
+       LTTNG_ASSERT(session);
+
+       switch (session->trace_format) {
+       case RELAYD_TRACE_FORMAT_CTF_1:
+               return true;
+       case RELAYD_TRACE_FORMAT_CTF_2:
+               /* Introduced in protocol version 2.15 */
+               return connection->minor >= 15;
+       default:
+               abort();
+               break;
+       }
+}
+
 /*
  * Send the viewer the list of current sessions.
  */
@@ -1387,6 +1405,15 @@ int viewer_attach_session(struct relay_connection *conn)
                goto send_reply;
        }
 
+       if (!viewer_supports_trace_format(conn, session)) {
+               viewer_attach_status = LTTNG_VIEWER_ATTACH_NOT_LIVE;
+               DBG("Relay session ID %" PRIu64
+                   " trace format is not supported by the viewer, returning status=%s",
+                               session_id,
+                               lttng_viewer_attach_return_code_str(viewer_attach_status));
+               goto send_reply;
+       }
+
        send_streams = 1;
        viewer_attach_status = viewer_session_attach(conn->viewer_session,
                        session);
This page took 0.028101 seconds and 5 git commands to generate.