Fix: flt.utils.muxer: Potential memory leak
[babeltrace.git] / plugins / utils / muxer / muxer.c
CommitLineData
958f7d11
PP
1/*
2 * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
fed72692
PP
23#define BT_LOG_TAG "PLUGIN-UTILS-MUXER-FLT"
24#include "logging.h"
25
958f7d11 26#include <babeltrace/babeltrace-internal.h>
282c8cd0 27#include <babeltrace/compat/uuid-internal.h>
9d408fca 28#include <babeltrace/babeltrace.h>
c6bd8523 29#include <babeltrace/value-internal.h>
fed72692 30#include <babeltrace/graph/component-internal.h>
d6e69534 31#include <babeltrace/graph/message-iterator-internal.h>
fed72692 32#include <babeltrace/graph/connection-internal.h>
958f7d11
PP
33#include <plugins-common.h>
34#include <glib.h>
c55a9f58 35#include <stdbool.h>
fed72692 36#include <inttypes.h>
f6ccaed9 37#include <babeltrace/assert-internal.h>
da91b29a 38#include <babeltrace/common-internal.h>
0fbb9a9f 39#include <stdlib.h>
282c8cd0 40#include <string.h>
958f7d11 41
fdf0b89e
FD
42#include "muxer.h"
43
c3acd5f3 44#define ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME "assume-absolute-clock-classes"
65ee897d 45
958f7d11 46struct muxer_comp {
958f7d11 47 /* Weak ref */
b19ff26f 48 bt_self_component_filter *self_comp;
d94d92ac 49
958f7d11
PP
50 unsigned int next_port_num;
51 size_t available_input_ports;
d6e69534 52 bool initializing_muxer_msg_iter;
282c8cd0 53 bool assume_absolute_clock_classes;
958f7d11
PP
54};
55
d6e69534 56struct muxer_upstream_msg_iter {
ab11110e 57 /* Owned by this, NULL if ended */
d6e69534 58 bt_self_component_port_input_message_iterator *msg_iter;
958f7d11 59
d6e69534
PP
60 /* Contains `const bt_message *`, owned by this */
61 GQueue *msgs;
958f7d11
PP
62};
63
d6e69534
PP
64enum muxer_msg_iter_clock_class_expectation {
65 MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ANY = 0,
60f3d027 66 MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NONE,
d6e69534
PP
67 MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ABSOLUTE,
68 MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID,
69 MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_NO_UUID,
282c8cd0
PP
70};
71
d6e69534 72struct muxer_msg_iter {
ab11110e 73 /*
d6e69534 74 * Array of struct muxer_upstream_msg_iter * (owned by this).
ab11110e
PP
75 *
76 * NOTE: This array is searched in linearly to find the youngest
d6e69534 77 * current message. Keep this until benchmarks confirm that
ab11110e
PP
78 * another data structure is faster than this for our typical
79 * use cases.
80 */
54bdc1f7
PP
81 GPtrArray *active_muxer_upstream_msg_iters;
82
83 /*
84 * Array of struct muxer_upstream_msg_iter * (owned by this).
85 *
86 * We move ended message iterators from
87 * `active_muxer_upstream_msg_iters` to this array so as to be
88 * able to restore them when seeking.
89 */
90 GPtrArray *ended_muxer_upstream_msg_iters;
958f7d11 91
d6e69534 92 /* Last time returned in a message */
958f7d11 93 int64_t last_returned_ts_ns;
282c8cd0
PP
94
95 /* Clock class expectation state */
d6e69534 96 enum muxer_msg_iter_clock_class_expectation clock_class_expectation;
282c8cd0
PP
97
98 /*
99 * Expected clock class UUID, only valid when
100 * clock_class_expectation is
d6e69534 101 * MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID.
282c8cd0
PP
102 */
103 unsigned char expected_clock_class_uuid[BABELTRACE_UUID_LEN];
958f7d11
PP
104};
105
54bdc1f7
PP
106static
107void empty_message_queue(struct muxer_upstream_msg_iter *upstream_msg_iter)
108{
109 const bt_message *msg;
110
111 while ((msg = g_queue_pop_head(upstream_msg_iter->msgs))) {
112 bt_message_put_ref(msg);
113 }
114}
115
ab11110e 116static
d6e69534
PP
117void destroy_muxer_upstream_msg_iter(
118 struct muxer_upstream_msg_iter *muxer_upstream_msg_iter)
ab11110e 119{
d6e69534 120 if (!muxer_upstream_msg_iter) {
ab11110e
PP
121 return;
122 }
123
d6e69534
PP
124 BT_LOGD("Destroying muxer's upstream message iterator wrapper: "
125 "addr=%p, msg-iter-addr=%p, queue-len=%u",
126 muxer_upstream_msg_iter,
127 muxer_upstream_msg_iter->msg_iter,
128 muxer_upstream_msg_iter->msgs->length);
54bdc1f7
PP
129 bt_self_component_port_input_message_iterator_put_ref(
130 muxer_upstream_msg_iter->msg_iter);
d4393e08 131
d6e69534 132 if (muxer_upstream_msg_iter->msgs) {
54bdc1f7 133 empty_message_queue(muxer_upstream_msg_iter);
d6e69534 134 g_queue_free(muxer_upstream_msg_iter->msgs);
d4393e08
PP
135 }
136
d6e69534 137 g_free(muxer_upstream_msg_iter);
ab11110e
PP
138}
139
958f7d11 140static
d6e69534
PP
141struct muxer_upstream_msg_iter *muxer_msg_iter_add_upstream_msg_iter(
142 struct muxer_msg_iter *muxer_msg_iter,
143 bt_self_component_port_input_message_iterator *self_msg_iter)
958f7d11 144{
d6e69534
PP
145 struct muxer_upstream_msg_iter *muxer_upstream_msg_iter =
146 g_new0(struct muxer_upstream_msg_iter, 1);
958f7d11 147
d6e69534
PP
148 if (!muxer_upstream_msg_iter) {
149 BT_LOGE_STR("Failed to allocate one muxer's upstream message iterator wrapper.");
6c20f4a0 150 goto error;
958f7d11
PP
151 }
152
d6e69534
PP
153 muxer_upstream_msg_iter->msg_iter = self_msg_iter;
154 bt_self_component_port_input_message_iterator_get_ref(muxer_upstream_msg_iter->msg_iter);
155 muxer_upstream_msg_iter->msgs = g_queue_new();
156 if (!muxer_upstream_msg_iter->msgs) {
d4393e08 157 BT_LOGE_STR("Failed to allocate a GQueue.");
6c20f4a0 158 goto error;
d4393e08
PP
159 }
160
54bdc1f7 161 g_ptr_array_add(muxer_msg_iter->active_muxer_upstream_msg_iters,
d6e69534
PP
162 muxer_upstream_msg_iter);
163 BT_LOGD("Added muxer's upstream message iterator wrapper: "
164 "addr=%p, muxer-msg-iter-addr=%p, msg-iter-addr=%p",
165 muxer_upstream_msg_iter, muxer_msg_iter,
166 self_msg_iter);
958f7d11 167
6c20f4a0
FD
168 goto end;
169
170error:
171 g_free(muxer_upstream_msg_iter);
172 muxer_upstream_msg_iter = NULL;
173
958f7d11 174end:
d6e69534 175 return muxer_upstream_msg_iter;
958f7d11
PP
176}
177
958f7d11 178static
5badd463 179bt_self_component_status add_available_input_port(
b19ff26f 180 bt_self_component_filter *self_comp)
958f7d11 181{
d94d92ac 182 struct muxer_comp *muxer_comp = bt_self_component_get_data(
707b7d35 183 bt_self_component_filter_as_self_component(self_comp));
4cdfc5e8 184 bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
958f7d11 185 GString *port_name = NULL;
958f7d11 186
f6ccaed9 187 BT_ASSERT(muxer_comp);
958f7d11
PP
188 port_name = g_string_new("in");
189 if (!port_name) {
fed72692 190 BT_LOGE_STR("Failed to allocate a GString.");
d94d92ac 191 status = BT_SELF_COMPONENT_STATUS_NOMEM;
958f7d11
PP
192 goto end;
193 }
194
195 g_string_append_printf(port_name, "%u", muxer_comp->next_port_num);
d94d92ac
PP
196 status = bt_self_component_filter_add_input_port(
197 self_comp, port_name->str, NULL, NULL);
198 if (status != BT_SELF_COMPONENT_STATUS_OK) {
fed72692
PP
199 BT_LOGE("Cannot add input port to muxer component: "
200 "port-name=\"%s\", comp-addr=%p, status=%s",
d94d92ac
PP
201 port_name->str, self_comp,
202 bt_self_component_status_string(status));
958f7d11
PP
203 goto end;
204 }
205
206 muxer_comp->available_input_ports++;
207 muxer_comp->next_port_num++;
fed72692
PP
208 BT_LOGD("Added one input port to muxer component: "
209 "port-name=\"%s\", comp-addr=%p",
d94d92ac 210 port_name->str, self_comp);
5badd463 211
958f7d11
PP
212end:
213 if (port_name) {
214 g_string_free(port_name, TRUE);
215 }
216
147337a3 217 return status;
958f7d11
PP
218}
219
958f7d11 220static
4cdfc5e8 221bt_self_component_status create_output_port(
b19ff26f 222 bt_self_component_filter *self_comp)
958f7d11 223{
d94d92ac
PP
224 return bt_self_component_filter_add_output_port(
225 self_comp, "out", NULL, NULL);
958f7d11
PP
226}
227
228static
229void destroy_muxer_comp(struct muxer_comp *muxer_comp)
230{
231 if (!muxer_comp) {
232 return;
233 }
234
958f7d11
PP
235 g_free(muxer_comp);
236}
237
65ee897d 238static
b19ff26f 239bt_value *get_default_params(void)
65ee897d 240{
b19ff26f 241 bt_value *params;
65ee897d
PP
242 int ret;
243
05e21286 244 params = bt_value_map_create();
65ee897d 245 if (!params) {
fed72692 246 BT_LOGE_STR("Cannot create a map value object.");
65ee897d
PP
247 goto error;
248 }
249
05e21286 250 ret = bt_value_map_insert_bool_entry(params,
c3acd5f3 251 ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME, false);
65ee897d 252 if (ret) {
fed72692 253 BT_LOGE_STR("Cannot add boolean value to map value object.");
65ee897d
PP
254 goto error;
255 }
256
257 goto end;
258
259error:
c5b9b441 260 BT_VALUE_PUT_REF_AND_RESET(params);
65ee897d
PP
261
262end:
263 return params;
264}
265
266static
05e21286 267int configure_muxer_comp(struct muxer_comp *muxer_comp,
b19ff26f 268 const bt_value *params)
65ee897d 269{
b19ff26f
PP
270 bt_value *default_params = NULL;
271 bt_value *real_params = NULL;
272 const bt_value *assume_absolute_clock_classes = NULL;
65ee897d 273 int ret = 0;
c55a9f58 274 bt_bool bool_val;
65ee897d
PP
275
276 default_params = get_default_params();
277 if (!default_params) {
fed72692
PP
278 BT_LOGE("Cannot get default parameters: "
279 "muxer-comp-addr=%p", muxer_comp);
65ee897d
PP
280 goto error;
281 }
282
35294e83 283 ret = bt_value_map_extend(default_params, params, &real_params);
601b0d3c 284 if (ret) {
fed72692
PP
285 BT_LOGE("Cannot extend default parameters map value: "
286 "muxer-comp-addr=%p, def-params-addr=%p, "
287 "params-addr=%p", muxer_comp, default_params,
288 params);
65ee897d
PP
289 goto error;
290 }
291
05e21286
PP
292 assume_absolute_clock_classes = bt_value_map_borrow_entry_value(real_params,
293 ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME);
f6ccaed9
PP
294 if (assume_absolute_clock_classes &&
295 !bt_value_is_bool(assume_absolute_clock_classes)) {
fed72692
PP
296 BT_LOGE("Expecting a boolean value for the `%s` parameter: "
297 "muxer-comp-addr=%p, value-type=%s",
298 ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME, muxer_comp,
da91b29a 299 bt_common_value_type_string(
fed72692 300 bt_value_get_type(assume_absolute_clock_classes)));
65ee897d
PP
301 goto error;
302 }
303
601b0d3c 304 bool_val = bt_value_bool_get(assume_absolute_clock_classes);
282c8cd0 305 muxer_comp->assume_absolute_clock_classes = (bool) bool_val;
fed72692
PP
306 BT_LOGD("Configured muxer component: muxer-comp-addr=%p, "
307 "assume-absolute-clock-classes=%d",
308 muxer_comp, muxer_comp->assume_absolute_clock_classes);
65ee897d
PP
309 goto end;
310
311error:
312 ret = -1;
313
314end:
c5b9b441
PP
315 bt_value_put_ref(default_params);
316 bt_value_put_ref(real_params);
65ee897d
PP
317 return ret;
318}
319
958f7d11 320BT_HIDDEN
4cdfc5e8 321bt_self_component_status muxer_init(
b19ff26f 322 bt_self_component_filter *self_comp,
fdf0b89e 323 const bt_value *params, void *init_data)
958f7d11
PP
324{
325 int ret;
4cdfc5e8 326 bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
958f7d11
PP
327 struct muxer_comp *muxer_comp = g_new0(struct muxer_comp, 1);
328
fed72692 329 BT_LOGD("Initializing muxer component: "
d94d92ac 330 "comp-addr=%p, params-addr=%p", self_comp, params);
fed72692 331
958f7d11 332 if (!muxer_comp) {
fed72692 333 BT_LOGE_STR("Failed to allocate one muxer component.");
958f7d11
PP
334 goto error;
335 }
336
65ee897d
PP
337 ret = configure_muxer_comp(muxer_comp, params);
338 if (ret) {
fed72692
PP
339 BT_LOGE("Cannot configure muxer component: "
340 "muxer-comp-addr=%p, params-addr=%p",
341 muxer_comp, params);
65ee897d
PP
342 goto error;
343 }
344
d94d92ac
PP
345 muxer_comp->self_comp = self_comp;
346 bt_self_component_set_data(
707b7d35 347 bt_self_component_filter_as_self_component(self_comp),
d94d92ac 348 muxer_comp);
5badd463 349 status = add_available_input_port(self_comp);
d94d92ac 350 if (status != BT_SELF_COMPONENT_STATUS_OK) {
fed72692
PP
351 BT_LOGE("Cannot ensure that at least one muxer component's input port is available: "
352 "muxer-comp-addr=%p, status=%s",
353 muxer_comp,
d94d92ac 354 bt_self_component_status_string(status));
958f7d11
PP
355 goto error;
356 }
357
d94d92ac 358 status = create_output_port(self_comp);
fed72692
PP
359 if (status) {
360 BT_LOGE("Cannot create muxer component's output port: "
361 "muxer-comp-addr=%p, status=%s",
362 muxer_comp,
d94d92ac 363 bt_self_component_status_string(status));
958f7d11
PP
364 goto error;
365 }
366
fed72692
PP
367 BT_LOGD("Initialized muxer component: "
368 "comp-addr=%p, params-addr=%p, muxer-comp-addr=%p",
d94d92ac 369 self_comp, params, muxer_comp);
fed72692 370
958f7d11
PP
371 goto end;
372
373error:
374 destroy_muxer_comp(muxer_comp);
d94d92ac 375 bt_self_component_set_data(
707b7d35 376 bt_self_component_filter_as_self_component(self_comp),
d94d92ac 377 NULL);
147337a3 378
d94d92ac
PP
379 if (status == BT_SELF_COMPONENT_STATUS_OK) {
380 status = BT_SELF_COMPONENT_STATUS_ERROR;
147337a3 381 }
958f7d11
PP
382
383end:
384 return status;
385}
386
387BT_HIDDEN
b19ff26f 388void muxer_finalize(bt_self_component_filter *self_comp)
958f7d11 389{
d94d92ac 390 struct muxer_comp *muxer_comp = bt_self_component_get_data(
707b7d35 391 bt_self_component_filter_as_self_component(self_comp));
958f7d11 392
fed72692 393 BT_LOGD("Finalizing muxer component: comp-addr=%p",
d94d92ac 394 self_comp);
958f7d11
PP
395 destroy_muxer_comp(muxer_comp);
396}
397
398static
d6e69534 399bt_self_component_port_input_message_iterator *
5badd463 400create_msg_iter_on_input_port(bt_self_component_port_input *self_port)
958f7d11 401{
b19ff26f 402 const bt_port *port = bt_self_component_port_as_port(
707b7d35 403 bt_self_component_port_input_as_self_component_port(
d94d92ac 404 self_port));
d6e69534 405 bt_self_component_port_input_message_iterator *msg_iter =
d94d92ac 406 NULL;
958f7d11 407
f6ccaed9
PP
408 BT_ASSERT(port);
409 BT_ASSERT(bt_port_is_connected(port));
958f7d11 410
ab11110e 411 // TODO: Advance the iterator to >= the time of the latest
d6e69534 412 // returned message by the muxer message
ab11110e 413 // iterator which creates it.
d6e69534 414 msg_iter = bt_self_component_port_input_message_iterator_create(
d94d92ac 415 self_port);
d6e69534
PP
416 if (!msg_iter) {
417 BT_LOGE("Cannot create upstream message iterator on input port: "
d94d92ac
PP
418 "port-addr=%p, port-name=\"%s\"",
419 port, bt_port_get_name(port));
958f7d11
PP
420 goto end;
421 }
422
d6e69534
PP
423 BT_LOGD("Created upstream message iterator on input port: "
424 "port-addr=%p, port-name=\"%s\", msg-iter-addr=%p",
425 port, bt_port_get_name(port), msg_iter);
fed72692 426
958f7d11 427end:
d6e69534 428 return msg_iter;
958f7d11
PP
429}
430
ab11110e 431static
fdf0b89e 432bt_self_message_iterator_status muxer_upstream_msg_iter_next(
54bdc1f7
PP
433 struct muxer_upstream_msg_iter *muxer_upstream_msg_iter,
434 bool *is_ended)
ab11110e 435{
fdf0b89e
FD
436 bt_self_message_iterator_status status;
437 bt_message_iterator_status input_port_iter_status;
d6e69534 438 bt_message_array_const msgs;
d4393e08
PP
439 uint64_t i;
440 uint64_t count;
ab11110e 441
d6e69534
PP
442 BT_LOGV("Calling upstream message iterator's \"next\" method: "
443 "muxer-upstream-msg-iter-wrap-addr=%p, msg-iter-addr=%p",
444 muxer_upstream_msg_iter,
445 muxer_upstream_msg_iter->msg_iter);
fdf0b89e 446 input_port_iter_status = bt_self_component_port_input_message_iterator_next(
d6e69534
PP
447 muxer_upstream_msg_iter->msg_iter, &msgs, &count);
448 BT_LOGV("Upstream message iterator's \"next\" method returned: "
fdf0b89e 449 "status=%s", bt_message_iterator_status_string(input_port_iter_status));
ab11110e 450
fdf0b89e 451 switch (input_port_iter_status) {
d6e69534 452 case BT_MESSAGE_ITERATOR_STATUS_OK:
089717de 453 /*
d6e69534 454 * Message iterator's current message is
d4393e08 455 * valid: it must be considered for muxing operations.
089717de 456 */
d6e69534 457 BT_LOGV_STR("Validated upstream message iterator wrapper.");
d4393e08
PP
458 BT_ASSERT(count > 0);
459
d6e69534 460 /* Move messages to our queue */
d4393e08
PP
461 for (i = 0; i < count; i++) {
462 /*
463 * Push to tail in order; other side
d6e69534 464 * (muxer_msg_iter_do_next_one()) consumes
d4393e08
PP
465 * from the head first.
466 */
d6e69534
PP
467 g_queue_push_tail(muxer_upstream_msg_iter->msgs,
468 (void *) msgs[i]);
d4393e08 469 }
fdf0b89e 470 status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
ab11110e 471 break;
d6e69534 472 case BT_MESSAGE_ITERATOR_STATUS_AGAIN:
089717de 473 /*
d6e69534 474 * Message iterator's current message is not
089717de 475 * valid anymore. Return
d6e69534 476 * BT_MESSAGE_ITERATOR_STATUS_AGAIN immediately.
089717de 477 */
fdf0b89e 478 status = BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN;
ab11110e 479 break;
d6e69534 480 case BT_MESSAGE_ITERATOR_STATUS_END: /* Fall-through. */
ab11110e 481 /*
d6e69534 482 * Message iterator reached the end: release it. It
ab11110e 483 * won't be considered again to find the youngest
d6e69534 484 * message.
ab11110e 485 */
54bdc1f7 486 *is_ended = true;
fdf0b89e 487 status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
089717de 488 break;
ab11110e
PP
489 default:
490 /* Error or unsupported status code */
fed72692 491 BT_LOGE("Error or unsupported status code: "
fdf0b89e
FD
492 "status-code=%d", input_port_iter_status);
493 status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
089717de 494 break;
ab11110e
PP
495 }
496
089717de 497 return status;
ab11110e
PP
498}
499
958f7d11 500static
d6e69534
PP
501int get_msg_ts_ns(struct muxer_comp *muxer_comp,
502 struct muxer_msg_iter *muxer_msg_iter,
503 const bt_message *msg, int64_t last_returned_ts_ns,
958f7d11
PP
504 int64_t *ts_ns)
505{
605e1019 506 const bt_clock_snapshot *clock_snapshot = NULL;
958f7d11 507 int ret = 0;
4cdfc5e8 508 bt_clock_snapshot_state cs_state = BT_CLOCK_SNAPSHOT_STATE_KNOWN;
5366eb53 509 bt_message_stream_activity_clock_snapshot_state sa_cs_state;
958f7d11 510
d6e69534 511 BT_ASSERT(msg);
f6ccaed9 512 BT_ASSERT(ts_ns);
d6e69534
PP
513 BT_LOGV("Getting message's timestamp: "
514 "muxer-msg-iter-addr=%p, msg-addr=%p, "
fed72692 515 "last-returned-ts=%" PRId64,
d6e69534 516 muxer_msg_iter, msg, last_returned_ts_ns);
fed72692 517
60f3d027
PP
518 if (unlikely(muxer_msg_iter->clock_class_expectation ==
519 MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NONE)) {
520 *ts_ns = last_returned_ts_ns;
521 goto end;
522 }
523
d6e69534
PP
524 switch (bt_message_get_type(msg)) {
525 case BT_MESSAGE_TYPE_EVENT:
60f3d027
PP
526 BT_ASSERT(bt_message_event_borrow_stream_class_default_clock_class_const(
527 msg));
2c091c04
PP
528 cs_state = bt_message_event_borrow_default_clock_snapshot_const(
529 msg, &clock_snapshot);
958f7d11 530 break;
5366eb53 531 case BT_MESSAGE_TYPE_PACKET_BEGINNING:
60f3d027
PP
532 BT_ASSERT(bt_message_packet_beginning_borrow_stream_class_default_clock_class_const(
533 msg));
5366eb53
PP
534 cs_state = bt_message_packet_beginning_borrow_default_clock_snapshot_const(
535 msg, &clock_snapshot);
536 break;
537 case BT_MESSAGE_TYPE_PACKET_END:
60f3d027
PP
538 BT_ASSERT(bt_message_packet_end_borrow_stream_class_default_clock_class_const(
539 msg));
5366eb53
PP
540 cs_state = bt_message_packet_end_borrow_default_clock_snapshot_const(
541 msg, &clock_snapshot);
542 break;
543 case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
60f3d027
PP
544 BT_ASSERT(bt_message_discarded_events_borrow_stream_class_default_clock_class_const(
545 msg));
5366eb53
PP
546 cs_state = bt_message_discarded_events_borrow_default_beginning_clock_snapshot_const(
547 msg, &clock_snapshot);
548 break;
549 case BT_MESSAGE_TYPE_DISCARDED_PACKETS:
60f3d027
PP
550 BT_ASSERT(bt_message_discarded_packets_borrow_stream_class_default_clock_class_const(
551 msg));
5366eb53
PP
552 cs_state = bt_message_discarded_packets_borrow_default_beginning_clock_snapshot_const(
553 msg, &clock_snapshot);
554 break;
555 case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING:
60f3d027
PP
556 BT_ASSERT(bt_message_stream_activity_beginning_borrow_stream_class_default_clock_class_const(
557 msg));
5366eb53
PP
558 sa_cs_state = bt_message_stream_activity_beginning_borrow_default_clock_snapshot_const(
559 msg, &clock_snapshot);
560 if (sa_cs_state != BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN) {
4c0f1c8c 561 goto no_clock_snapshot;
5366eb53 562 }
958f7d11 563
5366eb53
PP
564 break;
565 case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END:
60f3d027
PP
566 BT_ASSERT(bt_message_stream_activity_end_borrow_stream_class_default_clock_class_const(
567 msg));
5366eb53
PP
568 sa_cs_state = bt_message_stream_activity_end_borrow_default_clock_snapshot_const(
569 msg, &clock_snapshot);
570 if (sa_cs_state != BT_MESSAGE_STREAM_ACTIVITY_CLOCK_SNAPSHOT_STATE_KNOWN) {
4c0f1c8c 571 goto no_clock_snapshot;
5366eb53
PP
572 }
573
574 break;
b9fd9cbb 575 case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY:
dc68f16d 576 cs_state =
b9fd9cbb 577 bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
dc68f16d 578 msg, &clock_snapshot);
958f7d11
PP
579 break;
580 default:
d6e69534
PP
581 /* All the other messages have a higher priority */
582 BT_LOGV_STR("Message has no timestamp: using the last returned timestamp.");
958f7d11
PP
583 *ts_ns = last_returned_ts_ns;
584 goto end;
585 }
586
60f3d027
PP
587 BT_ASSERT(cs_state == BT_CLOCK_SNAPSHOT_STATE_KNOWN);
588 ret = bt_clock_snapshot_get_ns_from_origin(clock_snapshot, ts_ns);
589 if (ret) {
590 BT_LOGE("Cannot get nanoseconds from Epoch of clock snapshot: "
591 "clock-snapshot-addr=%p", clock_snapshot);
592 goto error;
593 }
594
595 goto end;
596
597no_clock_snapshot:
598 BT_LOGV_STR("Message's default clock snapshot is missing: "
599 "using the last returned timestamp.");
600 *ts_ns = last_returned_ts_ns;
601 goto end;
602
603error:
604 ret = -1;
605
606end:
607 if (ret == 0) {
608 BT_LOGV("Found message's timestamp: "
609 "muxer-msg-iter-addr=%p, msg-addr=%p, "
610 "last-returned-ts=%" PRId64 ", ts=%" PRId64,
611 muxer_msg_iter, msg, last_returned_ts_ns,
612 *ts_ns);
44c440bc
PP
613 }
614
60f3d027
PP
615 return ret;
616}
617
618static inline
619int validate_clock_class(struct muxer_msg_iter *muxer_msg_iter,
620 struct muxer_comp *muxer_comp,
621 const bt_clock_class *clock_class)
622{
623 int ret = 0;
624 const unsigned char *cc_uuid;
625 const char *cc_name;
626
e22b45d0 627 BT_ASSERT(clock_class);
50842bdc
PP
628 cc_uuid = bt_clock_class_get_uuid(clock_class);
629 cc_name = bt_clock_class_get_name(clock_class);
282c8cd0 630
d6e69534
PP
631 if (muxer_msg_iter->clock_class_expectation ==
632 MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ANY) {
282c8cd0
PP
633 /*
634 * This is the first clock class that this muxer
d6e69534 635 * message iterator encounters. Its properties
282c8cd0
PP
636 * determine what to expect for the whole lifetime of
637 * the iterator without a true
638 * `assume-absolute-clock-classes` parameter.
639 */
5552377a 640 if (bt_clock_class_origin_is_unix_epoch(clock_class)) {
282c8cd0 641 /* Expect absolute clock classes */
d6e69534
PP
642 muxer_msg_iter->clock_class_expectation =
643 MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ABSOLUTE;
282c8cd0
PP
644 } else {
645 if (cc_uuid) {
646 /*
647 * Expect non-absolute clock classes
648 * with a specific UUID.
649 */
d6e69534
PP
650 muxer_msg_iter->clock_class_expectation =
651 MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID;
652 memcpy(muxer_msg_iter->expected_clock_class_uuid,
282c8cd0
PP
653 cc_uuid, BABELTRACE_UUID_LEN);
654 } else {
655 /*
656 * Expect non-absolute clock classes
657 * with no UUID.
658 */
d6e69534
PP
659 muxer_msg_iter->clock_class_expectation =
660 MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_NO_UUID;
282c8cd0
PP
661 }
662 }
663 }
664
665 if (!muxer_comp->assume_absolute_clock_classes) {
d6e69534
PP
666 switch (muxer_msg_iter->clock_class_expectation) {
667 case MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ABSOLUTE:
5552377a 668 if (!bt_clock_class_origin_is_unix_epoch(clock_class)) {
fed72692
PP
669 BT_LOGE("Expecting an absolute clock class, "
670 "but got a non-absolute one: "
671 "clock-class-addr=%p, clock-class-name=\"%s\"",
672 clock_class, cc_name);
282c8cd0
PP
673 goto error;
674 }
675 break;
d6e69534 676 case MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_NO_UUID:
5552377a 677 if (bt_clock_class_origin_is_unix_epoch(clock_class)) {
fed72692
PP
678 BT_LOGE("Expecting a non-absolute clock class with no UUID, "
679 "but got an absolute one: "
680 "clock-class-addr=%p, clock-class-name=\"%s\"",
681 clock_class, cc_name);
282c8cd0
PP
682 goto error;
683 }
684
685 if (cc_uuid) {
fed72692
PP
686 BT_LOGE("Expecting a non-absolute clock class with no UUID, "
687 "but got one with a UUID: "
688 "clock-class-addr=%p, clock-class-name=\"%s\", "
689 "uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
690 clock_class, cc_name,
691 (unsigned int) cc_uuid[0],
692 (unsigned int) cc_uuid[1],
693 (unsigned int) cc_uuid[2],
694 (unsigned int) cc_uuid[3],
695 (unsigned int) cc_uuid[4],
696 (unsigned int) cc_uuid[5],
697 (unsigned int) cc_uuid[6],
698 (unsigned int) cc_uuid[7],
699 (unsigned int) cc_uuid[8],
700 (unsigned int) cc_uuid[9],
701 (unsigned int) cc_uuid[10],
702 (unsigned int) cc_uuid[11],
703 (unsigned int) cc_uuid[12],
704 (unsigned int) cc_uuid[13],
705 (unsigned int) cc_uuid[14],
706 (unsigned int) cc_uuid[15]);
282c8cd0
PP
707 goto error;
708 }
709 break;
d6e69534 710 case MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NOT_ABS_SPEC_UUID:
5552377a 711 if (bt_clock_class_origin_is_unix_epoch(clock_class)) {
fed72692
PP
712 BT_LOGE("Expecting a non-absolute clock class with a specific UUID, "
713 "but got an absolute one: "
714 "clock-class-addr=%p, clock-class-name=\"%s\"",
715 clock_class, cc_name);
282c8cd0
PP
716 goto error;
717 }
718
719 if (!cc_uuid) {
fed72692
PP
720 BT_LOGE("Expecting a non-absolute clock class with a specific UUID, "
721 "but got one with no UUID: "
722 "clock-class-addr=%p, clock-class-name=\"%s\"",
723 clock_class, cc_name);
282c8cd0
PP
724 goto error;
725 }
726
d6e69534 727 if (memcmp(muxer_msg_iter->expected_clock_class_uuid,
282c8cd0 728 cc_uuid, BABELTRACE_UUID_LEN) != 0) {
fed72692
PP
729 BT_LOGE("Expecting a non-absolute clock class with a specific UUID, "
730 "but got one with different UUID: "
731 "clock-class-addr=%p, clock-class-name=\"%s\", "
732 "expected-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", "
733 "uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
734 clock_class, cc_name,
d6e69534
PP
735 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[0],
736 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[1],
737 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[2],
738 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[3],
739 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[4],
740 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[5],
741 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[6],
742 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[7],
743 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[8],
744 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[9],
745 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[10],
746 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[11],
747 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[12],
748 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[13],
749 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[14],
750 (unsigned int) muxer_msg_iter->expected_clock_class_uuid[15],
fed72692
PP
751 (unsigned int) cc_uuid[0],
752 (unsigned int) cc_uuid[1],
753 (unsigned int) cc_uuid[2],
754 (unsigned int) cc_uuid[3],
755 (unsigned int) cc_uuid[4],
756 (unsigned int) cc_uuid[5],
757 (unsigned int) cc_uuid[6],
758 (unsigned int) cc_uuid[7],
759 (unsigned int) cc_uuid[8],
760 (unsigned int) cc_uuid[9],
761 (unsigned int) cc_uuid[10],
762 (unsigned int) cc_uuid[11],
763 (unsigned int) cc_uuid[12],
764 (unsigned int) cc_uuid[13],
765 (unsigned int) cc_uuid[14],
766 (unsigned int) cc_uuid[15]);
282c8cd0
PP
767 goto error;
768 }
769 break;
60f3d027
PP
770 case MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NONE:
771 BT_LOGE("Expecting no clock class, but got one: "
772 "clock-class-addr=%p, clock-class-name=\"%s\"",
773 clock_class, cc_name);
774 goto error;
282c8cd0
PP
775 default:
776 /* Unexpected */
fed72692
PP
777 BT_LOGF("Unexpected clock class expectation: "
778 "expectation-code=%d",
d6e69534 779 muxer_msg_iter->clock_class_expectation);
282c8cd0
PP
780 abort();
781 }
958f7d11
PP
782 }
783
4c0f1c8c
PP
784 goto end;
785
958f7d11
PP
786error:
787 ret = -1;
788
789end:
60f3d027
PP
790 return ret;
791}
792
793static inline
794int validate_new_stream_clock_class(struct muxer_msg_iter *muxer_msg_iter,
795 struct muxer_comp *muxer_comp, const bt_stream *stream)
796{
797 int ret = 0;
798 const bt_stream_class *stream_class =
799 bt_stream_borrow_class_const(stream);
800 const bt_clock_class *clock_class =
801 bt_stream_class_borrow_default_clock_class_const(stream_class);
802
803 if (!clock_class) {
804 if (muxer_msg_iter->clock_class_expectation ==
805 MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ANY) {
806 /* Expect no clock class */
807 muxer_msg_iter->clock_class_expectation =
808 MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NONE;
809 } else {
810 BT_LOGE("Expecting stream class with a default clock class: "
811 "stream-class-addr=%p, stream-class-name=\"%s\", "
812 "stream-class-id=%" PRIu64,
813 stream_class, bt_stream_class_get_name(stream_class),
814 bt_stream_class_get_id(stream_class));
815 ret = -1;
816 }
817
818 goto end;
fed72692
PP
819 }
820
60f3d027
PP
821 if (!bt_stream_class_default_clock_is_always_known(stream_class)) {
822 BT_LOGE("Stream's default clock is not always known: "
823 "stream-class-addr=%p, stream-class-name=\"%s\", "
824 "stream-class-id=%" PRIu64,
825 stream_class, bt_stream_class_get_name(stream_class),
826 bt_stream_class_get_id(stream_class));
827 ret = -1;
828 goto end;
829 }
830
831 ret = validate_clock_class(muxer_msg_iter, muxer_comp, clock_class);
832
833end:
958f7d11
PP
834 return ret;
835}
836
ab11110e 837/*
d6e69534
PP
838 * This function finds the youngest available message amongst the
839 * non-ended upstream message iterators and returns the upstream
840 * message iterator which has it, or
841 * BT_MESSAGE_ITERATOR_STATUS_END if there's no available
842 * message.
ab11110e
PP
843 *
844 * This function does NOT:
845 *
d6e69534 846 * * Update any upstream message iterator.
d6e69534 847 * * Check the upstream message iterators to retry.
ab11110e 848 *
d6e69534
PP
849 * On sucess, this function sets *muxer_upstream_msg_iter to the
850 * upstream message iterator of which the current message is
ab11110e
PP
851 * the youngest, and sets *ts_ns to its time.
852 */
958f7d11 853static
fdf0b89e 854bt_self_message_iterator_status
d6e69534 855muxer_msg_iter_youngest_upstream_msg_iter(
958f7d11 856 struct muxer_comp *muxer_comp,
d6e69534
PP
857 struct muxer_msg_iter *muxer_msg_iter,
858 struct muxer_upstream_msg_iter **muxer_upstream_msg_iter,
958f7d11
PP
859 int64_t *ts_ns)
860{
861 size_t i;
862 int ret;
863 int64_t youngest_ts_ns = INT64_MAX;
fdf0b89e
FD
864 bt_self_message_iterator_status status =
865 BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
958f7d11 866
f6ccaed9 867 BT_ASSERT(muxer_comp);
d6e69534
PP
868 BT_ASSERT(muxer_msg_iter);
869 BT_ASSERT(muxer_upstream_msg_iter);
870 *muxer_upstream_msg_iter = NULL;
871
54bdc1f7
PP
872 for (i = 0; i < muxer_msg_iter->active_muxer_upstream_msg_iters->len;
873 i++) {
d6e69534
PP
874 const bt_message *msg;
875 struct muxer_upstream_msg_iter *cur_muxer_upstream_msg_iter =
54bdc1f7
PP
876 g_ptr_array_index(
877 muxer_msg_iter->active_muxer_upstream_msg_iters,
878 i);
d6e69534
PP
879 int64_t msg_ts_ns;
880
881 if (!cur_muxer_upstream_msg_iter->msg_iter) {
882 /* This upstream message iterator is ended */
883 BT_LOGV("Skipping ended upstream message iterator: "
884 "muxer-upstream-msg-iter-wrap-addr=%p",
885 cur_muxer_upstream_msg_iter);
958f7d11
PP
886 continue;
887 }
888
d6e69534
PP
889 BT_ASSERT(cur_muxer_upstream_msg_iter->msgs->length > 0);
890 msg = g_queue_peek_head(cur_muxer_upstream_msg_iter->msgs);
891 BT_ASSERT(msg);
60f3d027
PP
892
893 if (unlikely(bt_message_get_type(msg) ==
894 BT_MESSAGE_TYPE_STREAM_BEGINNING)) {
895 ret = validate_new_stream_clock_class(
896 muxer_msg_iter, muxer_comp,
897 bt_message_stream_beginning_borrow_stream_const(
898 msg));
899 if (ret) {
900 /*
901 * validate_new_stream_clock_class() logs
902 * errors.
903 */
904 status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
905 goto end;
906 }
907 } else if (unlikely(bt_message_get_type(msg) ==
908 BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY)) {
909 const bt_clock_snapshot *cs;
910 bt_clock_snapshot_state cs_state;
911
912 cs_state = bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
913 msg, &cs);
914
915 if (cs_state != BT_CLOCK_SNAPSHOT_STATE_KNOWN) {
916 BT_LOGE("Message iterator inactivity message's "
917 "default clock snapshot is unknown: "
918 "msg-addr=%p",
919 msg);
920 status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
921 goto end;
922 }
923
924 ret = validate_clock_class(muxer_msg_iter, muxer_comp,
925 bt_clock_snapshot_borrow_clock_class_const(cs));
926 if (ret) {
927 /* validate_clock_class() logs errors */
928 status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
929 goto end;
930 }
931 }
932
d6e69534
PP
933 ret = get_msg_ts_ns(muxer_comp, muxer_msg_iter, msg,
934 muxer_msg_iter->last_returned_ts_ns, &msg_ts_ns);
958f7d11 935 if (ret) {
d6e69534
PP
936 /* get_msg_ts_ns() logs errors */
937 *muxer_upstream_msg_iter = NULL;
fdf0b89e 938 status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
958f7d11
PP
939 goto end;
940 }
941
d6e69534
PP
942 if (msg_ts_ns <= youngest_ts_ns) {
943 *muxer_upstream_msg_iter =
944 cur_muxer_upstream_msg_iter;
945 youngest_ts_ns = msg_ts_ns;
958f7d11
PP
946 *ts_ns = youngest_ts_ns;
947 }
948 }
949
d6e69534 950 if (!*muxer_upstream_msg_iter) {
fdf0b89e 951 status = BT_SELF_MESSAGE_ITERATOR_STATUS_END;
958f7d11
PP
952 *ts_ns = INT64_MIN;
953 }
954
955end:
956 return status;
957}
958
959static
fdf0b89e 960bt_self_message_iterator_status validate_muxer_upstream_msg_iter(
54bdc1f7
PP
961 struct muxer_upstream_msg_iter *muxer_upstream_msg_iter,
962 bool *is_ended)
958f7d11 963{
fdf0b89e
FD
964 bt_self_message_iterator_status status =
965 BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
958f7d11 966
d6e69534
PP
967 BT_LOGV("Validating muxer's upstream message iterator wrapper: "
968 "muxer-upstream-msg-iter-wrap-addr=%p",
969 muxer_upstream_msg_iter);
fed72692 970
d6e69534
PP
971 if (muxer_upstream_msg_iter->msgs->length > 0 ||
972 !muxer_upstream_msg_iter->msg_iter) {
d4393e08 973 BT_LOGV("Already valid or not considered: "
d6e69534
PP
974 "queue-len=%u, upstream-msg-iter-addr=%p",
975 muxer_upstream_msg_iter->msgs->length,
976 muxer_upstream_msg_iter->msg_iter);
ab11110e
PP
977 goto end;
978 }
979
d6e69534 980 /* muxer_upstream_msg_iter_next() logs details/errors */
54bdc1f7
PP
981 status = muxer_upstream_msg_iter_next(muxer_upstream_msg_iter,
982 is_ended);
089717de
PP
983
984end:
985 return status;
986}
987
988static
fdf0b89e 989bt_self_message_iterator_status validate_muxer_upstream_msg_iters(
d6e69534 990 struct muxer_msg_iter *muxer_msg_iter)
089717de 991{
fdf0b89e
FD
992 bt_self_message_iterator_status status =
993 BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
089717de
PP
994 size_t i;
995
d6e69534
PP
996 BT_LOGV("Validating muxer's upstream message iterator wrappers: "
997 "muxer-msg-iter-addr=%p", muxer_msg_iter);
fed72692 998
54bdc1f7
PP
999 for (i = 0; i < muxer_msg_iter->active_muxer_upstream_msg_iters->len;
1000 i++) {
6bf2abbd 1001 bool is_ended = false;
d6e69534 1002 struct muxer_upstream_msg_iter *muxer_upstream_msg_iter =
089717de 1003 g_ptr_array_index(
54bdc1f7 1004 muxer_msg_iter->active_muxer_upstream_msg_iters,
089717de
PP
1005 i);
1006
d6e69534 1007 status = validate_muxer_upstream_msg_iter(
54bdc1f7 1008 muxer_upstream_msg_iter, &is_ended);
fdf0b89e 1009 if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) {
fed72692 1010 if (status < 0) {
d6e69534
PP
1011 BT_LOGE("Cannot validate muxer's upstream message iterator wrapper: "
1012 "muxer-msg-iter-addr=%p, "
1013 "muxer-upstream-msg-iter-wrap-addr=%p",
1014 muxer_msg_iter,
1015 muxer_upstream_msg_iter);
fed72692 1016 } else {
d6e69534
PP
1017 BT_LOGV("Cannot validate muxer's upstream message iterator wrapper: "
1018 "muxer-msg-iter-addr=%p, "
1019 "muxer-upstream-msg-iter-wrap-addr=%p",
1020 muxer_msg_iter,
1021 muxer_upstream_msg_iter);
fed72692
PP
1022 }
1023
089717de
PP
1024 goto end;
1025 }
744ba28b
PP
1026
1027 /*
54bdc1f7
PP
1028 * Move this muxer upstream message iterator to the
1029 * array of ended iterators if it's ended.
744ba28b 1030 */
54bdc1f7
PP
1031 if (unlikely(is_ended)) {
1032 BT_LOGV("Muxer's upstream message iterator wrapper: ended or canceled: "
1033 "muxer-msg-iter-addr=%p, "
1034 "muxer-upstream-msg-iter-wrap-addr=%p",
1035 muxer_msg_iter, muxer_upstream_msg_iter);
1036 g_ptr_array_add(
1037 muxer_msg_iter->ended_muxer_upstream_msg_iters,
1038 muxer_upstream_msg_iter);
1039 muxer_msg_iter->active_muxer_upstream_msg_iters->pdata[i] = NULL;
1040
744ba28b
PP
1041 /*
1042 * Use g_ptr_array_remove_fast() because the
1043 * order of those elements is not important.
1044 */
1045 g_ptr_array_remove_index_fast(
54bdc1f7 1046 muxer_msg_iter->active_muxer_upstream_msg_iters,
744ba28b
PP
1047 i);
1048 i--;
1049 }
089717de
PP
1050 }
1051
1052end:
1053 return status;
1054}
1055
d4393e08 1056static inline
fdf0b89e 1057bt_self_message_iterator_status muxer_msg_iter_do_next_one(
089717de 1058 struct muxer_comp *muxer_comp,
d6e69534
PP
1059 struct muxer_msg_iter *muxer_msg_iter,
1060 const bt_message **msg)
089717de 1061{
5badd463 1062 bt_self_message_iterator_status status;
d6e69534 1063 struct muxer_upstream_msg_iter *muxer_upstream_msg_iter = NULL;
089717de
PP
1064 int64_t next_return_ts;
1065
5badd463
PP
1066 status = validate_muxer_upstream_msg_iters(muxer_msg_iter);
1067 if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) {
1068 /* validate_muxer_upstream_msg_iters() logs details */
1069 goto end;
958f7d11
PP
1070 }
1071
1072 /*
089717de 1073 * At this point we know that all the existing upstream
d6e69534
PP
1074 * message iterators are valid. We can find the one,
1075 * amongst those, of which the current message is the
089717de 1076 * youngest.
958f7d11 1077 */
d6e69534
PP
1078 status = muxer_msg_iter_youngest_upstream_msg_iter(muxer_comp,
1079 muxer_msg_iter, &muxer_upstream_msg_iter,
089717de 1080 &next_return_ts);
fdf0b89e 1081 if (status < 0 || status == BT_SELF_MESSAGE_ITERATOR_STATUS_END) {
d4393e08 1082 if (status < 0) {
d6e69534 1083 BT_LOGE("Cannot find the youngest upstream message iterator wrapper: "
fed72692 1084 "status=%s",
bd1a54fe 1085 bt_common_self_message_iterator_status_string(status));
fed72692 1086 } else {
d6e69534 1087 BT_LOGV("Cannot find the youngest upstream message iterator wrapper: "
fed72692 1088 "status=%s",
bd1a54fe 1089 bt_common_self_message_iterator_status_string(status));
fed72692
PP
1090 }
1091
958f7d11
PP
1092 goto end;
1093 }
1094
d6e69534
PP
1095 if (next_return_ts < muxer_msg_iter->last_returned_ts_ns) {
1096 BT_LOGE("Youngest upstream message iterator wrapper's timestamp is less than muxer's message iterator's last returned timestamp: "
1097 "muxer-msg-iter-addr=%p, ts=%" PRId64 ", "
fed72692 1098 "last-returned-ts=%" PRId64,
d6e69534
PP
1099 muxer_msg_iter, next_return_ts,
1100 muxer_msg_iter->last_returned_ts_ns);
fdf0b89e 1101 status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
958f7d11
PP
1102 goto end;
1103 }
1104
d6e69534
PP
1105 BT_LOGV("Found youngest upstream message iterator wrapper: "
1106 "muxer-msg-iter-addr=%p, "
1107 "muxer-upstream-msg-iter-wrap-addr=%p, "
fed72692 1108 "ts=%" PRId64,
d6e69534 1109 muxer_msg_iter, muxer_upstream_msg_iter, next_return_ts);
fdf0b89e 1110 BT_ASSERT(status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK);
d6e69534 1111 BT_ASSERT(muxer_upstream_msg_iter);
958f7d11
PP
1112
1113 /*
d4393e08 1114 * Consume from the queue's head: other side
d6e69534 1115 * (muxer_upstream_msg_iter_next()) writes to the tail.
958f7d11 1116 */
d6e69534
PP
1117 *msg = g_queue_pop_head(muxer_upstream_msg_iter->msgs);
1118 BT_ASSERT(*msg);
1119 muxer_msg_iter->last_returned_ts_ns = next_return_ts;
958f7d11
PP
1120
1121end:
d4393e08
PP
1122 return status;
1123}
1124
1125static
fdf0b89e 1126bt_self_message_iterator_status muxer_msg_iter_do_next(
d4393e08 1127 struct muxer_comp *muxer_comp,
d6e69534
PP
1128 struct muxer_msg_iter *muxer_msg_iter,
1129 bt_message_array_const msgs, uint64_t capacity,
d4393e08
PP
1130 uint64_t *count)
1131{
fdf0b89e
FD
1132 bt_self_message_iterator_status status =
1133 BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
d4393e08
PP
1134 uint64_t i = 0;
1135
4725a201 1136 while (i < capacity && status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) {
d6e69534
PP
1137 status = muxer_msg_iter_do_next_one(muxer_comp,
1138 muxer_msg_iter, &msgs[i]);
4725a201 1139 if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) {
d4393e08
PP
1140 i++;
1141 }
1142 }
1143
1144 if (i > 0) {
1145 /*
d6e69534 1146 * Even if muxer_msg_iter_do_next_one() returned
d4393e08 1147 * something else than
d6e69534
PP
1148 * BT_MESSAGE_ITERATOR_STATUS_OK, we accumulated
1149 * message objects in the output message
d4393e08 1150 * array, so we need to return
d6e69534 1151 * BT_MESSAGE_ITERATOR_STATUS_OK so that they are
d4393e08 1152 * transfered to downstream. This other status occurs
d6e69534 1153 * again the next time muxer_msg_iter_do_next() is
d4393e08 1154 * called, possibly without any accumulated
d6e69534 1155 * message, in which case we'll return it.
d4393e08
PP
1156 */
1157 *count = i;
fdf0b89e 1158 status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
d4393e08
PP
1159 }
1160
1161 return status;
958f7d11
PP
1162}
1163
1164static
d6e69534 1165void destroy_muxer_msg_iter(struct muxer_msg_iter *muxer_msg_iter)
ab11110e 1166{
d6e69534 1167 if (!muxer_msg_iter) {
ab11110e
PP
1168 return;
1169 }
1170
d6e69534
PP
1171 BT_LOGD("Destroying muxer component's message iterator: "
1172 "muxer-msg-iter-addr=%p", muxer_msg_iter);
fed72692 1173
54bdc1f7
PP
1174 if (muxer_msg_iter->active_muxer_upstream_msg_iters) {
1175 BT_LOGD_STR("Destroying muxer's active upstream message iterator wrappers.");
1176 g_ptr_array_free(
1177 muxer_msg_iter->active_muxer_upstream_msg_iters, TRUE);
1178 }
1179
1180 if (muxer_msg_iter->ended_muxer_upstream_msg_iters) {
1181 BT_LOGD_STR("Destroying muxer's ended upstream message iterator wrappers.");
ab11110e 1182 g_ptr_array_free(
54bdc1f7 1183 muxer_msg_iter->ended_muxer_upstream_msg_iters, TRUE);
ab11110e
PP
1184 }
1185
d6e69534 1186 g_free(muxer_msg_iter);
ab11110e
PP
1187}
1188
1189static
5badd463 1190int muxer_msg_iter_init_upstream_iterators(struct muxer_comp *muxer_comp,
d6e69534 1191 struct muxer_msg_iter *muxer_msg_iter)
958f7d11 1192{
544d0515
PP
1193 int64_t count;
1194 int64_t i;
ab11110e 1195 int ret = 0;
958f7d11 1196
d94d92ac 1197 count = bt_component_filter_get_input_port_count(
707b7d35 1198 bt_self_component_filter_as_component_filter(
d94d92ac 1199 muxer_comp->self_comp));
544d0515 1200 if (count < 0) {
d6e69534
PP
1201 BT_LOGD("No input port to initialize for muxer component's message iterator: "
1202 "muxer-comp-addr=%p, muxer-msg-iter-addr=%p",
1203 muxer_comp, muxer_msg_iter);
ab11110e
PP
1204 goto end;
1205 }
958f7d11
PP
1206
1207 for (i = 0; i < count; i++) {
5badd463
PP
1208 bt_self_component_port_input_message_iterator *upstream_msg_iter;
1209 struct muxer_upstream_msg_iter *muxer_upstream_msg_iter;
b19ff26f 1210 bt_self_component_port_input *self_port =
d94d92ac
PP
1211 bt_self_component_filter_borrow_input_port_by_index(
1212 muxer_comp->self_comp, i);
b19ff26f 1213 const bt_port *port;
958f7d11 1214
d94d92ac 1215 BT_ASSERT(self_port);
707b7d35
PP
1216 port = bt_self_component_port_as_port(
1217 bt_self_component_port_input_as_self_component_port(
d94d92ac 1218 self_port));
f6ccaed9 1219 BT_ASSERT(port);
958f7d11
PP
1220
1221 if (!bt_port_is_connected(port)) {
5badd463 1222 /* Skip non-connected port */
958f7d11
PP
1223 continue;
1224 }
1225
5badd463
PP
1226 upstream_msg_iter = create_msg_iter_on_input_port(self_port);
1227 if (!upstream_msg_iter) {
1228 /* create_msg_iter_on_input_port() logs errors */
1229 BT_ASSERT(!upstream_msg_iter);
ab11110e
PP
1230 ret = -1;
1231 goto end;
958f7d11 1232 }
fed72692 1233
5badd463
PP
1234 muxer_upstream_msg_iter =
1235 muxer_msg_iter_add_upstream_msg_iter(
1236 muxer_msg_iter, upstream_msg_iter);
1237 bt_self_component_port_input_message_iterator_put_ref(
1238 upstream_msg_iter);
1239 if (!muxer_upstream_msg_iter) {
1240 /* muxer_msg_iter_add_upstream_msg_iter() logs errors */
1241 ret = -1;
1242 goto end;
1243 }
958f7d11
PP
1244 }
1245
1246end:
958f7d11
PP
1247 return ret;
1248}
1249
958f7d11 1250BT_HIDDEN
4cdfc5e8 1251bt_self_message_iterator_status muxer_msg_iter_init(
d6e69534 1252 bt_self_message_iterator *self_msg_iter,
b19ff26f
PP
1253 bt_self_component_filter *self_comp,
1254 bt_self_component_port_output *port)
958f7d11
PP
1255{
1256 struct muxer_comp *muxer_comp = NULL;
d6e69534 1257 struct muxer_msg_iter *muxer_msg_iter = NULL;
4cdfc5e8 1258 bt_self_message_iterator_status status =
fdf0b89e 1259 BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
958f7d11
PP
1260 int ret;
1261
d94d92ac 1262 muxer_comp = bt_self_component_get_data(
707b7d35 1263 bt_self_component_filter_as_self_component(self_comp));
f6ccaed9 1264 BT_ASSERT(muxer_comp);
d6e69534
PP
1265 BT_LOGD("Initializing muxer component's message iterator: "
1266 "comp-addr=%p, muxer-comp-addr=%p, msg-iter-addr=%p",
1267 self_comp, muxer_comp, self_msg_iter);
a09c6b95 1268
d6e69534 1269 if (muxer_comp->initializing_muxer_msg_iter) {
a09c6b95 1270 /*
089717de 1271 * Weird, unhandled situation detected: downstream
d6e69534
PP
1272 * creates a muxer message iterator while creating
1273 * another muxer message iterator (same component).
a09c6b95 1274 */
d6e69534
PP
1275 BT_LOGE("Recursive initialization of muxer component's message iterator: "
1276 "comp-addr=%p, muxer-comp-addr=%p, msg-iter-addr=%p",
1277 self_comp, muxer_comp, self_msg_iter);
958f7d11
PP
1278 goto error;
1279 }
1280
d6e69534
PP
1281 muxer_comp->initializing_muxer_msg_iter = true;
1282 muxer_msg_iter = g_new0(struct muxer_msg_iter, 1);
1283 if (!muxer_msg_iter) {
1284 BT_LOGE_STR("Failed to allocate one muxer component's message iterator.");
ab11110e
PP
1285 goto error;
1286 }
1287
d6e69534 1288 muxer_msg_iter->last_returned_ts_ns = INT64_MIN;
54bdc1f7 1289 muxer_msg_iter->active_muxer_upstream_msg_iters =
958f7d11 1290 g_ptr_array_new_with_free_func(
d6e69534 1291 (GDestroyNotify) destroy_muxer_upstream_msg_iter);
54bdc1f7
PP
1292 if (!muxer_msg_iter->active_muxer_upstream_msg_iters) {
1293 BT_LOGE_STR("Failed to allocate a GPtrArray.");
1294 goto error;
1295 }
1296
1297 muxer_msg_iter->ended_muxer_upstream_msg_iters =
1298 g_ptr_array_new_with_free_func(
1299 (GDestroyNotify) destroy_muxer_upstream_msg_iter);
1300 if (!muxer_msg_iter->ended_muxer_upstream_msg_iters) {
fed72692 1301 BT_LOGE_STR("Failed to allocate a GPtrArray.");
958f7d11
PP
1302 goto error;
1303 }
1304
5badd463 1305 ret = muxer_msg_iter_init_upstream_iterators(muxer_comp,
d6e69534 1306 muxer_msg_iter);
a09c6b95 1307 if (ret) {
5badd463 1308 BT_LOGE("Cannot initialize connected input ports for muxer component's message iterator: "
fed72692 1309 "comp-addr=%p, muxer-comp-addr=%p, "
d6e69534
PP
1310 "muxer-msg-iter-addr=%p, msg-iter-addr=%p, ret=%d",
1311 self_comp, muxer_comp, muxer_msg_iter,
1312 self_msg_iter, ret);
a09c6b95
PP
1313 goto error;
1314 }
1315
5badd463 1316 bt_self_message_iterator_set_data(self_msg_iter, muxer_msg_iter);
d6e69534
PP
1317 BT_LOGD("Initialized muxer component's message iterator: "
1318 "comp-addr=%p, muxer-comp-addr=%p, muxer-msg-iter-addr=%p, "
1319 "msg-iter-addr=%p",
1320 self_comp, muxer_comp, muxer_msg_iter, self_msg_iter);
958f7d11
PP
1321 goto end;
1322
1323error:
d6e69534 1324 destroy_muxer_msg_iter(muxer_msg_iter);
5badd463 1325 bt_self_message_iterator_set_data(self_msg_iter, NULL);
fdf0b89e 1326 status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
958f7d11
PP
1327
1328end:
d6e69534 1329 muxer_comp->initializing_muxer_msg_iter = false;
958f7d11
PP
1330 return status;
1331}
1332
1333BT_HIDDEN
54bdc1f7 1334void muxer_msg_iter_finalize(bt_self_message_iterator *self_msg_iter)
958f7d11 1335{
d6e69534
PP
1336 struct muxer_msg_iter *muxer_msg_iter =
1337 bt_self_message_iterator_get_data(self_msg_iter);
b19ff26f 1338 bt_self_component *self_comp = NULL;
958f7d11
PP
1339 struct muxer_comp *muxer_comp = NULL;
1340
d6e69534
PP
1341 self_comp = bt_self_message_iterator_borrow_component(
1342 self_msg_iter);
d94d92ac
PP
1343 BT_ASSERT(self_comp);
1344 muxer_comp = bt_self_component_get_data(self_comp);
d6e69534
PP
1345 BT_LOGD("Finalizing muxer component's message iterator: "
1346 "comp-addr=%p, muxer-comp-addr=%p, muxer-msg-iter-addr=%p, "
1347 "msg-iter-addr=%p",
1348 self_comp, muxer_comp, muxer_msg_iter, self_msg_iter);
958f7d11 1349
5badd463 1350 if (muxer_msg_iter) {
d6e69534 1351 destroy_muxer_msg_iter(muxer_msg_iter);
958f7d11 1352 }
958f7d11
PP
1353}
1354
1355BT_HIDDEN
fdf0b89e 1356bt_self_message_iterator_status muxer_msg_iter_next(
d6e69534
PP
1357 bt_self_message_iterator *self_msg_iter,
1358 bt_message_array_const msgs, uint64_t capacity,
d4393e08 1359 uint64_t *count)
958f7d11 1360{
fdf0b89e 1361 bt_self_message_iterator_status status;
d6e69534
PP
1362 struct muxer_msg_iter *muxer_msg_iter =
1363 bt_self_message_iterator_get_data(self_msg_iter);
b19ff26f 1364 bt_self_component *self_comp = NULL;
958f7d11 1365 struct muxer_comp *muxer_comp = NULL;
958f7d11 1366
d6e69534
PP
1367 BT_ASSERT(muxer_msg_iter);
1368 self_comp = bt_self_message_iterator_borrow_component(
1369 self_msg_iter);
d94d92ac
PP
1370 BT_ASSERT(self_comp);
1371 muxer_comp = bt_self_component_get_data(self_comp);
f6ccaed9 1372 BT_ASSERT(muxer_comp);
d6e69534
PP
1373 BT_LOGV("Muxer component's message iterator's \"next\" method called: "
1374 "comp-addr=%p, muxer-comp-addr=%p, muxer-msg-iter-addr=%p, "
1375 "msg-iter-addr=%p",
1376 self_comp, muxer_comp, muxer_msg_iter, self_msg_iter);
fed72692 1377
d6e69534
PP
1378 status = muxer_msg_iter_do_next(muxer_comp, muxer_msg_iter,
1379 msgs, capacity, count);
d4393e08 1380 if (status < 0) {
d6e69534
PP
1381 BT_LOGE("Cannot get next message: "
1382 "comp-addr=%p, muxer-comp-addr=%p, muxer-msg-iter-addr=%p, "
1383 "msg-iter-addr=%p, status=%s",
1384 self_comp, muxer_comp, muxer_msg_iter, self_msg_iter,
bd1a54fe 1385 bt_common_self_message_iterator_status_string(status));
fed72692 1386 } else {
d6e69534 1387 BT_LOGV("Returning from muxer component's message iterator's \"next\" method: "
d4393e08 1388 "status=%s",
bd1a54fe 1389 bt_common_self_message_iterator_status_string(status));
fed72692 1390 }
958f7d11 1391
d4393e08 1392 return status;
958f7d11
PP
1393}
1394
1395BT_HIDDEN
4cdfc5e8 1396bt_self_component_status muxer_input_port_connected(
b19ff26f
PP
1397 bt_self_component_filter *self_comp,
1398 bt_self_component_port_input *self_port,
1399 const bt_port_output *other_port)
958f7d11 1400{
5badd463 1401 bt_self_component_status status;
958f7d11 1402
5badd463
PP
1403 status = add_available_input_port(self_comp);
1404 if (status) {
06a2cb0d
PP
1405 /*
1406 * Only way to report an error later since this
1407 * method does not return anything.
1408 */
5badd463
PP
1409 BT_LOGE("Cannot add one muxer component's input port: "
1410 "status=%s",
1411 bt_self_component_status_string(status));
06a2cb0d
PP
1412 goto end;
1413 }
1414
958f7d11 1415end:
bf55043c 1416 return status;
958f7d11 1417}
b5443165 1418
54bdc1f7
PP
1419static inline
1420bt_bool muxer_upstream_msg_iters_can_all_seek_beginning(
1421 GPtrArray *muxer_upstream_msg_iters)
b5443165 1422{
b5443165
PP
1423 uint64_t i;
1424 bt_bool ret = BT_TRUE;
1425
54bdc1f7 1426 for (i = 0; i < muxer_upstream_msg_iters->len; i++) {
b5443165 1427 struct muxer_upstream_msg_iter *upstream_msg_iter =
54bdc1f7 1428 muxer_upstream_msg_iters->pdata[i];
b5443165
PP
1429
1430 if (!bt_self_component_port_input_message_iterator_can_seek_beginning(
1431 upstream_msg_iter->msg_iter)) {
1432 ret = BT_FALSE;
1433 goto end;
1434 }
1435 }
1436
1437end:
1438 return ret;
1439}
1440
54bdc1f7
PP
1441BT_HIDDEN
1442bt_bool muxer_msg_iter_can_seek_beginning(
1443 bt_self_message_iterator *self_msg_iter)
1444{
1445 struct muxer_msg_iter *muxer_msg_iter =
1446 bt_self_message_iterator_get_data(self_msg_iter);
1447 bt_bool ret = BT_TRUE;
1448
1449 if (!muxer_upstream_msg_iters_can_all_seek_beginning(
1450 muxer_msg_iter->active_muxer_upstream_msg_iters)) {
1451 ret = BT_FALSE;
1452 goto end;
1453 }
1454
1455 if (!muxer_upstream_msg_iters_can_all_seek_beginning(
1456 muxer_msg_iter->ended_muxer_upstream_msg_iters)) {
1457 ret = BT_FALSE;
1458 goto end;
1459 }
1460
1461end:
1462 return ret;
1463}
1464
b5443165
PP
1465BT_HIDDEN
1466bt_self_message_iterator_status muxer_msg_iter_seek_beginning(
1467 bt_self_message_iterator *self_msg_iter)
1468{
1469 struct muxer_msg_iter *muxer_msg_iter =
1470 bt_self_message_iterator_get_data(self_msg_iter);
ffb12c4f 1471 bt_message_iterator_status status = BT_MESSAGE_ITERATOR_STATUS_OK;
b5443165
PP
1472 uint64_t i;
1473
54bdc1f7
PP
1474 /* Seek all ended upstream iterators first */
1475 for (i = 0; i < muxer_msg_iter->ended_muxer_upstream_msg_iters->len;
1476 i++) {
b5443165 1477 struct muxer_upstream_msg_iter *upstream_msg_iter =
54bdc1f7 1478 muxer_msg_iter->ended_muxer_upstream_msg_iters->pdata[i];
b5443165
PP
1479
1480 status = bt_self_component_port_input_message_iterator_seek_beginning(
1481 upstream_msg_iter->msg_iter);
1482 if (status != BT_MESSAGE_ITERATOR_STATUS_OK) {
1483 goto end;
1484 }
54bdc1f7
PP
1485
1486 empty_message_queue(upstream_msg_iter);
1487 }
1488
1489 /* Seek all previously active upstream iterators */
1490 for (i = 0; i < muxer_msg_iter->active_muxer_upstream_msg_iters->len;
1491 i++) {
1492 struct muxer_upstream_msg_iter *upstream_msg_iter =
1493 muxer_msg_iter->active_muxer_upstream_msg_iters->pdata[i];
1494
1495 status = bt_self_component_port_input_message_iterator_seek_beginning(
1496 upstream_msg_iter->msg_iter);
1497 if (status != BT_MESSAGE_ITERATOR_STATUS_OK) {
1498 goto end;
1499 }
1500
1501 empty_message_queue(upstream_msg_iter);
1502 }
1503
1504 /* Make them all active */
1505 for (i = 0; i < muxer_msg_iter->ended_muxer_upstream_msg_iters->len;
1506 i++) {
1507 struct muxer_upstream_msg_iter *upstream_msg_iter =
1508 muxer_msg_iter->ended_muxer_upstream_msg_iters->pdata[i];
1509
1510 g_ptr_array_add(muxer_msg_iter->active_muxer_upstream_msg_iters,
1511 upstream_msg_iter);
1512 muxer_msg_iter->ended_muxer_upstream_msg_iters->pdata[i] = NULL;
b5443165
PP
1513 }
1514
54bdc1f7
PP
1515 g_ptr_array_remove_range(muxer_msg_iter->ended_muxer_upstream_msg_iters,
1516 0, muxer_msg_iter->ended_muxer_upstream_msg_iters->len);
b5443165 1517 muxer_msg_iter->last_returned_ts_ns = INT64_MIN;
54bdc1f7
PP
1518 muxer_msg_iter->clock_class_expectation =
1519 MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ANY;
b5443165
PP
1520
1521end:
ffb12c4f 1522 return (bt_self_message_iterator_status) status;
b5443165 1523}
This page took 0.122091 seconds and 4 git commands to generate.