lib: do not allow port to be removed when message iterators are active
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 18 Dec 2018 22:16:33 +0000 (17:16 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 2 May 2019 04:09:19 +0000 (00:09 -0400)
commit44b2734f713bf5ff42c0f6ee819d4d3ec29a1bb9
treea341f59aae7747b4caf931f7590084fad4f1c781
parent7f57aa089db4db4e83a032047616644c8cec8664
lib: do not allow port to be removed when message iterators are active

This patch makes it illegal to remove a port when at least one message
iterator using it is not finalized (or in the process of being
finalized).

This introduces the following advantages:

* From a downstream point of view, your upstream message iterator cannot
  randomly get canceled, because a connection cannot end while any
  message iterator is active.

  Therefore the `BT_MESSAGE_ITERATOR_STATUS_CANCELED` status is removed.
  This status was ambiguous and there was no clear indication of what to
  do when you get it. Current plugins were handling it like
  `BT_MESSAGE_ITERATOR_STATUS_END`.

* There's a precondition that you when you call
  bt_self_component_port_input_message_iterator_next(), the iterator
  must be active. In practice this is always the case because the only
  way for it to be finalized if when you actively put its last
  reference, and you should know it.

  Therefore bt_self_component_port_input_message_iterator_next() does
  not need to check the "finalized" status every time you call it in
  case it needs to return the removed
  `BT_MESSAGE_ITERATOR_STATUS_CANCELED` status.

To distinguish between "finalized" and "in the process of being
finalized", the (internal)
`BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING` is
introduced: when a message iterator is finalized, its state is set to
`BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING`, then
its finalization method is called, then its state is set to
`BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED`. You can
remove a component's port when all its message iterators have one of
those states.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
include/babeltrace/graph/message-iterator-internal.h
include/babeltrace/graph/message-iterator.h
lib/graph/component-class-sink-colander.c
lib/graph/component.c
lib/graph/connection.c
lib/graph/graph.c
lib/graph/iterator.c
lib/graph/port.c
plugins/utils/muxer/muxer.c
This page took 0.024631 seconds and 5 git commands to generate.