Skip to content

Commit

Permalink
muxer: append causes on some _next iterator method code paths
Browse files Browse the repository at this point in the history
The goal of this patch (on top of the fact that having more error causes
is nice) is to ensure that if an error status is returned to
muxer_msg_iter_do_next, an error is set on the current thread.  This
will help for the next patch, which will save and restore the error in
this function.

Change-Id: I7221af107f330ab5ded10b69f24121be6ad1678c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2382
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
  • Loading branch information
simark authored and jgalar committed Nov 15, 2019
1 parent 7c4a2fb commit f331468
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions src/plugins/utils/muxer/muxer.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ bt_component_class_message_iterator_next_method_status muxer_upstream_msg_iter_n
struct muxer_upstream_msg_iter *muxer_upstream_msg_iter,
bool *is_ended)
{
struct muxer_comp *muxer_comp =
muxer_upstream_msg_iter->muxer_comp;
struct muxer_comp *muxer_comp = muxer_upstream_msg_iter->muxer_comp;
bt_component_class_message_iterator_next_method_status status;
bt_message_iterator_next_status input_port_iter_status;
bt_message_array_const msgs;
Expand Down Expand Up @@ -438,10 +437,19 @@ bt_component_class_message_iterator_next_method_status muxer_upstream_msg_iter_n
*is_ended = true;
status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
break;
case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR:
case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR:
/* Error status code */
BT_COMP_LOGE_APPEND_CAUSE(muxer_comp->self_comp,
"Upstream iterator's next method returned an error: status=%s",
bt_common_func_status_string(input_port_iter_status));
status = (int) input_port_iter_status;
break;
default:
/* Error or unsupported status code */
BT_COMP_LOGE("Error or unsupported status code: "
"status-code=%d", input_port_iter_status);
/* Unsupported status code */
BT_COMP_LOGE_APPEND_CAUSE(muxer_comp->self_comp,
"Unsupported status code: status=%s",
bt_common_func_status_string(input_port_iter_status));
status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR;
break;
}
Expand Down Expand Up @@ -917,10 +925,8 @@ validate_muxer_upstream_msg_iter(
struct muxer_upstream_msg_iter *muxer_upstream_msg_iter,
bool *is_ended)
{
struct muxer_comp *muxer_comp =
muxer_upstream_msg_iter->muxer_comp;
bt_component_class_message_iterator_next_method_status status =
BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
struct muxer_comp *muxer_comp = muxer_upstream_msg_iter->muxer_comp;
bt_component_class_message_iterator_next_method_status status;

BT_COMP_LOGD("Validating muxer's upstream message iterator wrapper: "
"muxer-upstream-msg-iter-wrap-addr=%p",
Expand All @@ -932,6 +938,7 @@ validate_muxer_upstream_msg_iter(
"queue-len=%u, upstream-msg-iter-addr=%p",
muxer_upstream_msg_iter->msgs->length,
muxer_upstream_msg_iter->msg_iter);
status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
goto end;
}

Expand All @@ -949,8 +956,7 @@ validate_muxer_upstream_msg_iters(
struct muxer_msg_iter *muxer_msg_iter)
{
struct muxer_comp *muxer_comp = muxer_msg_iter->muxer_comp;
bt_component_class_message_iterator_next_method_status status =
BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
bt_component_class_message_iterator_next_method_status status;
size_t i;

BT_COMP_LOGD("Validating muxer's upstream message iterator wrappers: "
Expand All @@ -968,7 +974,8 @@ validate_muxer_upstream_msg_iters(
muxer_upstream_msg_iter, &is_ended);
if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) {
if (status < 0) {
BT_COMP_LOGE("Cannot validate muxer's upstream message iterator wrapper: "
BT_COMP_LOGE_APPEND_CAUSE(muxer_comp->self_comp,
"Cannot validate muxer's upstream message iterator wrapper: "
"muxer-msg-iter-addr=%p, "
"muxer-upstream-msg-iter-wrap-addr=%p",
muxer_msg_iter,
Expand Down Expand Up @@ -1009,6 +1016,8 @@ validate_muxer_upstream_msg_iters(
}
}

status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;

end:
return status;
}
Expand Down Expand Up @@ -1040,7 +1049,8 @@ bt_component_class_message_iterator_next_method_status muxer_msg_iter_do_next_on
&next_return_ts);
if (status < 0 || status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END) {
if (status < 0) {
BT_COMP_LOGE("Cannot find the youngest upstream message iterator wrapper: "
BT_COMP_LOGE_APPEND_CAUSE(muxer_comp->self_comp,
"Cannot find the youngest upstream message iterator wrapper: "
"status=%s",
bt_common_func_status_string(status));
} else {
Expand All @@ -1053,7 +1063,8 @@ bt_component_class_message_iterator_next_method_status muxer_msg_iter_do_next_on
}

if (next_return_ts < muxer_msg_iter->last_returned_ts_ns) {
BT_COMP_LOGE("Youngest upstream message iterator wrapper's timestamp is less than muxer's message iterator's last returned timestamp: "
BT_COMP_LOGE_APPEND_CAUSE(muxer_comp->self_comp,
"Youngest upstream message iterator wrapper's timestamp is less than muxer's message iterator's last returned timestamp: "
"muxer-msg-iter-addr=%p, ts=%" PRId64 ", "
"last-returned-ts=%" PRId64,
muxer_msg_iter, next_return_ts,
Expand Down

0 comments on commit f331468

Please sign in to comment.