Implement UST stop command
[lttng-tools.git] / lttng-sessiond / main.c
index 0c93395b4a573ddbbaeca68332692e5169d777d2..9464c2c1b8e0f4f3d17ef300cf15975d2174c6ec 100644 (file)
@@ -157,6 +157,8 @@ static struct ust_cmd_queue ust_cmd_queue;
  */
 static struct ltt_session_list *session_list_ptr;
 
+int ust_consumer_fd;
+
 /*
  * Create a poll set with O_CLOEXEC and add the thread quit pipe to the set.
  */
@@ -1788,6 +1790,7 @@ static void list_lttng_sessions(struct lttng_session *sessions)
                sessions[i].path[PATH_MAX - 1] = '\0';
                strncpy(sessions[i].name, session->name, NAME_MAX);
                sessions[i].name[NAME_MAX - 1] = '\0';
+               sessions[i].enabled = session->enabled;
                i++;
        }
 }
@@ -2510,6 +2513,10 @@ static int cmd_start_trace(struct ltt_session *session)
        ksession = session->kernel_session;
        usess = session->ust_session;
 
+       if (session->enabled)
+               return LTTCOMM_UST_START_FAIL;
+       session->enabled = 1;
+
        /* Kernel tracing */
        if (ksession != NULL) {
                struct ltt_kernel_channel *kchan;
@@ -2589,11 +2596,15 @@ static int cmd_stop_trace(struct ltt_session *session)
        int ret;
        struct ltt_kernel_channel *kchan;
        struct ltt_kernel_session *ksession;
-       //struct ltt_ust_session *usess;
-       //struct ltt_ust_channel *ustchan;
+       struct ltt_ust_session *usess;
 
        /* Short cut */
        ksession = session->kernel_session;
+       usess = session->ust_session;
+
+       if (!session->enabled)
+               return LTTCOMM_UST_START_FAIL;
+       session->enabled = 0;
 
        /* Kernel tracer */
        if (ksession != NULL) {
@@ -2621,32 +2632,16 @@ static int cmd_stop_trace(struct ltt_session *session)
                kernel_wait_quiescent(kernel_tracer_fd);
        }
 
-#ifdef DISABLE
-       /* Stop each UST session */
-       DBG("Stop UST tracing");
-       cds_list_for_each_entry(usess, &session->ust_session_list.head, list) {
-               /* Flush all buffers before stopping */
-               ret = ustctl_flush_buffer(usess->sock, usess->metadata->obj);
-               if (ret < 0) {
-                       ERR("UST metadata flush failed");
-               }
-
-               cds_list_for_each_entry(ustchan, &usess->channels.head, list) {
-                       ret = ustctl_flush_buffer(usess->sock, ustchan->obj);
-                       if (ret < 0) {
-                               ERR("UST flush buffer error");
-                       }
-               }
+       /* Flag session that trace should start automatically */
+       if (usess) {
+               usess->start_trace = 0;
 
-               ret = ustctl_stop_session(usess->sock, usess->handle);
+               ret = ust_app_stop_trace_all(usess);
                if (ret < 0) {
-                       ret = LTTCOMM_KERN_STOP_FAIL;
+                       ret = LTTCOMM_UST_START_FAIL;
                        goto error;
                }
-
-               ustctl_wait_quiescent(usess->sock);
        }
-#endif
 
        ret = LTTCOMM_OK;
 
@@ -3010,8 +3005,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                                        goto error;
                                }
 
-                               cmd_ctx->session->ust_session->consumer_fd =
-                                       ustconsumer_data.cmd_sock;
+                               ust_consumer_fd = ustconsumer_data.cmd_sock;
                        }
                        pthread_mutex_unlock(&ustconsumer_data.pid_mutex);
                }
This page took 0.024105 seconds and 4 git commands to generate.