From d5e6e3629aacfc9dbdeeaf9f652aa8d4c342fb73 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 6 Mar 2026 15:42:03 +0100 Subject: [PATCH] hd-rum-translator: add new_message callback if no data is comming, the messages are not dispatched Maybe not a big problem, it would be dispatched when some data arives. The potential problem, however, can be if added huge number of participants at that time, the queue may overflow and further message dropped. (Current max queue len is 10 - maybe it can be extended later.) --- src/hd-rum-translator/hd-rum-translator.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/hd-rum-translator/hd-rum-translator.cpp b/src/hd-rum-translator/hd-rum-translator.cpp index fabf721ea..1b7c01c06 100644 --- a/src/hd-rum-translator/hd-rum-translator.cpp +++ b/src/hd-rum-translator/hd-rum-translator.cpp @@ -13,7 +13,7 @@ * compresses and sends frame to receiver */ /* - * Copyright (c) 2013-2025 CESNET + * Copyright (c) 2013-2026 CESNET, zájmové sdružení právnických osob * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -103,6 +103,8 @@ set_replica_mod_name(size_t buflen, char *buf, const char *addr, assert(len < buflen); // len >= buflen means overflow } +static void new_message_received(struct module *); + struct replica { replica(const char *addr, uint16_t rx_port, uint16_t tx_port, int bufsize, struct module *parent, int force_ip_version) { magic = REPLICA_MAGIC; @@ -122,6 +124,7 @@ struct replica { mod.cls = MODULE_CLASS_PORT; set_replica_mod_name(sizeof mod.name, mod.name, addr, tx_port); mod.priv_data = this; + mod.new_message = new_message_received; module_register(&mod, parent); type = replica::type_t::NONE; } @@ -537,6 +540,16 @@ static void *writer(void *arg) return NULL; } +static void +new_message_received(struct module *m) +{ + auto *s = (struct hd_rum_translator_state *) m->priv_data; + pthread_mutex_lock(&s->qempty_mtx); + s->qempty = 0; + pthread_mutex_unlock(&s->qempty_mtx); + pthread_cond_signal(&s->qempty_cond); +} + static void usage(const char *progname) { col() << "Usage:\n\t" << SBOLD(SRED(progname)