Bug #801
closedlttng-sessiond: invalid error handling in cmd_start_trace()
100%
Description
Currently cmd_start_trace() sets session->enabled flag unconditionally, and does not clear it on error paths.
So if for whatever reason further actions fail, session->enabled flag is left set, and new session start is not possible.
In the following example we first tried to enable all events, but that failed due to extremely low memory in target. We then tried to enable only some events, and start operation did not start tracing (but claimed that tracing was already started).
root@Squalus:~# lttng create --snapshot trace1
Spawning a session daemon
Warning: No tracing group detected
Session trace1 created.
Default snapshot output set to: /home/root/lttng-traces/trace1-20140523-002816
Snapshot mode set. Every channel enabled for that session will be set in
overwrite mode and mmap output.
root@Squalus:~# lttng enable-event -a -k
All kernel events are enabled in channel channel0
root@Squalus:~# lttng start
PERROR [3759/3811]: ioctl start session: Cannot allocate memory (in
kernel_start_session() at kernel.c:410)
Error: Starting kernel trace failed
root@Squalus:~# lttng disable-event -a -k
PERROR [3759/3811]: disable kernel event: Bad file descriptor (in
kernel_disable_event() at kernel.c:342)
Error: Cannot disable syscall tracing for existing session. Please destroy
session instead.
All kernel events are disabled in channel channel0
root@Squalus:~# lttng enable-event sched_switch,sched_process_fork -k
kernel event sched_switch created in channel channel0
kernel event sched_process_fork created in channel channel0
root@Squalus:~# lttng start
Warning: Tracing already started for session trace1