Fix: send the streams sent message after metadata

We now make sure that we only sent the streams_sent message to the relay
when all the streams (including the metadata) are sent.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: notify the viewer if new streams got added

As soon as new streams are available, the viewer must start reading
them, otherwise we risk to ignore complete streams.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: handle new streams in live mode in relayd

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: code refactoring of viewer streams in relayd

This also renames the lttng-viewer.h to lttng-viewer-abi.h which
represents the live reading ABI.

Acked-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: big relayd cleanup and refactor

Due to a number of race conditions between the live feature and the data
threads, we had to refactor the relayd which mostly splits the different
objects in their own files creating APIs for each of them.

That done, we are able to remove duplicate code, centralize code path
to help with cleanup and having a flow that makes more sense when
handling multiple objects.

This commits adds a lot of fixes with the live feature and cleanup code
path of a session since some objects are shared between threads like
ctf-trace and stream.

So yeah, this is quite a BIG commit and unfortunately this work was
essential in order to fix a lof of issues and have a way more
maintainable code base for the relayd.

Signed-off-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: relayd connection object refactor

Mostly rename and move the connection data structure to its own C
file/header along with functions handling the object.

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: Namespace lttng-viewer-abi

This header is copied to all the viewers that implement the lttng-live
protocol, we need to make sure it is properly namespaced.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Fix: force the client to create a viewer session before attaching

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Fix: handle session hang up in get_new_streams

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Fix: allow attach command to multiple sessions

The attach session command can now attach to multiple session using an
ID list.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Fix: Move static functions up in the code

When we detect that the viewer is trying to get new streams for a
session closed and for which it already got all the streams, we can
delete and destroy the session, we know it won't be useful anymore.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Fix: check for new streams in all attached sessions

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Fix: use uint32_t for metadata_flag in viewer's ABI

This struct is meant to be sent over the network so members should be
of exact-width.

Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: merge issue with thread quit pipe

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: cleanup indef guards following the rename

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Fix: add flag to create session command and fix tests

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Fix: don't delete ctf trace while in snapshot mode

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: add missing ctf trace delete before destroy

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: free viewer session in connection_free()

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: don't sleep(1) on the consumer ready flag

This is way too long on especially when the first command that spawn the
consumer as to wait a full second on powerful system.

Bring this down to 0.1 sec sleep by using usleep().

Signed-off-by: David Goulet <dgoulet@efficios.com>