The objects owned by a graph should not be able to perform any useless
action. Having those constraints promise that certain contained objects
remain within certain states when the graph is canceled.
In this case, it is useless for a component to add a port, since this
port cannot be connected to another one within the same graph because
bt_graph_connect_ports() is not permitted when the graph is canceled.
We still allow ports to be removed when the graph is canceled for
symetric teardowns, for example.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
return "BT_COMPONENT_STATUS_NOMEM";
case BT_COMPONENT_STATUS_NOT_FOUND:
return "BT_COMPONENT_STATUS_NOT_FOUND";
return "BT_COMPONENT_STATUS_NOMEM";
case BT_COMPONENT_STATUS_NOT_FOUND:
return "BT_COMPONENT_STATUS_NOT_FOUND";
+ case BT_COMPONENT_STATUS_GRAPH_IS_CANCELED:
+ return "BT_COMPONENT_STATUS_GRAPH_IS_CANCELED";
default:
return "(unknown)";
}
default:
return "(unknown)";
}
BT_COMPONENT_STATUS_NOMEM = -12,
/** Element not found. */
BT_COMPONENT_STATUS_NOT_FOUND = -19,
BT_COMPONENT_STATUS_NOMEM = -12,
/** Element not found. */
BT_COMPONENT_STATUS_NOT_FOUND = -19,
+ BT_COMPONENT_STATUS_GRAPH_IS_CANCELED = 125,
#include <babeltrace/graph/component-class-internal.h>
#include <babeltrace/graph/notification.h>
#include <babeltrace/graph/notification-iterator-internal.h>
#include <babeltrace/graph/component-class-internal.h>
#include <babeltrace/graph/notification.h>
#include <babeltrace/graph/notification-iterator-internal.h>
+#include <babeltrace/graph/graph.h>
BT_HIDDEN
void bt_component_filter_destroy(struct bt_component *component)
BT_HIDDEN
void bt_component_filter_destroy(struct bt_component *component)
struct bt_port *port = NULL;
struct bt_component *component =
bt_component_from_private(private_component);
struct bt_port *port = NULL;
struct bt_component *component =
bt_component_from_private(private_component);
+ struct bt_graph *graph;
if (!component) {
BT_LOGW_STR("Invalid parameter: component is NULL.");
if (!component) {
BT_LOGW_STR("Invalid parameter: component is NULL.");
+ graph = bt_component_borrow_graph(component);
+
+ if (graph && bt_graph_is_canceled(graph)) {
+ BT_LOGW("Cannot add output port to filter component: graph is canceled: "
+ "comp-addr=%p, comp-name=\"%s\", graph-addr=%p",
+ component, bt_component_get_name(component),
+ bt_component_borrow_graph(component));
+ status = BT_COMPONENT_STATUS_GRAPH_IS_CANCELED;
+ goto end;
+ }
+
/* bt_component_add_input_port() logs details/errors */
port = bt_component_add_input_port(component, name, user_data);
if (!port) {
/* bt_component_add_input_port() logs details/errors */
port = bt_component_add_input_port(component, name, user_data);
if (!port) {
struct bt_port *port = NULL;
struct bt_component *component =
bt_component_from_private(private_component);
struct bt_port *port = NULL;
struct bt_component *component =
bt_component_from_private(private_component);
+ struct bt_graph *graph;
if (!component) {
BT_LOGW_STR("Invalid parameter: component is NULL.");
if (!component) {
BT_LOGW_STR("Invalid parameter: component is NULL.");
+ graph = bt_component_borrow_graph(component);
+
+ if (graph && bt_graph_is_canceled(graph)) {
+ BT_LOGW("Cannot add output port to filter component: graph is canceled: "
+ "comp-addr=%p, comp-name=\"%s\", graph-addr=%p",
+ component, bt_component_get_name(component),
+ bt_component_borrow_graph(component));
+ status = BT_COMPONENT_STATUS_GRAPH_IS_CANCELED;
+ goto end;
+ }
+
/* bt_component_add_output_port() logs details/errors */
port = bt_component_add_output_port(component, name, user_data);
if (!port) {
/* bt_component_add_output_port() logs details/errors */
port = bt_component_add_output_port(component, name, user_data);
if (!port) {
#include <babeltrace/graph/component-sink-internal.h>
#include <babeltrace/graph/component-internal.h>
#include <babeltrace/graph/notification.h>
#include <babeltrace/graph/component-sink-internal.h>
#include <babeltrace/graph/component-internal.h>
#include <babeltrace/graph/notification.h>
+#include <babeltrace/graph/graph.h>
BT_HIDDEN
void bt_component_sink_destroy(struct bt_component *component)
BT_HIDDEN
void bt_component_sink_destroy(struct bt_component *component)
struct bt_port *port = NULL;
struct bt_component *component =
bt_component_from_private(private_component);
struct bt_port *port = NULL;
struct bt_component *component =
bt_component_from_private(private_component);
+ struct bt_graph *graph;
if (!component) {
BT_LOGW_STR("Invalid parameter: component is NULL.");
if (!component) {
BT_LOGW_STR("Invalid parameter: component is NULL.");
+ graph = bt_component_borrow_graph(component);
+
+ if (graph && bt_graph_is_canceled(graph)) {
+ BT_LOGW("Cannot add output port to filter component: graph is canceled: "
+ "comp-addr=%p, comp-name=\"%s\", graph-addr=%p",
+ component, bt_component_get_name(component),
+ bt_component_borrow_graph(component));
+ status = BT_COMPONENT_STATUS_GRAPH_IS_CANCELED;
+ goto end;
+ }
+
/* bt_component_add_input_port() logs details/errors */
port = bt_component_add_input_port(component, name, user_data);
if (!port) {
/* bt_component_add_input_port() logs details/errors */
port = bt_component_add_input_port(component, name, user_data);
if (!port) {
#include <babeltrace/graph/port-internal.h>
#include <babeltrace/graph/notification-iterator.h>
#include <babeltrace/graph/notification-iterator-internal.h>
#include <babeltrace/graph/port-internal.h>
#include <babeltrace/graph/notification-iterator.h>
#include <babeltrace/graph/notification-iterator-internal.h>
+#include <babeltrace/graph/graph.h>
BT_HIDDEN
void bt_component_source_destroy(struct bt_component *component)
BT_HIDDEN
void bt_component_source_destroy(struct bt_component *component)
struct bt_port *port = NULL;
struct bt_component *component =
bt_component_from_private(private_component);
struct bt_port *port = NULL;
struct bt_component *component =
bt_component_from_private(private_component);
+ struct bt_graph *graph;
if (!component) {
BT_LOGW_STR("Invalid parameter: component is NULL.");
if (!component) {
BT_LOGW_STR("Invalid parameter: component is NULL.");
+ graph = bt_component_borrow_graph(component);
+
+ if (graph && bt_graph_is_canceled(graph)) {
+ BT_LOGW("Cannot add output port to filter component: graph is canceled: "
+ "comp-addr=%p, comp-name=\"%s\", graph-addr=%p",
+ component, bt_component_get_name(component),
+ bt_component_borrow_graph(component));
+ status = BT_COMPONENT_STATUS_GRAPH_IS_CANCELED;
+ goto end;
+ }
+
/* bt_component_add_output_port() logs details and errors */
port = bt_component_add_output_port(component, name, user_data);
if (!port) {
/* bt_component_add_output_port() logs details and errors */
port = bt_component_add_output_port(component, name, user_data);
if (!port) {