#include <babeltrace/graph/notification-heap.h>
#include <babeltrace/graph/notification-iterator.h>
#include <babeltrace/graph/notification-inactivity.h>
+#include <babeltrace/graph/graph.h>
#include <babeltrace/compiler-internal.h>
#include <inttypes.h>
#include <glib.h>
#include <plugins-common.h>
#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-LIVE"
+#define BT_LOGLEVEL_NAME "BABELTRACE_PLUGIN_CTF_LTTNG_LIVE_LOG_LEVEL"
#include "data-stream.h"
#include "metadata.h"
void lttng_live_destroy_trace(struct bt_object *obj)
{
struct lttng_live_trace *trace = container_of(obj, struct lttng_live_trace, obj);
+ int retval;
BT_LOGI("Destroy trace");
assert(bt_list_empty(&trace->streams));
bt_list_del(&trace->node);
+
+ retval = bt_ctf_trace_set_is_static(trace->trace);
+ assert(!retval);
+
lttng_live_metadata_fini(trace);
BT_PUT(trace->cc_prio_map);
g_free(trace);
BT_LOGI("Destroy session");
if (session->id != -1ULL) {
if (lttng_live_detach_session(session)) {
- /* Old relayd cannot detach sessions. */
- BT_LOGD("Unable to detach session %" PRIu64,
- session->id);
+ if (!bt_graph_is_canceled(session->lttng_live->graph)) {
+ /* Old relayd cannot detach sessions. */
+ BT_LOGD("Unable to detach session %" PRIu64,
+ session->id);
+ }
}
session->id = -1ULL;
}
struct lttng_live_trace *trace, *t;
if (lttng_live_attach_session(session)) {
- return BT_CTF_LTTNG_LIVE_ITERATOR_STATUS_ERROR;
+ if (bt_graph_is_canceled(lttng_live->graph)) {
+ return BT_CTF_LTTNG_LIVE_ITERATOR_STATUS_AGAIN;
+ } else {
+ return BT_CTF_LTTNG_LIVE_ITERATOR_STATUS_ERROR;
+ }
}
status = lttng_live_get_new_streams(session);
if (status != BT_CTF_LTTNG_LIVE_ITERATOR_STATUS_OK &&
}
bt_list_for_each_entry_safe(trace, t, &session->traces, node) {
status = lttng_live_metadata_update(trace);
- if (status == BT_CTF_LTTNG_LIVE_ITERATOR_STATUS_END) {
- int retval;
-
- retval = bt_ctf_trace_set_is_static(trace->trace);
- assert(!retval);
- } else if (status != BT_CTF_LTTNG_LIVE_ITERATOR_STATUS_OK) {
+ if (status != BT_CTF_LTTNG_LIVE_ITERATOR_STATUS_OK &&
+ status != BT_CTF_LTTNG_LIVE_ITERATOR_STATUS_END) {
return status;
}
}
goto error;
}
- viewer_connection = bt_live_viewer_connection_create(url, stderr);
+ viewer_connection = bt_live_viewer_connection_create(url, NULL);
if (!viewer_connection) {
ret = BT_COMPONENT_STATUS_NOMEM;
goto error;
struct bt_value *value = NULL;
const char *url;
enum bt_value_status ret;
+ struct bt_component *component;
lttng_live = g_new0(struct lttng_live_component, 1);
if (!lttng_live) {
goto error;
}
lttng_live->viewer_connection =
- bt_live_viewer_connection_create(lttng_live->url->str,
- stderr);
+ bt_live_viewer_connection_create(lttng_live->url->str, lttng_live);
if (!lttng_live->viewer_connection) {
- ret = BT_COMPONENT_STATUS_NOMEM;
+ if (bt_graph_is_canceled(lttng_live->graph)) {
+ ret = BT_COMPONENT_STATUS_AGAIN;
+ } else {
+ ret = BT_COMPONENT_STATUS_NOMEM;
+ }
goto error;
}
if (lttng_live_create_viewer_session(lttng_live)) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ if (bt_graph_is_canceled(lttng_live->graph)) {
+ ret = BT_COMPONENT_STATUS_AGAIN;
+ } else {
+ ret = BT_COMPONENT_STATUS_NOMEM;
+ }
goto error;
}
lttng_live->private_component = private_component;
+ component = bt_component_from_private_component(private_component);
+ lttng_live->graph = bt_component_get_graph(component);
+ bt_put(lttng_live->graph); /* weak */
+ bt_put(component);
+
goto end;
error:
void __attribute__((constructor)) bt_lttng_live_logging_ctor(void)
{
enum bt_logging_level log_level = BT_LOG_NONE;
- const char *log_level_env = getenv("BABELTRACE_PLUGIN_LTTNG_LIVE_LOG_LEVEL");
+ const char *log_level_env = getenv(BT_LOGLEVEL_NAME);
if (!log_level_env) {
return;
log_level = BT_LOGGING_LEVEL_FATAL;
} else {
bt_lttng_live_log_level = BT_LOGGING_LEVEL_FATAL;
- BT_LOGF("Incorrect log level specified in BABELTRACE_PLUGIN_LTTNG_LIVE_LOG_LEVEL");
+ BT_LOGF("Incorrect log level specified in %s",
+ BT_LOGLEVEL_NAME);
abort();
}