Add ust stop trace feature
[lttng-tools.git] / ltt-sessiond / main.c
index 70ce53c8b1cd50c87e1712bc42a2c2e0ba0f9bd4..150f211fb825a44e1e614a3222744d7edf51a4bc 100644 (file)
@@ -374,6 +374,42 @@ error:
        return ret;
 }
 
        return ret;
 }
 
+/*
+ *  ust_stop_trace
+ *
+ *  Stop a trace. This trace, identified by the pid, must be
+ *  in the current session ust_traces list.
+ */
+static int ust_stop_trace(pid_t pid)
+{
+       int sock, ret;
+       struct ltt_ust_trace *trace;
+
+       DBG("Stopping trace for pid %d", pid);
+
+       trace = find_session_ust_trace_by_pid(current_session, pid);
+       if (trace == NULL) {
+               ret = LTTCOMM_NO_TRACE;
+               goto error;
+       }
+
+       /* Connect to app using ustctl API */
+       sock = connect_app(pid);
+       if (sock < 0) {
+               ret = LTTCOMM_NO_TRACEABLE;
+               goto error;
+       }
+
+       ret = ustctl_stop_trace(sock, trace->name);
+       if (ret < 0) {
+               ret = LTTCOMM_STOP_FAIL;
+               goto error;
+       }
+
+error:
+       return ret;
+}
+
 /*
  *  copy_common_data
  *
 /*
  *  copy_common_data
  *
@@ -564,6 +600,13 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm)
                        /* No auxiliary data so only send the llm struct. */
                        goto end;
                }
                        /* No auxiliary data so only send the llm struct. */
                        goto end;
                }
+               case UST_STOP_TRACE:
+               {
+                       ret = ust_stop_trace(lsm->pid);
+
+                       /* No auxiliary data so only send the llm struct. */
+                       goto end;
+               }
                case LTTNG_LIST_SESSIONS:
                {
                        unsigned int session_count = get_session_count();
                case LTTNG_LIST_SESSIONS:
                {
                        unsigned int session_count = get_session_count();
This page took 0.022877 seconds and 4 git commands to generate.