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