2 * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
3 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 * SPDX-License-Identifier: GPL-2.0-only
10 #include "common/buffer-view.h"
11 #include "common/compat/socket.h"
12 #include "common/dynamic-buffer.h"
13 #include "common/dynamic-array.h"
14 #include "common/payload.h"
15 #include "common/payload-view.h"
16 #include "common/fd-handle.h"
17 #include "common/sessiond-comm/sessiond-comm.h"
18 #include "common/payload.h"
19 #include "common/payload-view.h"
20 #include "lttng/lttng-error.h"
21 #include "lttng/tracker.h"
22 #include <common/compat/getenv.h>
23 #include <common/tracker.h>
24 #include <common/unix.h>
25 #include <common/utils.h>
26 #include <lttng/event-internal.h>
27 #include <lttng/session-descriptor-internal.h>
28 #include <lttng/session-internal.h>
29 #include <lttng/userspace-probe-internal.h>
36 #include "lttng-sessiond.h"
40 #include "health-sessiond.h"
41 #include "testpoint.h"
43 #include "manage-consumer.h"
48 static struct thread_state
{
54 static void set_thread_status(bool running
)
56 DBG("Marking client thread's state as %s", running
? "running" : "error");
57 thread_state
.running
= running
;
58 sem_post(&thread_state
.ready
);
61 static bool wait_thread_status(void)
63 DBG("Waiting for client thread to be ready");
64 sem_wait(&thread_state
.ready
);
65 if (thread_state
.running
) {
66 DBG("Client thread is ready");
68 ERR("Initialization of client thread failed");
71 return thread_state
.running
;
75 * Setup the outgoing data buffer for the response (llm) by allocating the
76 * right amount of memory and copying the original information from the lsm
79 * Return 0 on success, negative value on error.
81 static int setup_lttng_msg(struct command_ctx
*cmd_ctx
,
82 const void *payload_buf
, size_t payload_len
,
83 const void *cmd_header_buf
, size_t cmd_header_len
)
86 const size_t header_len
= sizeof(struct lttcomm_lttng_msg
);
87 const size_t total_msg_size
= header_len
+ cmd_header_len
+ payload_len
;
88 const struct lttcomm_lttng_msg llm
= {
89 .cmd_type
= cmd_ctx
->lsm
.cmd_type
,
90 .pid
= cmd_ctx
->lsm
.domain
.attr
.pid
,
91 .cmd_header_size
= cmd_header_len
,
92 .data_size
= payload_len
,
95 lttng_dynamic_buffer_set_size(&cmd_ctx
->reply_payload
.buffer
, 0);
96 lttng_dynamic_pointer_array_clear(&cmd_ctx
->reply_payload
._fd_handles
);
98 cmd_ctx
->lttng_msg_size
= total_msg_size
;
100 /* Append reply header. */
101 ret
= lttng_dynamic_buffer_append(
102 &cmd_ctx
->reply_payload
.buffer
, &llm
, sizeof(llm
));
107 /* Append command header. */
108 if (cmd_header_len
) {
109 ret
= lttng_dynamic_buffer_append(
110 &cmd_ctx
->reply_payload
.buffer
, cmd_header_buf
,
117 /* Append payload. */
119 ret
= lttng_dynamic_buffer_append(
120 &cmd_ctx
->reply_payload
.buffer
, payload_buf
,
131 static int setup_empty_lttng_msg(struct command_ctx
*cmd_ctx
)
134 const struct lttcomm_lttng_msg llm
= {};
136 lttng_dynamic_buffer_set_size(&cmd_ctx
->reply_payload
.buffer
, 0);
138 /* Append place-holder reply header. */
139 ret
= lttng_dynamic_buffer_append(
140 &cmd_ctx
->reply_payload
.buffer
, &llm
, sizeof(llm
));
145 cmd_ctx
->lttng_msg_size
= sizeof(llm
);
150 static void update_lttng_msg(struct command_ctx
*cmd_ctx
, size_t cmd_header_len
,
153 const size_t header_len
= sizeof(struct lttcomm_lttng_msg
);
154 const size_t total_msg_size
= header_len
+ cmd_header_len
+ payload_len
;
155 const struct lttcomm_lttng_msg llm
= {
156 .cmd_type
= cmd_ctx
->lsm
.cmd_type
,
157 .pid
= cmd_ctx
->lsm
.domain
.attr
.pid
,
158 .cmd_header_size
= cmd_header_len
,
159 .data_size
= payload_len
,
161 struct lttcomm_lttng_msg
*p_llm
;
163 assert(cmd_ctx
->reply_payload
.buffer
.size
>= sizeof(llm
));
165 p_llm
= (typeof(p_llm
)) cmd_ctx
->reply_payload
.buffer
.data
;
167 /* Update existing header. */
168 memcpy(p_llm
, &llm
, sizeof(llm
));
170 cmd_ctx
->lttng_msg_size
= total_msg_size
;
174 * Start the thread_manage_consumer. This must be done after a lttng-consumerd
175 * exec or it will fail.
177 static int spawn_consumer_thread(struct consumer_data
*consumer_data
)
179 return launch_consumer_management_thread(consumer_data
) ? 0 : -1;
183 * Fork and exec a consumer daemon (consumerd).
185 * Return pid if successful else -1.
187 static pid_t
spawn_consumerd(struct consumer_data
*consumer_data
)
191 const char *consumer_to_use
;
192 const char *verbosity
;
195 DBG("Spawning consumerd");
202 if (config
.verbose_consumer
) {
203 verbosity
= "--verbose";
204 } else if (lttng_opt_quiet
) {
205 verbosity
= "--quiet";
210 switch (consumer_data
->type
) {
211 case LTTNG_CONSUMER_KERNEL
:
213 * Find out which consumerd to execute. We will first try the
214 * 64-bit path, then the sessiond's installation directory, and
215 * fallback on the 32-bit one,
217 DBG3("Looking for a kernel consumer at these locations:");
218 DBG3(" 1) %s", config
.consumerd64_bin_path
.value
? : "NULL");
219 DBG3(" 2) %s/%s", INSTALL_BIN_PATH
, DEFAULT_CONSUMERD_FILE
);
220 DBG3(" 3) %s", config
.consumerd32_bin_path
.value
? : "NULL");
221 if (stat(config
.consumerd64_bin_path
.value
, &st
) == 0) {
222 DBG3("Found location #1");
223 consumer_to_use
= config
.consumerd64_bin_path
.value
;
224 } else if (stat(INSTALL_BIN_PATH
"/" DEFAULT_CONSUMERD_FILE
, &st
) == 0) {
225 DBG3("Found location #2");
226 consumer_to_use
= INSTALL_BIN_PATH
"/" DEFAULT_CONSUMERD_FILE
;
227 } else if (config
.consumerd32_bin_path
.value
&&
228 stat(config
.consumerd32_bin_path
.value
, &st
) == 0) {
229 DBG3("Found location #3");
230 consumer_to_use
= config
.consumerd32_bin_path
.value
;
232 DBG("Could not find any valid consumerd executable");
236 DBG("Using kernel consumer at: %s", consumer_to_use
);
237 (void) execl(consumer_to_use
,
238 "lttng-consumerd", verbosity
, "-k",
239 "--consumerd-cmd-sock", consumer_data
->cmd_unix_sock_path
,
240 "--consumerd-err-sock", consumer_data
->err_unix_sock_path
,
241 "--group", config
.tracing_group_name
.value
,
244 case LTTNG_CONSUMER64_UST
:
246 if (config
.consumerd64_lib_dir
.value
) {
251 tmp
= lttng_secure_getenv("LD_LIBRARY_PATH");
255 tmplen
= strlen(config
.consumerd64_lib_dir
.value
) + 1 /* : */ + strlen(tmp
);
256 tmpnew
= zmalloc(tmplen
+ 1 /* \0 */);
261 strcat(tmpnew
, config
.consumerd64_lib_dir
.value
);
262 if (tmp
[0] != '\0') {
266 ret
= setenv("LD_LIBRARY_PATH", tmpnew
, 1);
273 DBG("Using 64-bit UST consumer at: %s", config
.consumerd64_bin_path
.value
);
274 (void) execl(config
.consumerd64_bin_path
.value
, "lttng-consumerd", verbosity
, "-u",
275 "--consumerd-cmd-sock", consumer_data
->cmd_unix_sock_path
,
276 "--consumerd-err-sock", consumer_data
->err_unix_sock_path
,
277 "--group", config
.tracing_group_name
.value
,
281 case LTTNG_CONSUMER32_UST
:
283 if (config
.consumerd32_lib_dir
.value
) {
288 tmp
= lttng_secure_getenv("LD_LIBRARY_PATH");
292 tmplen
= strlen(config
.consumerd32_lib_dir
.value
) + 1 /* : */ + strlen(tmp
);
293 tmpnew
= zmalloc(tmplen
+ 1 /* \0 */);
298 strcat(tmpnew
, config
.consumerd32_lib_dir
.value
);
299 if (tmp
[0] != '\0') {
303 ret
= setenv("LD_LIBRARY_PATH", tmpnew
, 1);
310 DBG("Using 32-bit UST consumer at: %s", config
.consumerd32_bin_path
.value
);
311 (void) execl(config
.consumerd32_bin_path
.value
, "lttng-consumerd", verbosity
, "-u",
312 "--consumerd-cmd-sock", consumer_data
->cmd_unix_sock_path
,
313 "--consumerd-err-sock", consumer_data
->err_unix_sock_path
,
314 "--group", config
.tracing_group_name
.value
,
319 ERR("unknown consumer type");
323 PERROR("Consumer execl()");
325 /* Reaching this point, we got a failure on our execl(). */
327 } else if (pid
> 0) {
330 PERROR("start consumer fork");
338 * Spawn the consumerd daemon and session daemon thread.
340 static int start_consumerd(struct consumer_data
*consumer_data
)
345 * Set the listen() state on the socket since there is a possible race
346 * between the exec() of the consumer daemon and this call if place in the
347 * consumer thread. See bug #366 for more details.
349 ret
= lttcomm_listen_unix_sock(consumer_data
->err_sock
);
354 pthread_mutex_lock(&consumer_data
->pid_mutex
);
355 if (consumer_data
->pid
!= 0) {
356 pthread_mutex_unlock(&consumer_data
->pid_mutex
);
360 ret
= spawn_consumerd(consumer_data
);
362 ERR("Spawning consumerd failed");
363 pthread_mutex_unlock(&consumer_data
->pid_mutex
);
367 /* Setting up the consumer_data pid */
368 consumer_data
->pid
= ret
;
369 DBG2("Consumer pid %d", consumer_data
->pid
);
370 pthread_mutex_unlock(&consumer_data
->pid_mutex
);
372 DBG2("Spawning consumer control thread");
373 ret
= spawn_consumer_thread(consumer_data
);
375 ERR("Fatal error spawning consumer control thread");
383 /* Cleanup already created sockets on error. */
384 if (consumer_data
->err_sock
>= 0) {
387 err
= close(consumer_data
->err_sock
);
389 PERROR("close consumer data error socket");
396 * Copy consumer output from the tracing session to the domain session. The
397 * function also applies the right modification on a per domain basis for the
398 * trace files destination directory.
400 * Should *NOT* be called with RCU read-side lock held.
402 static int copy_session_consumer(int domain
, struct ltt_session
*session
)
405 const char *dir_name
;
406 struct consumer_output
*consumer
;
409 assert(session
->consumer
);
412 case LTTNG_DOMAIN_KERNEL
:
413 DBG3("Copying tracing session consumer output in kernel session");
415 * XXX: We should audit the session creation and what this function
416 * does "extra" in order to avoid a destroy since this function is used
417 * in the domain session creation (kernel and ust) only. Same for UST
420 if (session
->kernel_session
->consumer
) {
421 consumer_output_put(session
->kernel_session
->consumer
);
423 session
->kernel_session
->consumer
=
424 consumer_copy_output(session
->consumer
);
425 /* Ease our life a bit for the next part */
426 consumer
= session
->kernel_session
->consumer
;
427 dir_name
= DEFAULT_KERNEL_TRACE_DIR
;
429 case LTTNG_DOMAIN_JUL
:
430 case LTTNG_DOMAIN_LOG4J
:
431 case LTTNG_DOMAIN_PYTHON
:
432 case LTTNG_DOMAIN_UST
:
433 DBG3("Copying tracing session consumer output in UST session");
434 if (session
->ust_session
->consumer
) {
435 consumer_output_put(session
->ust_session
->consumer
);
437 session
->ust_session
->consumer
=
438 consumer_copy_output(session
->consumer
);
439 /* Ease our life a bit for the next part */
440 consumer
= session
->ust_session
->consumer
;
441 dir_name
= DEFAULT_UST_TRACE_DIR
;
444 ret
= LTTNG_ERR_UNKNOWN_DOMAIN
;
448 /* Append correct directory to subdir */
449 ret
= lttng_strncpy(consumer
->domain_subdir
, dir_name
,
450 sizeof(consumer
->domain_subdir
));
455 DBG3("Copy session consumer subdir %s", consumer
->domain_subdir
);
463 * Create an UST session and add it to the session ust list.
465 * Should *NOT* be called with RCU read-side lock held.
467 static int create_ust_session(struct ltt_session
*session
,
468 const struct lttng_domain
*domain
)
471 struct ltt_ust_session
*lus
= NULL
;
475 assert(session
->consumer
);
477 switch (domain
->type
) {
478 case LTTNG_DOMAIN_JUL
:
479 case LTTNG_DOMAIN_LOG4J
:
480 case LTTNG_DOMAIN_PYTHON
:
481 case LTTNG_DOMAIN_UST
:
484 ERR("Unknown UST domain on create session %d", domain
->type
);
485 ret
= LTTNG_ERR_UNKNOWN_DOMAIN
;
489 DBG("Creating UST session");
491 lus
= trace_ust_create_session(session
->id
);
493 ret
= LTTNG_ERR_UST_SESS_FAIL
;
497 lus
->uid
= session
->uid
;
498 lus
->gid
= session
->gid
;
499 lus
->output_traces
= session
->output_traces
;
500 lus
->snapshot_mode
= session
->snapshot_mode
;
501 lus
->live_timer_interval
= session
->live_timer
;
502 session
->ust_session
= lus
;
503 if (session
->shm_path
[0]) {
504 strncpy(lus
->root_shm_path
, session
->shm_path
,
505 sizeof(lus
->root_shm_path
));
506 lus
->root_shm_path
[sizeof(lus
->root_shm_path
) - 1] = '\0';
507 strncpy(lus
->shm_path
, session
->shm_path
,
508 sizeof(lus
->shm_path
));
509 lus
->shm_path
[sizeof(lus
->shm_path
) - 1] = '\0';
510 strncat(lus
->shm_path
, "/ust",
511 sizeof(lus
->shm_path
) - strlen(lus
->shm_path
) - 1);
513 /* Copy session output to the newly created UST session */
514 ret
= copy_session_consumer(domain
->type
, session
);
515 if (ret
!= LTTNG_OK
) {
523 session
->ust_session
= NULL
;
528 * Create a kernel tracer session then create the default channel.
530 static int create_kernel_session(struct ltt_session
*session
)
534 DBG("Creating kernel session");
536 ret
= kernel_create_session(session
);
538 ret
= LTTNG_ERR_KERN_SESS_FAIL
;
542 /* Code flow safety */
543 assert(session
->kernel_session
);
545 /* Copy session output to the newly created Kernel session */
546 ret
= copy_session_consumer(LTTNG_DOMAIN_KERNEL
, session
);
547 if (ret
!= LTTNG_OK
) {
551 session
->kernel_session
->uid
= session
->uid
;
552 session
->kernel_session
->gid
= session
->gid
;
553 session
->kernel_session
->output_traces
= session
->output_traces
;
554 session
->kernel_session
->snapshot_mode
= session
->snapshot_mode
;
555 session
->kernel_session
->is_live_session
= session
->live_timer
!= 0;
560 trace_kernel_destroy_session(session
->kernel_session
);
561 session
->kernel_session
= NULL
;
567 * Count number of session permitted by uid/gid.
569 static unsigned int lttng_sessions_count(uid_t uid
, gid_t gid
)
572 struct ltt_session
*session
;
573 const struct ltt_session_list
*session_list
= session_get_list();
575 DBG("Counting number of available session for UID %d GID %d",
577 cds_list_for_each_entry(session
, &session_list
->head
, list
) {
578 if (!session_get(session
)) {
581 session_lock(session
);
582 /* Only count the sessions the user can control. */
583 if (session_access_ok(session
, uid
, gid
) &&
584 !session
->destroyed
) {
587 session_unlock(session
);
588 session_put(session
);
593 static int receive_userspace_probe(struct command_ctx
*cmd_ctx
, int sock
,
594 int *sock_error
, struct lttng_event
*event
)
597 struct lttng_userspace_probe_location
*probe_location
;
598 struct lttng_payload probe_location_payload
;
599 struct fd_handle
*handle
= NULL
;
602 * Create a payload to store the serialized version of the probe
605 lttng_payload_init(&probe_location_payload
);
607 ret
= lttng_dynamic_buffer_set_size(&probe_location_payload
.buffer
,
608 cmd_ctx
->lsm
.u
.enable
.userspace_probe_location_len
);
610 ret
= LTTNG_ERR_NOMEM
;
615 * Receive the probe location.
617 ret
= lttcomm_recv_unix_sock(sock
, probe_location_payload
.buffer
.data
,
618 probe_location_payload
.buffer
.size
);
620 DBG("Nothing recv() from client var len data... continuing");
622 ret
= LTTNG_ERR_PROBE_LOCATION_INVAL
;
627 * Receive the file descriptor to the target binary from the client.
629 DBG("Receiving userspace probe target FD from client ...");
630 ret
= lttcomm_recv_fds_unix_sock(sock
, &fd
, 1);
632 DBG("Nothing recv() from client userspace probe fd... continuing");
634 ret
= LTTNG_ERR_PROBE_LOCATION_INVAL
;
638 handle
= fd_handle_create(fd
);
640 ret
= LTTNG_ERR_NOMEM
;
644 /* Transferred to the handle. */
647 ret
= lttng_payload_push_fd_handle(&probe_location_payload
, handle
);
649 ERR("Failed to add userspace probe file descriptor to payload");
650 ret
= LTTNG_ERR_NOMEM
;
654 fd_handle_put(handle
);
658 struct lttng_payload_view view
= lttng_payload_view_from_payload(
659 &probe_location_payload
, 0, -1);
661 /* Extract the probe location from the serialized version. */
662 ret
= lttng_userspace_probe_location_create_from_payload(
663 &view
, &probe_location
);
666 WARN("Failed to create a userspace probe location from the received buffer");
667 ret
= LTTNG_ERR_PROBE_LOCATION_INVAL
;
671 /* Attach the probe location to the event. */
672 ret
= lttng_event_set_userspace_probe_location(event
, probe_location
);
674 ret
= LTTNG_ERR_PROBE_LOCATION_INVAL
;
681 PERROR("Failed to close userspace probe location binary fd");
685 fd_handle_put(handle
);
686 lttng_payload_reset(&probe_location_payload
);
691 * Version of setup_lttng_msg() without command header.
693 static int setup_lttng_msg_no_cmd_header(struct command_ctx
*cmd_ctx
,
694 void *payload_buf
, size_t payload_len
)
696 return setup_lttng_msg(cmd_ctx
, payload_buf
, payload_len
, NULL
, 0);
700 * Check if the current kernel tracer supports the session rotation feature.
701 * Return 1 if it does, 0 otherwise.
703 static int check_rotate_compatible(void)
707 if (kernel_tracer_version
.major
!= 2 || kernel_tracer_version
.minor
< 11) {
708 DBG("Kernel tracer version is not compatible with the rotation feature");
716 * Send data on a unix socket using the liblttsessiondcomm API.
718 * Return lttcomm error code.
720 static int send_unix_sock(int sock
, struct lttng_payload_view
*view
)
723 const int fd_count
= lttng_payload_view_get_fd_handle_count(view
);
725 /* Check valid length */
726 if (view
->buffer
.size
== 0) {
731 ret
= lttcomm_send_unix_sock(
732 sock
, view
->buffer
.data
, view
->buffer
.size
);
738 ret
= lttcomm_send_payload_view_fds_unix_sock(sock
, view
);
749 * Process the command requested by the lttng client within the command
750 * context structure. This function make sure that the return structure (llm)
751 * is set and ready for transmission before returning.
753 * Return any error encountered or 0 for success.
755 * "sock" is only used for special-case var. len data.
756 * A command may assume the ownership of the socket, in which case its value
757 * should be set to -1.
759 * Should *NOT* be called with RCU read-side lock held.
761 static int process_client_msg(struct command_ctx
*cmd_ctx
, int *sock
,
765 int need_tracing_session
= 1;
768 DBG("Processing client command %d", cmd_ctx
->lsm
.cmd_type
);
770 assert(!rcu_read_ongoing());
774 switch (cmd_ctx
->lsm
.cmd_type
) {
775 case LTTNG_CREATE_SESSION_EXT
:
776 case LTTNG_DESTROY_SESSION
:
777 case LTTNG_LIST_SESSIONS
:
778 case LTTNG_LIST_DOMAINS
:
779 case LTTNG_START_TRACE
:
780 case LTTNG_STOP_TRACE
:
781 case LTTNG_DATA_PENDING
:
782 case LTTNG_SNAPSHOT_ADD_OUTPUT
:
783 case LTTNG_SNAPSHOT_DEL_OUTPUT
:
784 case LTTNG_SNAPSHOT_LIST_OUTPUT
:
785 case LTTNG_SNAPSHOT_RECORD
:
786 case LTTNG_SAVE_SESSION
:
787 case LTTNG_SET_SESSION_SHM_PATH
:
788 case LTTNG_REGENERATE_METADATA
:
789 case LTTNG_REGENERATE_STATEDUMP
:
790 case LTTNG_REGISTER_TRIGGER
:
791 case LTTNG_UNREGISTER_TRIGGER
:
792 case LTTNG_ROTATE_SESSION
:
793 case LTTNG_ROTATION_GET_INFO
:
794 case LTTNG_ROTATION_SET_SCHEDULE
:
795 case LTTNG_SESSION_LIST_ROTATION_SCHEDULES
:
796 case LTTNG_CLEAR_SESSION
:
803 if (config
.no_kernel
&& need_domain
804 && cmd_ctx
->lsm
.domain
.type
== LTTNG_DOMAIN_KERNEL
) {
806 ret
= LTTNG_ERR_NEED_ROOT_SESSIOND
;
808 ret
= LTTNG_ERR_KERN_NA
;
813 /* Deny register consumer if we already have a spawned consumer. */
814 if (cmd_ctx
->lsm
.cmd_type
== LTTNG_REGISTER_CONSUMER
) {
815 pthread_mutex_lock(&kconsumer_data
.pid_mutex
);
816 if (kconsumer_data
.pid
> 0) {
817 ret
= LTTNG_ERR_KERN_CONSUMER_FAIL
;
818 pthread_mutex_unlock(&kconsumer_data
.pid_mutex
);
821 pthread_mutex_unlock(&kconsumer_data
.pid_mutex
);
825 * Check for command that don't needs to allocate a returned payload. We do
826 * this here so we don't have to make the call for no payload at each
829 switch(cmd_ctx
->lsm
.cmd_type
) {
830 case LTTNG_LIST_SESSIONS
:
831 case LTTNG_LIST_TRACEPOINTS
:
832 case LTTNG_LIST_TRACEPOINT_FIELDS
:
833 case LTTNG_LIST_DOMAINS
:
834 case LTTNG_LIST_CHANNELS
:
835 case LTTNG_LIST_EVENTS
:
836 case LTTNG_LIST_SYSCALLS
:
837 case LTTNG_SESSION_LIST_ROTATION_SCHEDULES
:
838 case LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY
:
839 case LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET
:
840 case LTTNG_DATA_PENDING
:
841 case LTTNG_ROTATE_SESSION
:
842 case LTTNG_ROTATION_GET_INFO
:
845 /* Setup lttng message with no payload */
846 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
, NULL
, 0);
848 /* This label does not try to unlock the session */
849 goto init_setup_error
;
853 /* Commands that DO NOT need a session. */
854 switch (cmd_ctx
->lsm
.cmd_type
) {
855 case LTTNG_CREATE_SESSION_EXT
:
856 case LTTNG_LIST_SESSIONS
:
857 case LTTNG_LIST_TRACEPOINTS
:
858 case LTTNG_LIST_SYSCALLS
:
859 case LTTNG_LIST_TRACEPOINT_FIELDS
:
860 case LTTNG_SAVE_SESSION
:
861 case LTTNG_REGISTER_TRIGGER
:
862 case LTTNG_UNREGISTER_TRIGGER
:
863 need_tracing_session
= 0;
866 DBG("Getting session %s by name", cmd_ctx
->lsm
.session
.name
);
868 * We keep the session list lock across _all_ commands
869 * for now, because the per-session lock does not
870 * handle teardown properly.
873 cmd_ctx
->session
= session_find_by_name(cmd_ctx
->lsm
.session
.name
);
874 if (cmd_ctx
->session
== NULL
) {
875 ret
= LTTNG_ERR_SESS_NOT_FOUND
;
878 /* Acquire lock for the session */
879 session_lock(cmd_ctx
->session
);
885 * Commands that need a valid session but should NOT create one if none
886 * exists. Instead of creating one and destroying it when the command is
887 * handled, process that right before so we save some round trip in useless
890 switch (cmd_ctx
->lsm
.cmd_type
) {
891 case LTTNG_DISABLE_CHANNEL
:
892 case LTTNG_DISABLE_EVENT
:
893 switch (cmd_ctx
->lsm
.domain
.type
) {
894 case LTTNG_DOMAIN_KERNEL
:
895 if (!cmd_ctx
->session
->kernel_session
) {
896 ret
= LTTNG_ERR_NO_CHANNEL
;
900 case LTTNG_DOMAIN_JUL
:
901 case LTTNG_DOMAIN_LOG4J
:
902 case LTTNG_DOMAIN_PYTHON
:
903 case LTTNG_DOMAIN_UST
:
904 if (!cmd_ctx
->session
->ust_session
) {
905 ret
= LTTNG_ERR_NO_CHANNEL
;
910 ret
= LTTNG_ERR_UNKNOWN_DOMAIN
;
922 * Check domain type for specific "pre-action".
924 switch (cmd_ctx
->lsm
.domain
.type
) {
925 case LTTNG_DOMAIN_KERNEL
:
927 ret
= LTTNG_ERR_NEED_ROOT_SESSIOND
;
931 /* Kernel tracer check */
932 if (!kernel_tracer_is_initialized()) {
933 /* Basically, load kernel tracer modules */
934 ret
= init_kernel_tracer();
940 /* Consumer is in an ERROR state. Report back to client */
941 if (uatomic_read(&kernel_consumerd_state
) == CONSUMER_ERROR
) {
942 ret
= LTTNG_ERR_NO_KERNCONSUMERD
;
946 /* Need a session for kernel command */
947 if (need_tracing_session
) {
948 if (cmd_ctx
->session
->kernel_session
== NULL
) {
949 ret
= create_kernel_session(cmd_ctx
->session
);
950 if (ret
!= LTTNG_OK
) {
951 ret
= LTTNG_ERR_KERN_SESS_FAIL
;
956 /* Start the kernel consumer daemon */
957 pthread_mutex_lock(&kconsumer_data
.pid_mutex
);
958 if (kconsumer_data
.pid
== 0 &&
959 cmd_ctx
->lsm
.cmd_type
!= LTTNG_REGISTER_CONSUMER
) {
960 pthread_mutex_unlock(&kconsumer_data
.pid_mutex
);
961 ret
= start_consumerd(&kconsumer_data
);
963 ret
= LTTNG_ERR_KERN_CONSUMER_FAIL
;
966 uatomic_set(&kernel_consumerd_state
, CONSUMER_STARTED
);
968 pthread_mutex_unlock(&kconsumer_data
.pid_mutex
);
972 * The consumer was just spawned so we need to add the socket to
973 * the consumer output of the session if exist.
975 ret
= consumer_create_socket(&kconsumer_data
,
976 cmd_ctx
->session
->kernel_session
->consumer
);
983 case LTTNG_DOMAIN_JUL
:
984 case LTTNG_DOMAIN_LOG4J
:
985 case LTTNG_DOMAIN_PYTHON
:
986 case LTTNG_DOMAIN_UST
:
988 if (!ust_app_supported()) {
989 ret
= LTTNG_ERR_NO_UST
;
992 /* Consumer is in an ERROR state. Report back to client */
993 if (uatomic_read(&ust_consumerd_state
) == CONSUMER_ERROR
) {
994 ret
= LTTNG_ERR_NO_USTCONSUMERD
;
998 if (need_tracing_session
) {
999 /* Create UST session if none exist. */
1000 if (cmd_ctx
->session
->ust_session
== NULL
) {
1001 ret
= create_ust_session(cmd_ctx
->session
,
1002 ALIGNED_CONST_PTR(cmd_ctx
->lsm
.domain
));
1003 if (ret
!= LTTNG_OK
) {
1008 /* Start the UST consumer daemons */
1010 pthread_mutex_lock(&ustconsumer64_data
.pid_mutex
);
1011 if (config
.consumerd64_bin_path
.value
&&
1012 ustconsumer64_data
.pid
== 0 &&
1013 cmd_ctx
->lsm
.cmd_type
!= LTTNG_REGISTER_CONSUMER
) {
1014 pthread_mutex_unlock(&ustconsumer64_data
.pid_mutex
);
1015 ret
= start_consumerd(&ustconsumer64_data
);
1017 ret
= LTTNG_ERR_UST_CONSUMER64_FAIL
;
1018 uatomic_set(&ust_consumerd64_fd
, -EINVAL
);
1022 uatomic_set(&ust_consumerd64_fd
, ustconsumer64_data
.cmd_sock
);
1023 uatomic_set(&ust_consumerd_state
, CONSUMER_STARTED
);
1025 pthread_mutex_unlock(&ustconsumer64_data
.pid_mutex
);
1029 * Setup socket for consumer 64 bit. No need for atomic access
1030 * since it was set above and can ONLY be set in this thread.
1032 ret
= consumer_create_socket(&ustconsumer64_data
,
1033 cmd_ctx
->session
->ust_session
->consumer
);
1039 pthread_mutex_lock(&ustconsumer32_data
.pid_mutex
);
1040 if (config
.consumerd32_bin_path
.value
&&
1041 ustconsumer32_data
.pid
== 0 &&
1042 cmd_ctx
->lsm
.cmd_type
!= LTTNG_REGISTER_CONSUMER
) {
1043 pthread_mutex_unlock(&ustconsumer32_data
.pid_mutex
);
1044 ret
= start_consumerd(&ustconsumer32_data
);
1046 ret
= LTTNG_ERR_UST_CONSUMER32_FAIL
;
1047 uatomic_set(&ust_consumerd32_fd
, -EINVAL
);
1051 uatomic_set(&ust_consumerd32_fd
, ustconsumer32_data
.cmd_sock
);
1052 uatomic_set(&ust_consumerd_state
, CONSUMER_STARTED
);
1054 pthread_mutex_unlock(&ustconsumer32_data
.pid_mutex
);
1058 * Setup socket for consumer 32 bit. No need for atomic access
1059 * since it was set above and can ONLY be set in this thread.
1061 ret
= consumer_create_socket(&ustconsumer32_data
,
1062 cmd_ctx
->session
->ust_session
->consumer
);
1074 /* Validate consumer daemon state when start/stop trace command */
1075 if (cmd_ctx
->lsm
.cmd_type
== LTTNG_START_TRACE
||
1076 cmd_ctx
->lsm
.cmd_type
== LTTNG_STOP_TRACE
) {
1077 switch (cmd_ctx
->lsm
.domain
.type
) {
1078 case LTTNG_DOMAIN_NONE
:
1080 case LTTNG_DOMAIN_JUL
:
1081 case LTTNG_DOMAIN_LOG4J
:
1082 case LTTNG_DOMAIN_PYTHON
:
1083 case LTTNG_DOMAIN_UST
:
1084 if (uatomic_read(&ust_consumerd_state
) != CONSUMER_STARTED
) {
1085 ret
= LTTNG_ERR_NO_USTCONSUMERD
;
1089 case LTTNG_DOMAIN_KERNEL
:
1090 if (uatomic_read(&kernel_consumerd_state
) != CONSUMER_STARTED
) {
1091 ret
= LTTNG_ERR_NO_KERNCONSUMERD
;
1096 ret
= LTTNG_ERR_UNKNOWN_DOMAIN
;
1102 * Check that the UID or GID match that of the tracing session.
1103 * The root user can interact with all sessions.
1105 if (need_tracing_session
) {
1106 if (!session_access_ok(cmd_ctx
->session
,
1107 LTTNG_SOCK_GET_UID_CRED(&cmd_ctx
->creds
),
1108 LTTNG_SOCK_GET_GID_CRED(&cmd_ctx
->creds
)) ||
1109 cmd_ctx
->session
->destroyed
) {
1110 ret
= LTTNG_ERR_EPERM
;
1116 * Send relayd information to consumer as soon as we have a domain and a
1119 if (cmd_ctx
->session
&& need_domain
) {
1121 * Setup relayd if not done yet. If the relayd information was already
1122 * sent to the consumer, this call will gracefully return.
1124 ret
= cmd_setup_relayd(cmd_ctx
->session
);
1125 if (ret
!= LTTNG_OK
) {
1130 /* Process by command type */
1131 switch (cmd_ctx
->lsm
.cmd_type
) {
1132 case LTTNG_ADD_CONTEXT
:
1135 * An LTTNG_ADD_CONTEXT command might have a supplementary
1136 * payload if the context being added is an application context.
1138 if (cmd_ctx
->lsm
.u
.context
.ctx
.ctx
==
1139 LTTNG_EVENT_CONTEXT_APP_CONTEXT
) {
1140 char *provider_name
= NULL
, *context_name
= NULL
;
1141 size_t provider_name_len
=
1142 cmd_ctx
->lsm
.u
.context
.provider_name_len
;
1143 size_t context_name_len
=
1144 cmd_ctx
->lsm
.u
.context
.context_name_len
;
1146 if (provider_name_len
== 0 || context_name_len
== 0) {
1148 * Application provider and context names MUST
1151 ret
= -LTTNG_ERR_INVALID
;
1155 provider_name
= zmalloc(provider_name_len
+ 1);
1156 if (!provider_name
) {
1157 ret
= -LTTNG_ERR_NOMEM
;
1160 cmd_ctx
->lsm
.u
.context
.ctx
.u
.app_ctx
.provider_name
=
1163 context_name
= zmalloc(context_name_len
+ 1);
1164 if (!context_name
) {
1165 ret
= -LTTNG_ERR_NOMEM
;
1166 goto error_add_context
;
1168 cmd_ctx
->lsm
.u
.context
.ctx
.u
.app_ctx
.ctx_name
=
1171 ret
= lttcomm_recv_unix_sock(*sock
, provider_name
,
1174 goto error_add_context
;
1177 ret
= lttcomm_recv_unix_sock(*sock
, context_name
,
1180 goto error_add_context
;
1185 * cmd_add_context assumes ownership of the provider and context
1188 ret
= cmd_add_context(cmd_ctx
->session
,
1189 cmd_ctx
->lsm
.domain
.type
,
1190 cmd_ctx
->lsm
.u
.context
.channel_name
,
1191 ALIGNED_CONST_PTR(cmd_ctx
->lsm
.u
.context
.ctx
),
1192 kernel_poll_pipe
[1]);
1194 cmd_ctx
->lsm
.u
.context
.ctx
.u
.app_ctx
.provider_name
= NULL
;
1195 cmd_ctx
->lsm
.u
.context
.ctx
.u
.app_ctx
.ctx_name
= NULL
;
1197 free(cmd_ctx
->lsm
.u
.context
.ctx
.u
.app_ctx
.provider_name
);
1198 free(cmd_ctx
->lsm
.u
.context
.ctx
.u
.app_ctx
.ctx_name
);
1204 case LTTNG_DISABLE_CHANNEL
:
1206 ret
= cmd_disable_channel(cmd_ctx
->session
, cmd_ctx
->lsm
.domain
.type
,
1207 cmd_ctx
->lsm
.u
.disable
.channel_name
);
1210 case LTTNG_DISABLE_EVENT
:
1214 * FIXME: handle filter; for now we just receive the filter's
1215 * bytecode along with the filter expression which are sent by
1216 * liblttng-ctl and discard them.
1218 * This fixes an issue where the client may block while sending
1219 * the filter payload and encounter an error because the session
1220 * daemon closes the socket without ever handling this data.
1222 size_t count
= cmd_ctx
->lsm
.u
.disable
.expression_len
+
1223 cmd_ctx
->lsm
.u
.disable
.bytecode_len
;
1226 char data
[LTTNG_FILTER_MAX_LEN
];
1228 DBG("Discarding disable event command payload of size %zu", count
);
1230 ret
= lttcomm_recv_unix_sock(*sock
, data
,
1231 count
> sizeof(data
) ? sizeof(data
) : count
);
1236 count
-= (size_t) ret
;
1239 ret
= cmd_disable_event(cmd_ctx
->session
, cmd_ctx
->lsm
.domain
.type
,
1240 cmd_ctx
->lsm
.u
.disable
.channel_name
,
1241 ALIGNED_CONST_PTR(cmd_ctx
->lsm
.u
.disable
.event
));
1244 case LTTNG_ENABLE_CHANNEL
:
1246 cmd_ctx
->lsm
.u
.channel
.chan
.attr
.extended
.ptr
=
1247 (struct lttng_channel_extended
*) &cmd_ctx
->lsm
.u
.channel
.extended
;
1248 ret
= cmd_enable_channel(cmd_ctx
->session
,
1249 ALIGNED_CONST_PTR(cmd_ctx
->lsm
.domain
),
1250 ALIGNED_CONST_PTR(cmd_ctx
->lsm
.u
.channel
.chan
),
1251 kernel_poll_pipe
[1]);
1254 case LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE
:
1255 case LTTNG_PROCESS_ATTR_TRACKER_REMOVE_INCLUDE_VALUE
:
1257 struct lttng_dynamic_buffer payload
;
1258 struct lttng_buffer_view payload_view
;
1259 const bool add_value
=
1260 cmd_ctx
->lsm
.cmd_type
==
1261 LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE
;
1262 const size_t name_len
=
1263 cmd_ctx
->lsm
.u
.process_attr_tracker_add_remove_include_value
1265 const enum lttng_domain_type domain_type
=
1266 (enum lttng_domain_type
)
1267 cmd_ctx
->lsm
.domain
.type
;
1268 const enum lttng_process_attr process_attr
=
1269 (enum lttng_process_attr
) cmd_ctx
->lsm
.u
1270 .process_attr_tracker_add_remove_include_value
1272 const enum lttng_process_attr_value_type value_type
=
1273 (enum lttng_process_attr_value_type
) cmd_ctx
1275 .process_attr_tracker_add_remove_include_value
1277 struct process_attr_value
*value
;
1278 enum lttng_error_code ret_code
;
1280 /* Receive remaining variable length payload if applicable. */
1281 if (name_len
> LOGIN_NAME_MAX
) {
1283 * POSIX mandates user and group names that are at least
1284 * 8 characters long. Note that although shadow-utils
1285 * (useradd, groupaadd, etc.) use 32 chars as their
1286 * limit (from bits/utmp.h, UT_NAMESIZE),
1287 * LOGIN_NAME_MAX is defined to 256.
1289 ERR("Rejecting process attribute tracker value %s as the provided exceeds the maximal allowed length: argument length = %zu, maximal length = %d",
1290 add_value
? "addition" : "removal",
1291 name_len
, LOGIN_NAME_MAX
);
1292 ret
= LTTNG_ERR_INVALID
;
1296 lttng_dynamic_buffer_init(&payload
);
1297 if (name_len
!= 0) {
1299 * Receive variable payload for user/group name
1302 ret
= lttng_dynamic_buffer_set_size(&payload
, name_len
);
1304 ERR("Failed to allocate buffer to receive payload of %s process attribute tracker value argument",
1305 add_value
? "add" : "remove");
1306 ret
= LTTNG_ERR_NOMEM
;
1307 goto error_add_remove_tracker_value
;
1310 ret
= lttcomm_recv_unix_sock(
1311 *sock
, payload
.data
, name_len
);
1313 ERR("Failed to receive payload of %s process attribute tracker value argument",
1314 add_value
? "add" : "remove");
1316 ret
= LTTNG_ERR_INVALID_PROTOCOL
;
1317 goto error_add_remove_tracker_value
;
1321 payload_view
= lttng_buffer_view_from_dynamic_buffer(
1322 &payload
, 0, name_len
);
1324 * Validate the value type and domains are legal for the process
1325 * attribute tracker that is specified and convert the value to
1326 * add/remove to the internal sessiond representation.
1328 ret_code
= process_attr_value_from_comm(domain_type
,
1329 process_attr
, value_type
,
1330 &cmd_ctx
->lsm
.u
.process_attr_tracker_add_remove_include_value
1332 &payload_view
, &value
);
1333 if (ret_code
!= LTTNG_OK
) {
1335 goto error_add_remove_tracker_value
;
1339 ret
= cmd_process_attr_tracker_inclusion_set_add_value(
1340 cmd_ctx
->session
, domain_type
,
1341 process_attr
, value
);
1343 ret
= cmd_process_attr_tracker_inclusion_set_remove_value(
1344 cmd_ctx
->session
, domain_type
,
1345 process_attr
, value
);
1347 process_attr_value_destroy(value
);
1348 error_add_remove_tracker_value
:
1349 lttng_dynamic_buffer_reset(&payload
);
1352 case LTTNG_PROCESS_ATTR_TRACKER_GET_POLICY
:
1354 enum lttng_tracking_policy tracking_policy
;
1355 const enum lttng_domain_type domain_type
=
1356 (enum lttng_domain_type
)
1357 cmd_ctx
->lsm
.domain
.type
;
1358 const enum lttng_process_attr process_attr
=
1359 (enum lttng_process_attr
) cmd_ctx
->lsm
.u
1360 .process_attr_tracker_get_tracking_policy
1363 ret
= cmd_process_attr_tracker_get_tracking_policy(
1364 cmd_ctx
->session
, domain_type
, process_attr
,
1366 if (ret
!= LTTNG_OK
) {
1370 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
,
1371 &(uint32_t){tracking_policy
}, sizeof(uint32_t));
1373 ret
= LTTNG_ERR_NOMEM
;
1379 case LTTNG_PROCESS_ATTR_TRACKER_SET_POLICY
:
1381 const enum lttng_tracking_policy tracking_policy
=
1382 (enum lttng_tracking_policy
) cmd_ctx
->lsm
.u
1383 .process_attr_tracker_set_tracking_policy
1385 const enum lttng_domain_type domain_type
=
1386 (enum lttng_domain_type
)
1387 cmd_ctx
->lsm
.domain
.type
;
1388 const enum lttng_process_attr process_attr
=
1389 (enum lttng_process_attr
) cmd_ctx
->lsm
.u
1390 .process_attr_tracker_set_tracking_policy
1393 ret
= cmd_process_attr_tracker_set_tracking_policy(
1394 cmd_ctx
->session
, domain_type
, process_attr
,
1396 if (ret
!= LTTNG_OK
) {
1401 case LTTNG_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET
:
1403 struct lttng_process_attr_values
*values
;
1404 struct lttng_dynamic_buffer reply
;
1405 const enum lttng_domain_type domain_type
=
1406 (enum lttng_domain_type
)
1407 cmd_ctx
->lsm
.domain
.type
;
1408 const enum lttng_process_attr process_attr
=
1409 (enum lttng_process_attr
) cmd_ctx
->lsm
.u
1410 .process_attr_tracker_get_inclusion_set
1413 ret
= cmd_process_attr_tracker_get_inclusion_set(
1414 cmd_ctx
->session
, domain_type
, process_attr
,
1416 if (ret
!= LTTNG_OK
) {
1420 lttng_dynamic_buffer_init(&reply
);
1421 ret
= lttng_process_attr_values_serialize(values
, &reply
);
1423 goto error_tracker_get_inclusion_set
;
1426 ret
= setup_lttng_msg_no_cmd_header(
1427 cmd_ctx
, reply
.data
, reply
.size
);
1429 ret
= LTTNG_ERR_NOMEM
;
1430 goto error_tracker_get_inclusion_set
;
1434 error_tracker_get_inclusion_set
:
1435 lttng_process_attr_values_destroy(values
);
1436 lttng_dynamic_buffer_reset(&reply
);
1439 case LTTNG_ENABLE_EVENT
:
1441 struct lttng_event
*ev
= NULL
;
1442 struct lttng_event_exclusion
*exclusion
= NULL
;
1443 struct lttng_filter_bytecode
*bytecode
= NULL
;
1444 char *filter_expression
= NULL
;
1446 /* Handle exclusion events and receive it from the client. */
1447 if (cmd_ctx
->lsm
.u
.enable
.exclusion_count
> 0) {
1448 size_t count
= cmd_ctx
->lsm
.u
.enable
.exclusion_count
;
1450 exclusion
= zmalloc(sizeof(struct lttng_event_exclusion
) +
1451 (count
* LTTNG_SYMBOL_NAME_LEN
));
1453 ret
= LTTNG_ERR_EXCLUSION_NOMEM
;
1457 DBG("Receiving var len exclusion event list from client ...");
1458 exclusion
->count
= count
;
1459 ret
= lttcomm_recv_unix_sock(*sock
, exclusion
->names
,
1460 count
* LTTNG_SYMBOL_NAME_LEN
);
1462 DBG("Nothing recv() from client var len data... continuing");
1465 ret
= LTTNG_ERR_EXCLUSION_INVAL
;
1470 /* Get filter expression from client. */
1471 if (cmd_ctx
->lsm
.u
.enable
.expression_len
> 0) {
1472 size_t expression_len
=
1473 cmd_ctx
->lsm
.u
.enable
.expression_len
;
1475 if (expression_len
> LTTNG_FILTER_MAX_LEN
) {
1476 ret
= LTTNG_ERR_FILTER_INVAL
;
1481 filter_expression
= zmalloc(expression_len
);
1482 if (!filter_expression
) {
1484 ret
= LTTNG_ERR_FILTER_NOMEM
;
1488 /* Receive var. len. data */
1489 DBG("Receiving var len filter's expression from client ...");
1490 ret
= lttcomm_recv_unix_sock(*sock
, filter_expression
,
1493 DBG("Nothing recv() from client var len data... continuing");
1495 free(filter_expression
);
1497 ret
= LTTNG_ERR_FILTER_INVAL
;
1502 /* Handle filter and get bytecode from client. */
1503 if (cmd_ctx
->lsm
.u
.enable
.bytecode_len
> 0) {
1504 size_t bytecode_len
= cmd_ctx
->lsm
.u
.enable
.bytecode_len
;
1506 if (bytecode_len
> LTTNG_FILTER_MAX_LEN
) {
1507 ret
= LTTNG_ERR_FILTER_INVAL
;
1508 free(filter_expression
);
1513 bytecode
= zmalloc(bytecode_len
);
1515 free(filter_expression
);
1517 ret
= LTTNG_ERR_FILTER_NOMEM
;
1521 /* Receive var. len. data */
1522 DBG("Receiving var len filter's bytecode from client ...");
1523 ret
= lttcomm_recv_unix_sock(*sock
, bytecode
, bytecode_len
);
1525 DBG("Nothing recv() from client var len data... continuing");
1527 free(filter_expression
);
1530 ret
= LTTNG_ERR_FILTER_INVAL
;
1534 if ((bytecode
->len
+ sizeof(*bytecode
)) != bytecode_len
) {
1535 free(filter_expression
);
1538 ret
= LTTNG_ERR_FILTER_INVAL
;
1543 ev
= lttng_event_copy(ALIGNED_CONST_PTR(cmd_ctx
->lsm
.u
.enable
.event
));
1545 DBG("Failed to copy event: %s",
1546 cmd_ctx
->lsm
.u
.enable
.event
.name
);
1547 free(filter_expression
);
1550 ret
= LTTNG_ERR_NOMEM
;
1555 if (cmd_ctx
->lsm
.u
.enable
.userspace_probe_location_len
> 0) {
1556 /* Expect a userspace probe description. */
1557 ret
= receive_userspace_probe(cmd_ctx
, *sock
, sock_error
, ev
);
1559 free(filter_expression
);
1562 lttng_event_destroy(ev
);
1567 ret
= cmd_enable_event(cmd_ctx
->session
,
1568 ALIGNED_CONST_PTR(cmd_ctx
->lsm
.domain
),
1569 cmd_ctx
->lsm
.u
.enable
.channel_name
,
1571 filter_expression
, bytecode
, exclusion
,
1572 kernel_poll_pipe
[1]);
1573 lttng_event_destroy(ev
);
1576 case LTTNG_LIST_TRACEPOINTS
:
1578 struct lttng_event
*events
;
1581 session_lock_list();
1582 nb_events
= cmd_list_tracepoints(cmd_ctx
->lsm
.domain
.type
, &events
);
1583 session_unlock_list();
1584 if (nb_events
< 0) {
1585 /* Return value is a negative lttng_error_code. */
1591 * Setup lttng message with payload size set to the event list size in
1592 * bytes and then copy list into the llm payload.
1594 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
, events
,
1595 sizeof(struct lttng_event
) * nb_events
);
1605 case LTTNG_LIST_TRACEPOINT_FIELDS
:
1607 struct lttng_event_field
*fields
;
1610 session_lock_list();
1611 nb_fields
= cmd_list_tracepoint_fields(cmd_ctx
->lsm
.domain
.type
,
1613 session_unlock_list();
1614 if (nb_fields
< 0) {
1615 /* Return value is a negative lttng_error_code. */
1621 * Setup lttng message with payload size set to the event list size in
1622 * bytes and then copy list into the llm payload.
1624 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
, fields
,
1625 sizeof(struct lttng_event_field
) * nb_fields
);
1635 case LTTNG_LIST_SYSCALLS
:
1637 struct lttng_event
*events
;
1640 nb_events
= cmd_list_syscalls(&events
);
1641 if (nb_events
< 0) {
1642 /* Return value is a negative lttng_error_code. */
1648 * Setup lttng message with payload size set to the event list size in
1649 * bytes and then copy list into the llm payload.
1651 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
, events
,
1652 sizeof(struct lttng_event
) * nb_events
);
1662 case LTTNG_SET_CONSUMER_URI
:
1665 struct lttng_uri
*uris
;
1667 nb_uri
= cmd_ctx
->lsm
.u
.uri
.size
;
1668 len
= nb_uri
* sizeof(struct lttng_uri
);
1671 ret
= LTTNG_ERR_INVALID
;
1675 uris
= zmalloc(len
);
1677 ret
= LTTNG_ERR_FATAL
;
1681 /* Receive variable len data */
1682 DBG("Receiving %zu URI(s) from client ...", nb_uri
);
1683 ret
= lttcomm_recv_unix_sock(*sock
, uris
, len
);
1685 DBG("No URIs received from client... continuing");
1687 ret
= LTTNG_ERR_SESSION_FAIL
;
1692 ret
= cmd_set_consumer_uri(cmd_ctx
->session
, nb_uri
, uris
);
1694 if (ret
!= LTTNG_OK
) {
1701 case LTTNG_START_TRACE
:
1704 * On the first start, if we have a kernel session and we have
1705 * enabled time or size-based rotations, we have to make sure
1706 * the kernel tracer supports it.
1708 if (!cmd_ctx
->session
->has_been_started
&& \
1709 cmd_ctx
->session
->kernel_session
&& \
1710 (cmd_ctx
->session
->rotate_timer_period
|| \
1711 cmd_ctx
->session
->rotate_size
) && \
1712 !check_rotate_compatible()) {
1713 DBG("Kernel tracer version is not compatible with the rotation feature");
1714 ret
= LTTNG_ERR_ROTATION_WRONG_VERSION
;
1717 ret
= cmd_start_trace(cmd_ctx
->session
);
1720 case LTTNG_STOP_TRACE
:
1722 ret
= cmd_stop_trace(cmd_ctx
->session
);
1725 case LTTNG_DESTROY_SESSION
:
1727 ret
= cmd_destroy_session(cmd_ctx
->session
,
1728 notification_thread_handle
,
1732 case LTTNG_LIST_DOMAINS
:
1735 struct lttng_domain
*domains
= NULL
;
1737 nb_dom
= cmd_list_domains(cmd_ctx
->session
, &domains
);
1739 /* Return value is a negative lttng_error_code. */
1744 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
, domains
,
1745 nb_dom
* sizeof(struct lttng_domain
));
1755 case LTTNG_LIST_CHANNELS
:
1757 ssize_t payload_size
;
1758 struct lttng_channel
*channels
= NULL
;
1760 payload_size
= cmd_list_channels(cmd_ctx
->lsm
.domain
.type
,
1761 cmd_ctx
->session
, &channels
);
1762 if (payload_size
< 0) {
1763 /* Return value is a negative lttng_error_code. */
1764 ret
= -payload_size
;
1768 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
, channels
,
1779 case LTTNG_LIST_EVENTS
:
1782 struct lttcomm_event_command_header cmd_header
= {};
1783 size_t original_payload_size
;
1784 size_t payload_size
;
1786 ret
= setup_empty_lttng_msg(cmd_ctx
);
1788 ret
= LTTNG_ERR_NOMEM
;
1792 original_payload_size
= cmd_ctx
->reply_payload
.buffer
.size
;
1794 /* Extended infos are included at the end of the payload. */
1795 list_ret
= cmd_list_events(cmd_ctx
->lsm
.domain
.type
,
1797 cmd_ctx
->lsm
.u
.list
.channel_name
,
1798 &cmd_ctx
->reply_payload
);
1800 /* Return value is a negative lttng_error_code. */
1805 payload_size
= cmd_ctx
->reply_payload
.buffer
.size
-
1806 sizeof(cmd_header
) - original_payload_size
;
1807 update_lttng_msg(cmd_ctx
, sizeof(cmd_header
), payload_size
);
1812 case LTTNG_LIST_SESSIONS
:
1814 unsigned int nr_sessions
;
1815 void *sessions_payload
;
1818 session_lock_list();
1819 nr_sessions
= lttng_sessions_count(
1820 LTTNG_SOCK_GET_UID_CRED(&cmd_ctx
->creds
),
1821 LTTNG_SOCK_GET_GID_CRED(&cmd_ctx
->creds
));
1823 payload_len
= (sizeof(struct lttng_session
) * nr_sessions
) +
1824 (sizeof(struct lttng_session_extended
) * nr_sessions
);
1825 sessions_payload
= zmalloc(payload_len
);
1827 if (!sessions_payload
) {
1828 session_unlock_list();
1833 cmd_list_lttng_sessions(sessions_payload
, nr_sessions
,
1834 LTTNG_SOCK_GET_UID_CRED(&cmd_ctx
->creds
),
1835 LTTNG_SOCK_GET_GID_CRED(&cmd_ctx
->creds
));
1836 session_unlock_list();
1838 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
, sessions_payload
,
1840 free(sessions_payload
);
1849 case LTTNG_REGISTER_CONSUMER
:
1851 struct consumer_data
*cdata
;
1853 switch (cmd_ctx
->lsm
.domain
.type
) {
1854 case LTTNG_DOMAIN_KERNEL
:
1855 cdata
= &kconsumer_data
;
1858 ret
= LTTNG_ERR_UND
;
1862 ret
= cmd_register_consumer(cmd_ctx
->session
, cmd_ctx
->lsm
.domain
.type
,
1863 cmd_ctx
->lsm
.u
.reg
.path
, cdata
);
1866 case LTTNG_DATA_PENDING
:
1869 uint8_t pending_ret_byte
;
1871 pending_ret
= cmd_data_pending(cmd_ctx
->session
);
1876 * This function may returns 0 or 1 to indicate whether or not
1877 * there is data pending. In case of error, it should return an
1878 * LTTNG_ERR code. However, some code paths may still return
1879 * a nondescript error code, which we handle by returning an
1882 if (pending_ret
== 0 || pending_ret
== 1) {
1884 * ret will be set to LTTNG_OK at the end of
1887 } else if (pending_ret
< 0) {
1888 ret
= LTTNG_ERR_UNK
;
1895 pending_ret_byte
= (uint8_t) pending_ret
;
1897 /* 1 byte to return whether or not data is pending */
1898 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
,
1899 &pending_ret_byte
, 1);
1908 case LTTNG_SNAPSHOT_ADD_OUTPUT
:
1910 uint32_t snapshot_id
;
1911 struct lttcomm_lttng_output_id reply
;
1913 ret
= cmd_snapshot_add_output(cmd_ctx
->session
,
1914 ALIGNED_CONST_PTR(cmd_ctx
->lsm
.u
.snapshot_output
.output
),
1916 if (ret
!= LTTNG_OK
) {
1919 reply
.id
= snapshot_id
;
1921 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
, &reply
,
1927 /* Copy output list into message payload */
1931 case LTTNG_SNAPSHOT_DEL_OUTPUT
:
1933 ret
= cmd_snapshot_del_output(cmd_ctx
->session
,
1934 ALIGNED_CONST_PTR(cmd_ctx
->lsm
.u
.snapshot_output
.output
));
1937 case LTTNG_SNAPSHOT_LIST_OUTPUT
:
1940 struct lttng_snapshot_output
*outputs
= NULL
;
1942 nb_output
= cmd_snapshot_list_outputs(cmd_ctx
->session
, &outputs
);
1943 if (nb_output
< 0) {
1948 assert((nb_output
> 0 && outputs
) || nb_output
== 0);
1949 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
, outputs
,
1950 nb_output
* sizeof(struct lttng_snapshot_output
));
1960 case LTTNG_SNAPSHOT_RECORD
:
1962 ret
= cmd_snapshot_record(cmd_ctx
->session
,
1963 ALIGNED_CONST_PTR(cmd_ctx
->lsm
.u
.snapshot_record
.output
),
1964 cmd_ctx
->lsm
.u
.snapshot_record
.wait
);
1967 case LTTNG_CREATE_SESSION_EXT
:
1969 struct lttng_dynamic_buffer payload
;
1970 struct lttng_session_descriptor
*return_descriptor
= NULL
;
1972 lttng_dynamic_buffer_init(&payload
);
1973 ret
= cmd_create_session(cmd_ctx
, *sock
, &return_descriptor
);
1974 if (ret
!= LTTNG_OK
) {
1978 ret
= lttng_session_descriptor_serialize(return_descriptor
,
1981 ERR("Failed to serialize session descriptor in reply to \"create session\" command");
1982 lttng_session_descriptor_destroy(return_descriptor
);
1983 ret
= LTTNG_ERR_NOMEM
;
1986 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
, payload
.data
,
1989 lttng_session_descriptor_destroy(return_descriptor
);
1990 ret
= LTTNG_ERR_NOMEM
;
1993 lttng_dynamic_buffer_reset(&payload
);
1994 lttng_session_descriptor_destroy(return_descriptor
);
1998 case LTTNG_SAVE_SESSION
:
2000 ret
= cmd_save_sessions(&cmd_ctx
->lsm
.u
.save_session
.attr
,
2004 case LTTNG_SET_SESSION_SHM_PATH
:
2006 ret
= cmd_set_session_shm_path(cmd_ctx
->session
,
2007 cmd_ctx
->lsm
.u
.set_shm_path
.shm_path
);
2010 case LTTNG_REGENERATE_METADATA
:
2012 ret
= cmd_regenerate_metadata(cmd_ctx
->session
);
2015 case LTTNG_REGENERATE_STATEDUMP
:
2017 ret
= cmd_regenerate_statedump(cmd_ctx
->session
);
2020 case LTTNG_REGISTER_TRIGGER
:
2022 ret
= cmd_register_trigger(cmd_ctx
, *sock
,
2023 notification_thread_handle
);
2026 case LTTNG_UNREGISTER_TRIGGER
:
2028 ret
= cmd_unregister_trigger(cmd_ctx
, *sock
,
2029 notification_thread_handle
);
2032 case LTTNG_ROTATE_SESSION
:
2034 struct lttng_rotate_session_return rotate_return
;
2036 DBG("Client rotate session \"%s\"", cmd_ctx
->session
->name
);
2038 memset(&rotate_return
, 0, sizeof(rotate_return
));
2039 if (cmd_ctx
->session
->kernel_session
&& !check_rotate_compatible()) {
2040 DBG("Kernel tracer version is not compatible with the rotation feature");
2041 ret
= LTTNG_ERR_ROTATION_WRONG_VERSION
;
2045 ret
= cmd_rotate_session(cmd_ctx
->session
, &rotate_return
,
2047 LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED
);
2053 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
, &rotate_return
,
2054 sizeof(rotate_return
));
2063 case LTTNG_ROTATION_GET_INFO
:
2065 struct lttng_rotation_get_info_return get_info_return
;
2067 memset(&get_info_return
, 0, sizeof(get_info_return
));
2068 ret
= cmd_rotate_get_info(cmd_ctx
->session
, &get_info_return
,
2069 cmd_ctx
->lsm
.u
.get_rotation_info
.rotation_id
);
2075 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
, &get_info_return
,
2076 sizeof(get_info_return
));
2085 case LTTNG_ROTATION_SET_SCHEDULE
:
2088 enum lttng_rotation_schedule_type schedule_type
;
2091 if (cmd_ctx
->session
->kernel_session
&& !check_rotate_compatible()) {
2092 DBG("Kernel tracer version does not support session rotations");
2093 ret
= LTTNG_ERR_ROTATION_WRONG_VERSION
;
2097 set_schedule
= cmd_ctx
->lsm
.u
.rotation_set_schedule
.set
== 1;
2098 schedule_type
= (enum lttng_rotation_schedule_type
) cmd_ctx
->lsm
.u
.rotation_set_schedule
.type
;
2099 value
= cmd_ctx
->lsm
.u
.rotation_set_schedule
.value
;
2101 ret
= cmd_rotation_set_schedule(cmd_ctx
->session
,
2105 notification_thread_handle
);
2106 if (ret
!= LTTNG_OK
) {
2112 case LTTNG_SESSION_LIST_ROTATION_SCHEDULES
:
2114 struct lttng_session_list_schedules_return schedules
= {
2115 .periodic
.set
= !!cmd_ctx
->session
->rotate_timer_period
,
2116 .periodic
.value
= cmd_ctx
->session
->rotate_timer_period
,
2117 .size
.set
= !!cmd_ctx
->session
->rotate_size
,
2118 .size
.value
= cmd_ctx
->session
->rotate_size
,
2121 ret
= setup_lttng_msg_no_cmd_header(cmd_ctx
, &schedules
,
2131 case LTTNG_CLEAR_SESSION
:
2133 ret
= cmd_clear_session(cmd_ctx
->session
, sock
);
2137 ret
= LTTNG_ERR_UND
;
2142 if (cmd_ctx
->reply_payload
.buffer
.size
== 0) {
2143 DBG("Missing llm header, creating one.");
2144 if (setup_lttng_msg_no_cmd_header(cmd_ctx
, NULL
, 0) < 0) {
2148 /* Set return code */
2149 ((struct lttcomm_lttng_msg
*) (cmd_ctx
->reply_payload
.buffer
.data
))->ret_code
= ret
;
2151 if (cmd_ctx
->session
) {
2152 session_unlock(cmd_ctx
->session
);
2153 session_put(cmd_ctx
->session
);
2154 cmd_ctx
->session
= NULL
;
2156 if (need_tracing_session
) {
2157 session_unlock_list();
2160 assert(!rcu_read_ongoing());
2164 static int create_client_sock(void)
2166 int ret
, client_sock
;
2167 const mode_t old_umask
= umask(0);
2169 /* Create client tool unix socket */
2170 client_sock
= lttcomm_create_unix_sock(config
.client_unix_sock_path
.value
);
2171 if (client_sock
< 0) {
2172 ERR("Create unix sock failed: %s", config
.client_unix_sock_path
.value
);
2177 /* Set the cloexec flag */
2178 ret
= utils_set_fd_cloexec(client_sock
);
2180 ERR("Unable to set CLOEXEC flag to the client Unix socket (fd: %d). "
2181 "Continuing but note that the consumer daemon will have a "
2182 "reference to this socket on exec()", client_sock
);
2185 /* File permission MUST be 660 */
2186 ret
= chmod(config
.client_unix_sock_path
.value
, S_IRUSR
| S_IWUSR
| S_IRGRP
| S_IWGRP
);
2188 ERR("Set file permissions failed: %s",
2189 config
.client_unix_sock_path
.value
);
2191 (void) lttcomm_close_unix_sock(client_sock
);
2195 DBG("Created client socket (fd = %i)", client_sock
);
2202 static void cleanup_client_thread(void *data
)
2204 struct lttng_pipe
*quit_pipe
= data
;
2206 lttng_pipe_destroy(quit_pipe
);
2209 static void thread_init_cleanup(void *data
)
2211 set_thread_status(false);
2215 * This thread manage all clients request using the unix client socket for
2218 static void *thread_manage_clients(void *data
)
2220 int sock
= -1, ret
, i
, pollfd
, err
= -1;
2222 uint32_t revents
, nb_fd
;
2223 struct lttng_poll_event events
;
2224 const int client_sock
= thread_state
.client_sock
;
2225 struct lttng_pipe
*quit_pipe
= data
;
2226 const int thread_quit_pipe_fd
= lttng_pipe_get_readfd(quit_pipe
);
2227 struct command_ctx cmd_ctx
= {};
2229 DBG("[thread] Manage client started");
2231 lttng_payload_init(&cmd_ctx
.reply_payload
);
2233 is_root
= (getuid() == 0);
2235 pthread_cleanup_push(thread_init_cleanup
, NULL
);
2237 rcu_register_thread();
2239 health_register(health_sessiond
, HEALTH_SESSIOND_TYPE_CMD
);
2241 health_code_update();
2243 ret
= lttcomm_listen_unix_sock(client_sock
);
2249 * Pass 2 as size here for the thread quit pipe and client_sock. Nothing
2250 * more will be added to this poll set.
2252 ret
= lttng_poll_create(&events
, 2, LTTNG_CLOEXEC
);
2254 goto error_create_poll
;
2257 /* Add the application registration socket */
2258 ret
= lttng_poll_add(&events
, client_sock
, LPOLLIN
| LPOLLPRI
);
2263 /* Add thread quit pipe */
2264 ret
= lttng_poll_add(&events
, thread_quit_pipe_fd
, LPOLLIN
| LPOLLERR
);
2269 /* Set state as running. */
2270 set_thread_status(true);
2271 pthread_cleanup_pop(0);
2273 /* This testpoint is after we signal readiness to the parent. */
2274 if (testpoint(sessiond_thread_manage_clients
)) {
2278 if (testpoint(sessiond_thread_manage_clients_before_loop
)) {
2282 health_code_update();
2285 const struct cmd_completion_handler
*cmd_completion_handler
;
2287 cmd_ctx
.creds
= (lttng_sock_cred
) {
2291 cmd_ctx
.session
= NULL
;
2292 lttng_payload_clear(&cmd_ctx
.reply_payload
);
2293 cmd_ctx
.lttng_msg_size
= 0;
2295 DBG("Accepting client command ...");
2297 /* Inifinite blocking call, waiting for transmission */
2299 health_poll_entry();
2300 ret
= lttng_poll_wait(&events
, -1);
2304 * Restart interrupted system call.
2306 if (errno
== EINTR
) {
2314 for (i
= 0; i
< nb_fd
; i
++) {
2315 revents
= LTTNG_POLL_GETEV(&events
, i
);
2316 pollfd
= LTTNG_POLL_GETFD(&events
, i
);
2318 health_code_update();
2320 if (pollfd
== thread_quit_pipe_fd
) {
2324 /* Event on the registration socket */
2325 if (revents
& LPOLLIN
) {
2327 } else if (revents
& (LPOLLERR
| LPOLLHUP
| LPOLLRDHUP
)) {
2328 ERR("Client socket poll error");
2331 ERR("Unexpected poll events %u for sock %d", revents
, pollfd
);
2337 DBG("Wait for client response");
2339 health_code_update();
2341 sock
= lttcomm_accept_unix_sock(client_sock
);
2347 * Set the CLOEXEC flag. Return code is useless because either way, the
2350 (void) utils_set_fd_cloexec(sock
);
2352 /* Set socket option for credentials retrieval */
2353 ret
= lttcomm_setsockopt_creds_unix_sock(sock
);
2358 health_code_update();
2361 * Data is received from the lttng client. The struct
2362 * lttcomm_session_msg (lsm) contains the command and data request of
2365 DBG("Receiving data from client ...");
2366 ret
= lttcomm_recv_creds_unix_sock(sock
, &cmd_ctx
.lsm
,
2367 sizeof(struct lttcomm_session_msg
), &cmd_ctx
.creds
);
2368 if (ret
!= sizeof(struct lttcomm_session_msg
)) {
2369 DBG("Incomplete recv() from client... continuing");
2378 health_code_update();
2380 // TODO: Validate cmd_ctx including sanity check for
2381 // security purpose.
2383 rcu_thread_online();
2385 * This function dispatch the work to the kernel or userspace tracer
2386 * libs and fill the lttcomm_lttng_msg data structure of all the needed
2387 * informations for the client. The command context struct contains
2388 * everything this function may needs.
2390 ret
= process_client_msg(&cmd_ctx
, &sock
, &sock_error
);
2391 rcu_thread_offline();
2401 * TODO: Inform client somehow of the fatal error. At
2402 * this point, ret < 0 means that a zmalloc failed
2403 * (ENOMEM). Error detected but still accept
2404 * command, unless a socket error has been
2410 cmd_completion_handler
= cmd_pop_completion_handler();
2411 if (cmd_completion_handler
) {
2412 enum lttng_error_code completion_code
;
2414 completion_code
= cmd_completion_handler
->run(
2415 cmd_completion_handler
->data
);
2416 if (completion_code
!= LTTNG_OK
) {
2421 health_code_update();
2424 struct lttng_payload_view view
=
2425 lttng_payload_view_from_payload(
2426 &cmd_ctx
.reply_payload
,
2428 struct lttcomm_lttng_msg
*llm
= (typeof(
2429 llm
)) cmd_ctx
.reply_payload
.buffer
.data
;
2431 assert(cmd_ctx
.reply_payload
.buffer
.size
>=
2433 assert(cmd_ctx
.lttng_msg_size
== cmd_ctx
.reply_payload
.buffer
.size
);
2435 llm
->fd_count
= lttng_payload_view_get_fd_handle_count(&view
);
2437 DBG("Sending response (size: %d, retcode: %s (%d))",
2438 cmd_ctx
.lttng_msg_size
,
2439 lttng_strerror(-llm
->ret_code
),
2441 ret
= send_unix_sock(sock
, &view
);
2443 ERR("Failed to send data back to client");
2446 /* End of transmission */
2454 health_code_update();
2466 lttng_poll_clean(&events
);
2470 unlink(config
.client_unix_sock_path
.value
);
2471 ret
= close(client_sock
);
2478 ERR("Health error occurred in %s", __func__
);
2481 health_unregister(health_sessiond
);
2483 DBG("Client thread dying");
2484 lttng_payload_reset(&cmd_ctx
.reply_payload
);
2485 rcu_unregister_thread();
2490 bool shutdown_client_thread(void *thread_data
)
2492 struct lttng_pipe
*client_quit_pipe
= thread_data
;
2493 const int write_fd
= lttng_pipe_get_writefd(client_quit_pipe
);
2495 return notify_thread_pipe(write_fd
) == 1;
2498 struct lttng_thread
*launch_client_thread(void)
2500 bool thread_running
;
2501 struct lttng_pipe
*client_quit_pipe
;
2502 struct lttng_thread
*thread
= NULL
;
2503 int client_sock_fd
= -1;
2505 sem_init(&thread_state
.ready
, 0, 0);
2506 client_quit_pipe
= lttng_pipe_open(FD_CLOEXEC
);
2507 if (!client_quit_pipe
) {
2511 client_sock_fd
= create_client_sock();
2512 if (client_sock_fd
< 0) {
2516 thread_state
.client_sock
= client_sock_fd
;
2517 thread
= lttng_thread_create("Client management",
2518 thread_manage_clients
,
2519 shutdown_client_thread
,
2520 cleanup_client_thread
,
2525 /* The client thread now owns the client sock fd and the quit pipe. */
2526 client_sock_fd
= -1;
2527 client_quit_pipe
= NULL
;
2530 * This thread is part of the threads that need to be fully
2531 * initialized before the session daemon is marked as "ready".
2533 thread_running
= wait_thread_status();
2534 if (!thread_running
) {
2539 if (client_sock_fd
>= 0) {
2540 if (close(client_sock_fd
)) {
2541 PERROR("Failed to close client socket");
2544 lttng_thread_put(thread
);
2545 cleanup_client_thread(client_quit_pipe
);