From 3271c1558653720ec481da57d4d41125a3776cde Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 25 Aug 2015 07:43:16 -0400 Subject: [PATCH] Fix: relayd reply with error if cannot find metadata MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- src/bin/lttng-relayd/live.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bin/lttng-relayd/live.c b/src/bin/lttng-relayd/live.c index 51457400b..1ae1ae98b 100644 --- a/src/bin/lttng-relayd/live.c +++ b/src/bin/lttng-relayd/live.c @@ -1628,7 +1628,15 @@ int viewer_get_metadata(struct relay_connection *conn) vstream = viewer_stream_get_by_id(be64toh(request.stream_id)); if (!vstream) { - reply.status = htobe32(LTTNG_VIEWER_NO_NEW_METADATA); + /* + * The metadata stream can be closed by a CLOSE command + * just before we attach. It can also be closed by + * per-pid tracing during tracing. Therefore, it is + * possible that we cannot find this viewer stream. + * Reply back to the client with an error if we cannot + * find it. + */ + reply.status = htobe32(LTTNG_VIEWER_METADATA_ERR); goto send_reply; } pthread_mutex_lock(&vstream->stream->lock); -- 2.34.1