Remove direct dependency of probes on urcu-bp

The filter feature added a direct dependency of probes providers against
urcu-bp .so, while linking them against liblttng-ust should suffice. Fix
this by using the tracepoint.h wrapper for rcu_dereference().

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Use tp rcu link test in provider

Ensure we never trigger a null pointer exception.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: don't flush-final for offset 0 if reader is on sub-buffer

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Move UST registry into sessiond and implement notifiers

Needs to be use in locked-step with lttng-tools

"Move UST registry into sessiond and implement notifiers" commit.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Add write metadata API to ust-ctl.h

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Move metadata creation into lttng-sessiond and lttng-consumed

Includes fixes in type serialization. Also stop sending metadata channel
events.

Need to be applied in locked-step with lttng-tools commit:

"Move metadata creation into lttng-sessiond and lttng-consumed"

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Remove now unused metadata printf code

Metadata is now generated by sessiond.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: Add timeout on notification socket

Use the constructor timeout value. If an error occurs, shutdown() is
called on the socket, so the following attempts to use this socket will
fail very quickly.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: ustctl: return -EPIPE to sessiond if connection is closed

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: Only notify socket should have timeout/nonblock

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: set wait/wake fd to -1 before close

Else triggers double-close race.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: return expected error return values for sessiond

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: don't print error in comm proto connect on ENOENT

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: notification timeout logic

-1: wait forever
0 to 10ms: wait for 10ms
+10ms: wait for the specified amount.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cleanup: remove now unused metadata code from UST

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Unregister tracepoint probes when not needed

Ensure tracepoint probes are only connected when we meet these
conditions:

at least one enabler enables event && session active && channel enabled

We introduce a "tstate" flag in addition to "active/enabled".

Active and enabled fields are used to atomically enable/disable session
and channel, whereas the tstate flag is a "transient state" enable
state. It is used to update all events following a state change
transition. The actual effect of the state transition is committed
atomically with store to active/enabled flag.

Upon enable, we do:

tstate = 1
update all events
enable = 1;

Upon disable, we do the opposite:

enable = 0;
tstate = 0;
update all events

The purpose of this scheme is to allow atomic enable/disable of events
while allowing per-event probe registration to be performed
non-atomically.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Reactivate error printing

Print errors at buffer teardown if LTTNG_UST_DEBUG=1 is set (env. var.)
when launching the consumerd. This is possible now that consumerd owns
the buffers.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: ensure all probe providers have their symbols

Following the removal of metadata generation from UST, the probes cannot
find the tracepoint_dlopen() symbol. Ensure those probes can be built by
declaring this symbol within each probe.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Implement ring buffer periodic buffer switch timer

The tricky part was the teardown. It must not race against neither
pending signals nor in-flight signal handler execution, otherwise the
timer handler could access freed channel data. Use a dedicated thread to
handle those signals, with a synchronization point between each handler
execution.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: only consumerd should print errors

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>