Fix: relayd: viewer_stream leak causes assertion failure on exit
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 11 Oct 2024 20:26:59 +0000 (16:26 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 17 Oct 2024 18:37:20 +0000 (14:37 -0400)
commit25e301be1a087831ccf7e6652a25a695011b03e2
tree0816d9ad639906bc36975289105e7d69dcb55bae
parentfdf647bb757759bc13da7cc38260f19984d04801
Fix: relayd: viewer_stream leak causes assertion failure on exit

Observed issue
==============

Running the test proposed in change #11584[1], the relay daemon aborts
when destroying the viewer_streams_ht as it is not empty.

Cause
=====

A viewer stream reference is leaked when sending streams to the live
client causing them to remain published in the viewer_streams_ht beyond
the lifetime of the viewer_connection.

The send_viewer_streams() function operates in two phases. First, it
iterates over the viewer_streams_ht to find streams that belong to the
target session and have not been sent yet.

In the second phase, it iterates over the session's unannounced stream
list. The commit message of 98b82dfa2 gives more background on the role
of the unannounced stream list.

When a viewer stream is created, two references are acquired:
  - one belongs to the global viewer_streams_ht,
  - the other belongs to the unannounced stream list.

When the viewer stream is eventually sent to the client, it is removed
from the unannounced stream list and that reference must be dropped.

Unfortunately, the reference is not dropped during the first phase.

Solution
========

Put the reference of the viewer streams that are sent during the first
phase of send_viewer_streams().

Known drawbacks
===============

None.

[1] https://review.lttng.org/c/lttng-tools/+/11584

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7d5d5d3a77f6f08744b712d9ef1233a1d19a7124
src/bin/lttng-relayd/live.cpp
This page took 0.025543 seconds and 4 git commands to generate.