#include "common/assert.h"
#include "cpp-common/bt2c/fmt.hpp"
+#include "cpp-common/bt2c/glib-up.hpp"
#include "cpp-common/vendor/fmt/format.h"
#include "plugins/common/muxing/muxing.h"
BT_ASSERT(trace->stream_iterators);
g_ptr_array_free(trace->stream_iterators, TRUE);
- BT_TRACE_PUT_REF_AND_RESET(trace->trace);
-
lttng_live_metadata_fini(trace);
delete trace;
}
lttng_live_trace *trace = new lttng_live_trace {session->logger};
trace->session = session;
trace->id = trace_id;
- trace->trace = NULL;
trace->stream_iterators =
g_ptr_array_new_with_free_func((GDestroyNotify) lttng_live_stream_iterator_destroy);
BT_ASSERT(trace->stream_iterators);
}
viewer_status = live_viewer_connection_create(
- lttng_live->params.url->str, false, lttng_live_msg_iter, lttng_live_msg_iter->logger,
+ lttng_live->params.url.c_str(), false, lttng_live_msg_iter, lttng_live_msg_iter->logger,
<tng_live_msg_iter->viewer_connection);
if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) {
if (viewer_status == LTTNG_LIVE_VIEWER_STATUS_ERROR) {
"Unable to connect to the requested live viewer session. "
"Keep trying to connect because of {}=\"{}\" component parameter: url=\"{}\"",
SESS_NOT_FOUND_ACTION_PARAM, SESS_NOT_FOUND_ACTION_CONTINUE_STR,
- lttng_live->params.url->str);
+ lttng_live->params.url);
break;
case SESSION_NOT_FOUND_ACTION_FAIL:
BT_CPPLOGE_APPEND_CAUSE_SPEC(
"Fail the message iterator initialization because of {}=\"{}\" "
"component parameter: url =\"{}\"",
SESS_NOT_FOUND_ACTION_PARAM, SESS_NOT_FOUND_ACTION_FAIL_STR,
- lttng_live->params.url->str);
+ lttng_live->params.url);
status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
goto error;
case SESSION_NOT_FOUND_ACTION_END:
"End gracefully at the first _next() call because of {}=\"{}\""
" component parameter: url=\"{}\"",
SESS_NOT_FOUND_ACTION_PARAM, SESS_NOT_FOUND_ACTION_END_STR,
- lttng_live->params.url->str);
+ lttng_live->params.url);
break;
default:
bt_common_abort();
}
}
-static void lttng_live_component_destroy_data(struct lttng_live_component *lttng_live)
-{
- if (!lttng_live) {
- return;
- }
-
- if (lttng_live->params.url) {
- g_string_free(lttng_live->params.url, TRUE);
- }
-
- delete lttng_live;
-}
-
void lttng_live_component_finalize(bt_self_component_source *component)
{
lttng_live_component *data = (lttng_live_component *) bt_self_component_get_data(
bt_self_component_source_as_self_component(component));
- if (!data) {
- return;
- }
- lttng_live_component_destroy_data(data);
+ delete data;
}
static enum session_not_found_action
const bt_value *inputs_value;
const bt_value *url_value;
const bt_value *value;
- const char *url;
enum bt_param_validation_status validation_status;
gchar *validation_error = NULL;
bt_component_class_initialize_method_status status;
status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
goto error;
} else if (validation_status == BT_PARAM_VALIDATION_STATUS_VALIDATION_ERROR) {
+ bt2c::GCharUP errorFreer {validation_error};
BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "{}", validation_error);
status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
goto error;
inputs_value = bt_value_map_borrow_entry_value_const(params, INPUTS_PARAM);
url_value = bt_value_array_borrow_element_by_index_const(inputs_value, 0);
- url = bt_value_string_get(url_value);
-
- lttng_live->params.url = g_string_new(url);
- if (!lttng_live->params.url) {
- status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
- goto error;
- }
+ lttng_live->params.url = bt_value_string_get(url_value);
value = bt_value_map_borrow_entry_value_const(params, SESS_NOT_FOUND_ACTION_PARAM);
if (value) {
goto end;
error:
- lttng_live_component_destroy_data(lttng_live);
+ delete lttng_live;
lttng_live = NULL;
end:
- g_free(validation_error);
-
*component = lttng_live;
return status;
}
goto end;
error:
- lttng_live_component_destroy_data(lttng_live);
+ delete lttng_live;
lttng_live = NULL;
end:
return ret;