Fix: don't ask data pending if session was not started
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 532af7d9917b733b33b59d6309f9a184417c6fbb..6df18935e0d1caadd24094aaf0ec03cfba06347c 100644 (file)
@@ -458,6 +458,7 @@ static int add_uri_to_consumer(struct consumer_output *consumer,
                         * URI was the same in the consumer so we do not append the subdir
                         * again so to not duplicate output dir.
                         */
+                       ret = LTTNG_OK;
                        goto error;
                }
 
@@ -1309,6 +1310,7 @@ error:
  */
 int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
                char *channel_name, struct lttng_event *event,
+               char *filter_expression,
                struct lttng_filter_bytecode *filter,
                struct lttng_event_exclusion *exclusion,
                int wpipe)
@@ -1424,7 +1426,8 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
                }
 
                /* At this point, the session and channel exist on the tracer */
-               ret = event_ust_enable_tracepoint(usess, uchan, event, filter, exclusion);
+               ret = event_ust_enable_tracepoint(usess, uchan, event,
+                               filter_expression, filter, exclusion);
                if (ret != LTTNG_OK) {
                        goto error;
                }
@@ -1460,7 +1463,7 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
                tmp_dom.type = LTTNG_DOMAIN_UST;
 
                ret = cmd_enable_event(session, &tmp_dom, DEFAULT_JUL_CHANNEL_NAME,
-                               &uevent, NULL, NULL, wpipe);
+                       &uevent, NULL, NULL, NULL, wpipe);
                if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) {
                        goto error;
                }
@@ -1499,6 +1502,7 @@ error:
  */
 int cmd_enable_event_all(struct ltt_session *session,
                struct lttng_domain *domain, char *channel_name, int event_type,
+               char *filter_expression,
                struct lttng_filter_bytecode *filter, int wpipe)
 {
        int ret;
@@ -1632,7 +1636,8 @@ int cmd_enable_event_all(struct ltt_session *session,
                switch (event_type) {
                case LTTNG_EVENT_ALL:
                case LTTNG_EVENT_TRACEPOINT:
-                       ret = event_ust_enable_all_tracepoints(usess, uchan, filter);
+                       ret = event_ust_enable_all_tracepoints(usess, uchan,
+                               filter_expression, filter);
                        if (ret != LTTNG_OK) {
                                goto error;
                        }
@@ -1678,7 +1683,7 @@ int cmd_enable_event_all(struct ltt_session *session,
                tmp_dom.type = LTTNG_DOMAIN_UST;
 
                ret = cmd_enable_event(session, &tmp_dom, DEFAULT_JUL_CHANNEL_NAME,
-                               &uevent, NULL, NULL, wpipe);
+                       &uevent, NULL, NULL, NULL, wpipe);
                if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) {
                        goto error;
                }
@@ -2506,6 +2511,7 @@ void cmd_list_lttng_sessions(struct lttng_session *sessions, uid_t uid,
                sessions[i].name[NAME_MAX - 1] = '\0';
                sessions[i].enabled = session->enabled;
                sessions[i].snapshot_mode = session->snapshot_mode;
+               sessions[i].live_timer_interval = session->live_timer;
                i++;
        }
 }
@@ -2526,6 +2532,21 @@ int cmd_data_pending(struct ltt_session *session)
        if (session->enabled) {
                ret = LTTNG_ERR_SESSION_STARTED;
                goto error;
+       } else {
+               /*
+                * If stopped, just make sure we've started before else the above call
+                * will always send that there is data pending.
+                *
+                * The consumer assumes that when the data pending command is received,
+                * the trace has been started before or else no output data is written
+                * by the streams which is a condition for data pending. So, this is
+                * *VERY* important that we don't ask the consumer before a start
+                * trace.
+                */
+               if (!session->started) {
+                       ret = 0;
+                       goto error;
+               }
        }
 
        if (ksess && ksess->consumer) {
This page took 0.024702 seconds and 4 git commands to generate.