Fix: Define __STDC_LIMIT_MACROS to fix C++ builds

Necessary to include the fixed-width type limits on glibc versions
older than 2.18 when building with a C++ compiler.

Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Man: clarify loglevel for JUL domain

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: protect close_write_flag with the rotation lock

Acked-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: relayd leak on error in consumer splice()

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: handle snapshot ENODATA in live timer

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: change ERR statement to DBG in kernel read subbuffer

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: steal channel key in the consumer to avoid race

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: simplify get next index in live

This fixes some case of unitialized status, use of bad ret value and
help modularize the get next index function.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: deadlock during rotation

The overwrite_lock is nested inside the viewer_stream_rotation_lock.
And the viewer_stream_rotate function is always called with the
viewer_stream_rotation_lock held.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: race with index file creation

Only the data thread should create the index file since it is
responsible of filling the FD field of the index struct in memory.
When the control thread is ready to write the index, the FD is already
set.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Update version to v2.4.0-rc5

Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: add missing VALGRIND ifdef checks and documentation

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: miscellaneous memory handling fixes

Issues found with Valgrind:

- Uninitialized memory sent through sendmsg,
- Uninitialized realloc memory,
- Erroneous pointer arithmetic in jul_list_events(),
- Memory leaks in kernel_consumer_add_channel(),
  kernel_consumer_add_metadata(),
- Memory leak (snapshot_destroy missing hash table cleanup),
- Uninitialized poll/epoll memory on realloc.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: scanf unbounded input

Awaiting a proper cleanup (introducing nscanf), do what we can to
validate the scanf input using its utterly broken API.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: consumerd errors on exit

- The LTTNG_CONSUMER_STOP command is not used by sessiond anymore, so
  deprecate it,
- Ensure that the normal teardown (with signal handler) does not trigger
  a health error in consumer daemon by distinguishing between errors and
  "should exit" with different lttng_consumer_poll_socket() return values.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Comments fix: lttngerr.h -> error.h (./Changelog:754)

Signed-off-by: Jonathan Rajotte <jonathan.r.julien@gmail.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: perror on index directory creation error

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: wrong condition on startup for low-activity streams

If we only received and sent one index, we should not be in the retry
condition.
The rstream->total_index_received == vstream->last_sent_index is checked
before.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: missing big endian conversion for one index field

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Revert "Fix: wrong condition on startup for low-activity streams"

This reverts commit d3aac146d0800fe9820d51e5b9fa52e7543c1237.

Acked-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>