Also, don't spawn the kernel thread if not root and the no-kernel option
is set.
Fixes #316
Signed-off-by: David Goulet <dgoulet@efficios.com>
/* Close thread quit pipes */
utils_close_pipe(thread_quit_pipe);
/* Close thread quit pipes */
utils_close_pipe(thread_quit_pipe);
- /* Close relay cmd pipes */
- utils_close_pipe(relay_cmd_pipe);
-
uri_free(control_uri);
uri_free(data_uri);
}
uri_free(control_uri);
uri_free(data_uri);
}
streams_ht_error:
lttng_ht_destroy(relay_connections_ht);
relay_connections_ht_error:
streams_ht_error:
lttng_ht_destroy(relay_connections_ht);
relay_connections_ht_error:
+ /* Close relay cmd pipes */
+ utils_close_pipe(relay_cmd_pipe);
if (err) {
DBG("Thread exited with error");
}
if (err) {
DBG("Thread exited with error");
}
{
struct ltt_kernel_channel *kchan;
{
struct ltt_kernel_channel *kchan;
- /* Mandatory for a kernel channel. */
- assert(wpipe > 0);
-
kchan = trace_kernel_get_channel_by_name(attr->name,
session->kernel_session);
if (kchan == NULL) {
kchan = trace_kernel_get_channel_by_name(attr->name,
session->kernel_session);
if (kchan == NULL) {
static void cleanup(void)
{
int ret;
static void cleanup(void)
{
int ret;
struct ltt_session *sess, *stmp;
DBG("Cleaning up");
struct ltt_session *sess, *stmp;
DBG("Cleaning up");
modprobe_remove_lttng_all();
}
modprobe_remove_lttng_all();
}
- utils_close_pipe(kernel_poll_pipe);
- utils_close_pipe(apps_cmd_pipe);
-
/* <fun> */
DBG("%c[%d;%dm*** assert failed :-) *** ==> %c[%dm%c[%d;%dm"
"Matthew, BEET driven development works!%c[%dm",
/* <fun> */
DBG("%c[%d;%dm*** assert failed :-) *** ==> %c[%dm%c[%d;%dm"
"Matthew, BEET driven development works!%c[%dm",
error:
lttng_poll_clean(&events);
error_poll_create:
error:
lttng_poll_clean(&events);
error_poll_create:
+ utils_close_pipe(kernel_poll_pipe);
+ kernel_poll_pipe[0] = kernel_poll_pipe[1] = -1;
if (err) {
health_error(&health_thread_kernel);
ERR("Health error occurred in %s", __func__);
if (err) {
health_error(&health_thread_kernel);
ERR("Health error occurred in %s", __func__);
+ WARN("Kernel thread died unexpectedly. "
+ "Kernel tracing can continue but CPU hotplug is disabled.");
}
health_exit(&health_thread_kernel);
DBG("Kernel thread dying");
}
health_exit(&health_thread_kernel);
DBG("Kernel thread dying");
error:
lttng_poll_clean(&events);
error_poll_create:
error:
lttng_poll_clean(&events);
error_poll_create:
+ utils_close_pipe(apps_cmd_pipe);
+ apps_cmd_pipe[0] = apps_cmd_pipe[1] = -1;
+
+ /*
+ * We don't clean the UST app hash table here since already registered
+ * applications can still be controlled so let them be until the session
+ * daemon dies or the applications stop.
+ */
+
if (err) {
health_error(&health_thread_app_manage);
ERR("Health error occurred in %s", __func__);
if (err) {
health_error(&health_thread_app_manage);
ERR("Health error occurred in %s", __func__);
* call is blocking so we can be assured that the data will be read
* at some point in time or wait to the end of the world :)
*/
* call is blocking so we can be assured that the data will be read
* at some point in time or wait to the end of the world :)
*/
- ret = write(apps_cmd_pipe[1], ust_cmd,
- sizeof(struct ust_command));
- if (ret < 0) {
- PERROR("write apps cmd pipe");
- if (errno == EBADF) {
- /*
- * We can't inform the application thread to process
- * registration. We will exit or else application
- * registration will not occur and tracing will never
- * start.
- */
- goto error;
+ if (apps_cmd_pipe[1] >= 0) {
+ ret = write(apps_cmd_pipe[1], ust_cmd,
+ sizeof(struct ust_command));
+ if (ret < 0) {
+ PERROR("write apps cmd pipe");
+ if (errno == EBADF) {
+ /*
+ * We can't inform the application thread to process
+ * registration. We will exit or else application
+ * registration will not occur and tracing will never
+ * start.
+ */
+ goto error;
+ }
+ }
+ } else {
+ /* Application manager thread is not available. */
+ ret = close(ust_cmd->sock);
+ if (ret < 0) {
+ PERROR("close ust_cmd sock");
}
/* Setup the kernel pipe for waking up the kernel thread */
}
/* Setup the kernel pipe for waking up the kernel thread */
- if ((ret = utils_create_pipe_cloexec(kernel_poll_pipe)) < 0) {
- goto exit;
+ if (is_root && !opt_no_kernel) {
+ if ((ret = utils_create_pipe_cloexec(kernel_poll_pipe)) < 0) {
+ goto exit;
+ }
}
/* Setup the thread apps communication pipe. */
}
/* Setup the thread apps communication pipe. */
- /* Create kernel thread to manage kernel event */
- ret = pthread_create(&kernel_thread, NULL,
- thread_manage_kernel, (void *) NULL);
- if (ret != 0) {
- PERROR("pthread_create kernel");
- goto exit_kernel;
- }
+ /* Don't start this thread if kernel tracing is not requested nor root */
+ if (is_root && !opt_no_kernel) {
+ /* Create kernel thread to manage kernel event */
+ ret = pthread_create(&kernel_thread, NULL,
+ thread_manage_kernel, (void *) NULL);
+ if (ret != 0) {
+ PERROR("pthread_create kernel");
+ goto exit_kernel;
+ }
- ret = pthread_join(kernel_thread, &status);
- if (ret != 0) {
- PERROR("pthread_join");
- goto error; /* join error, exit without cleanup */
+ ret = pthread_join(kernel_thread, &status);
+ if (ret != 0) {
+ PERROR("pthread_join");
+ goto error; /* join error, exit without cleanup */
+ }