Fix: consumer: 64-bit index for relayd rather than 32-bit (v2)
Relayd "unique" ids wrap every 32-bit, and in some cases, negative
values are considered as error.
Change this to make the error value specifically -1ULL, use a direct
comparison (since we use an unsigned 64-bit integer, comparison with 0
becomes incorrect).
Since we now use a 64-bit ID, it is assumed to _never_ wrap-around
(remember, value -1ULL is an _error_). Therefore,
consumer_add_relayd_socket() can become much more strict than it was:
instead of accepting re-use of net_seq_idx, we can now assert that upon
LTTNG_STREAM_CONTROL socket, we have indeed allocated a relayd object,
and upon LTTNG_STREAM_DATA, we have found a relayd object.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: David Goulet <dgoulet@efficios.com>
Julien Desfossez [Thu, 27 Jun 2013 21:57:06 +0000 (17:57 -0400)]
Fix: send per-pid session id in channel creation
The registry indexing for per-pid sessions is done with a per-pid
session id. So for per-pid buffers, we need to send the per-pid session
id as well as the global session id to the consumer in order to give it
enough information if it needs to request metadata later.
This patch adds the session_id_per_pid to the channel creation message
and to the consumer. When the sessiond receives a metadata_request,
depending on the buffer type (per-pid or per-uid), it selects the right
id to do the registry lookup.
David Goulet [Wed, 1 May 2013 19:18:50 +0000 (15:18 -0400)]
Support flight recorder mode for a session
This adds the --no-output option to the lttng UI which will flag a
session to not set an output destination meaning that tracing will be in
overwrite mode in the buffers.
This is also the only way for now to snapshot a session, it's to put it
in no output mode.
Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Tue, 16 Apr 2013 17:44:09 +0000 (13:44 -0400)]
Implement snapshot commands in lttng-sessiond
Basic functionalities are implemented in the session daemon so handle
snapshots and send the command to the consumer but note that at this
commit the consumer does not handle snapshot.
Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Mon, 27 May 2013 19:17:19 +0000 (15:17 -0400)]
Add consumer-stream.c/.h in libconsumer
These new files contain relevant calls to a lttng_consumer_stream object
and for now breaks down consumer_del_stream() from consumer.c that got
out of hand in terms of size and can not be used if the stream was not
previously successfully sent to a thread making difficult the deletion
of a stream in some error path or in no monitor mode (future mode for
streams with snapshots) outside of this use case.
It helps also modularize the consumer object and makes the code easier
to maintain and to better evolve.
At this commit, no components use this yet. Future work will
incrementaly move every consumer stream specific actions to that
seperate API.
Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Mon, 15 Apr 2013 16:37:06 +0000 (12:37 -0400)]
Add a lttng-ctl header to facilitate code separation
In order for lttng-ctl.c not to grow into an uncontrollable monster of
code, add this helper header and remove static declaration of some
functions to be exported out of the C file and set them hidden.
Future work on snapshot and trigger will use it in order to better split
the code into different files.
Signed-off-by: David Goulet <dgoulet@efficios.com>
1019896 Time of check time of use
In utils_mkdir_recursive: A check occurs on a file's attributes before
the file is used in a privileged operation, but things may have changed
(CWE-367)
1019904 Copy into fixed size buffer
In add_context: A source buffer of statically unknown size is copied
into a fixed-size destination buffer (CWE-120)
1022350 Dereference before null check
In ust_registry_session_destroy: All paths that lead to this null
pointer comparison already dereference the pointer earlier (CWE-476)
David Goulet [Thu, 6 Jun 2013 19:30:14 +0000 (15:30 -0400)]
Fix: poll compat layer reallocation new size
The size was doubled but in fact it should have been checked for the
maximum between the number of fd doubled and the alloc size doubled
(divised by two when shrinking the buffer).
Same goes for the shrink process. For that, get_count_order_u32() is
added to utils.c/.h.
Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Tue, 4 Jun 2013 19:56:43 +0000 (15:56 -0400)]
Fix: remove nonblock flag of sessiond socket in consumer
There is no need for non blocking socket. Furthermore, we have observed
unstable behaviors with a non blocking side (consumer) and a blocking
side (sessiond).
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Mon, 3 Jun 2013 17:24:10 +0000 (13:24 -0400)]
Fix: add more conditions and a lock to metadata cache flushed
Some more conditions applies to return if the metadata cache is indeed
flushed. If no metadata stream is found or the endpoint status is set to
something other than ACTIVE, this means the channel is being (or will
be) destroyed thus the metadata cache can't be updated so is indeed
"flushed".
David Goulet [Mon, 3 Jun 2013 17:13:55 +0000 (13:13 -0400)]
Fix: set metadata closed on a push/close metadata error
Check the metadata closed flag before pushing and closing the metadata
on the consumer side. On any error from those two actions, the closed
flag is set to indicate to stop using the metadata registry until a
destroy is done.
Also, before creating a metadata, a check is done to see if the registry
metadata was closed previously or else a new metadata key is created and
the old values from the previous channel in the registry are used
causing a bad state on the consumer.
With per UID buffers, the metadata cache is shared accross multiple
applications so if the metadata buffers were deleted on the consumer for
whatever reasons, we must STOP using it or else undesired behaviors have
been observed such as causing synchronization issues between the state
of the consumer and sessiond.
A destroy session command will wipe the faulty metadata.
David Goulet [Wed, 29 May 2013 16:19:57 +0000 (12:19 -0400)]
Fix: remove one too many metadata refcount increment
The refcount increment is removed from the add metadata stream function
so for both kernel and UST, the increment is done once the stream is
allocated and the channel reference is set.
Signed-off-by: David Goulet <dgoulet@efficios.com>
David Goulet [Wed, 22 May 2013 19:17:17 +0000 (15:17 -0400)]
Tests: Add stress test for multi session per UID
For this test, 10 applications are used with 5 sessions set with per UID
buffers.
A helper script is also added which launch applications with given
parameters. A README file is also present to help developers/users use
the stress tests correctly.
Stress tests save the stderr/stdout of the session daemon in a log file
and core dump created using the name found in core_pattern (in /proc).
Signed-off-by: David Goulet <dgoulet@efficios.com>
Julien Desfossez [Thu, 23 May 2013 21:07:08 +0000 (17:07 -0400)]
Fix: error handling in kernel add_channel
consumer_add_channel can return an error, it needs to be handled. Also,
init_kernel_tracing returns a positive lttng_error_code on error, so the
check in start_kernel_session needs to be for ret != 0.
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com> Signed-off-by: David Goulet <dgoulet@efficios.com>
Julien Desfossez [Thu, 23 May 2013 20:13:35 +0000 (16:13 -0400)]
Fix: close wait_fd on kernel tracing
The wait_fd in the kernel consumer streams was not closed causing a leak
of FDs in the consumer and never triggering the teardown mechanism in
the kernel tracer. This applies for metadata and data stream.
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com> Signed-off-by: David Goulet <dgoulet@efficios.com>