Backport: trackers: update lttng-sessiond
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 23c6c31a2fc05528476cd5f9d99ba9a1410a72ba..d5ed1dcfc39e4d02a6d0a8996f1d7945c91f2137 100644 (file)
@@ -41,6 +41,7 @@
 #include "syscall.h"
 #include "agent.h"
 #include "buffer-registry.h"
+#include "agent-thread.h"
 
 #include "cmd.h"
 
@@ -1194,12 +1195,14 @@ error:
 }
 
 /*
- * Command LTTNG_TRACK_PID processed by the client thread.
+ * Command LTTNG_TRACK_ID processed by the client thread.
  *
  * Called with session lock held.
  */
-int cmd_track_pid(struct ltt_session *session, enum lttng_domain_type domain,
-               int pid)
+int cmd_track_id(struct ltt_session *session,
+               enum lttng_tracker_type tracker_type,
+               enum lttng_domain_type domain,
+               struct lttng_tracker_id *id)
 {
        int ret;
 
@@ -1212,7 +1215,7 @@ int cmd_track_pid(struct ltt_session *session, enum lttng_domain_type domain,
 
                ksess = session->kernel_session;
 
-               ret = kernel_track_pid(ksess, pid);
+               ret = kernel_track_id(tracker_type, ksess, id);
                if (ret != LTTNG_OK) {
                        goto error;
                }
@@ -1226,7 +1229,7 @@ int cmd_track_pid(struct ltt_session *session, enum lttng_domain_type domain,
 
                usess = session->ust_session;
 
-               ret = trace_ust_track_pid(usess, pid);
+               ret = trace_ust_track_id(tracker_type, usess, id);
                if (ret != LTTNG_OK) {
                        goto error;
                }
@@ -1245,12 +1248,14 @@ error:
 }
 
 /*
- * Command LTTNG_UNTRACK_PID processed by the client thread.
+ * Command LTTNG_UNTRACK_ID processed by the client thread.
  *
  * Called with session lock held.
  */
-int cmd_untrack_pid(struct ltt_session *session, enum lttng_domain_type domain,
-               int pid)
+int cmd_untrack_id(struct ltt_session *session,
+               enum lttng_tracker_type tracker_type,
+               enum lttng_domain_type domain,
+               struct lttng_tracker_id *id)
 {
        int ret;
 
@@ -1263,7 +1268,7 @@ int cmd_untrack_pid(struct ltt_session *session, enum lttng_domain_type domain,
 
                ksess = session->kernel_session;
 
-               ret = kernel_untrack_pid(ksess, pid);
+               ret = kernel_untrack_id(tracker_type, ksess, id);
                if (ret != LTTNG_OK) {
                        goto error;
                }
@@ -1277,7 +1282,7 @@ int cmd_untrack_pid(struct ltt_session *session, enum lttng_domain_type domain,
 
                usess = session->ust_session;
 
-               ret = trace_ust_untrack_pid(usess, pid);
+               ret = trace_ust_untrack_id(tracker_type, usess, id);
                if (ret != LTTNG_OK) {
                        goto error;
                }
@@ -1344,6 +1349,21 @@ int cmd_enable_channel(struct ltt_session *session,
                attr->attr.switch_timer_interval = 0;
        }
 
+       /* Check for feature support */
+       switch (domain->type) {
+       case LTTNG_DOMAIN_JUL:
+       case LTTNG_DOMAIN_LOG4J:
+       case LTTNG_DOMAIN_PYTHON:
+               if (!agent_tracing_is_enabled()) {
+                       DBG("Attempted to enable a channel in an agent domain but the agent thread is not running");
+                       ret = LTTNG_ERR_AGENT_TRACING_DISABLED;
+                       goto error;
+               }
+               break;
+       default:
+               break;
+       }
+
        switch (domain->type) {
        case LTTNG_DOMAIN_KERNEL:
        {
@@ -2077,6 +2097,12 @@ static int _cmd_enable_event(struct ltt_session *session,
 
                assert(usess);
 
+               if (!agent_tracing_is_enabled()) {
+                       DBG("Attempted to enable an event in an agent domain but the agent thread is not running");
+                       ret = LTTNG_ERR_AGENT_TRACING_DISABLED;
+                       goto error;
+               }
+
                agt = trace_ust_find_agent(usess, domain->type);
                if (!agt) {
                        agt = agent_create(domain->type);
@@ -2310,12 +2336,14 @@ ssize_t cmd_list_syscalls(struct lttng_event **events)
 }
 
 /*
- * Command LTTNG_LIST_TRACKER_PIDS processed by the client thread.
+ * Command LTTNG_LIST_TRACKER_IDS processed by the client thread.
  *
  * Called with session lock held.
  */
-ssize_t cmd_list_tracker_pids(struct ltt_session *session,
-               enum lttng_domain_type domain, int32_t **pids)
+ssize_t cmd_list_tracker_ids(enum lttng_tracker_type tracker_type,
+               struct ltt_session *session,
+               enum lttng_domain_type domain,
+               struct lttng_tracker_id **ids)
 {
        int ret;
        ssize_t nr_pids = 0;
@@ -2326,7 +2354,7 @@ ssize_t cmd_list_tracker_pids(struct ltt_session *session,
                struct ltt_kernel_session *ksess;
 
                ksess = session->kernel_session;
-               nr_pids = kernel_list_tracker_pids(ksess, pids);
+               nr_pids = kernel_list_tracker_ids(tracker_type, ksess, ids);
                if (nr_pids < 0) {
                        ret = LTTNG_ERR_KERN_LIST_FAIL;
                        goto error;
@@ -2338,7 +2366,7 @@ ssize_t cmd_list_tracker_pids(struct ltt_session *session,
                struct ltt_ust_session *usess;
 
                usess = session->ust_session;
-               nr_pids = trace_ust_list_tracker_pids(usess, pids);
+               nr_pids = trace_ust_list_tracker_ids(tracker_type, usess, ids);
                if (nr_pids < 0) {
                        ret = LTTNG_ERR_UST_LIST_FAIL;
                        goto error;
@@ -3407,10 +3435,12 @@ static
 int clear_metadata_file(int fd)
 {
        int ret;
+       off_t lseek_ret;
 
-       ret = lseek(fd, 0, SEEK_SET);
-       if (ret < 0) {
+       lseek_ret = lseek(fd, 0, SEEK_SET);
+       if (lseek_ret < 0) {
                PERROR("lseek");
+               ret = -1;
                goto end;
        }
 
This page took 0.026738 seconds and 5 git commands to generate.