static void cleanup(void)
{
int ret;
- char *cmd;
+ char *cmd = NULL;
struct ltt_session *sess, *stmp;
DBG("Cleaning up");
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",
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__);
+ WARN("Kernel thread died unexpectedly. "
+ "Kernel tracing can continue but CPU hotplug is disabled.");
}
health_exit(&health_thread_kernel);
DBG("Kernel thread dying");
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__);
* 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");
}
}
free(ust_cmd);
}
/* 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. */
goto exit_apps;
}
- /* 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 */
+ }
}
exit_kernel: