Skip to content

Commit d5e6e36

Browse files
committed
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.)
1 parent 01c6d48 commit d5e6e36

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/hd-rum-translator/hd-rum-translator.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* compresses and sends frame to receiver
1414
*/
1515
/*
16-
* Copyright (c) 2013-2025 CESNET
16+
* Copyright (c) 2013-2026 CESNET, zájmové sdružení právnických osob
1717
* All rights reserved.
1818
*
1919
* 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,
103103
assert(len < buflen); // len >= buflen means overflow
104104
}
105105

106+
static void new_message_received(struct module *);
107+
106108
struct replica {
107109
replica(const char *addr, uint16_t rx_port, uint16_t tx_port, int bufsize, struct module *parent, int force_ip_version) {
108110
magic = REPLICA_MAGIC;
@@ -122,6 +124,7 @@ struct replica {
122124
mod.cls = MODULE_CLASS_PORT;
123125
set_replica_mod_name(sizeof mod.name, mod.name, addr, tx_port);
124126
mod.priv_data = this;
127+
mod.new_message = new_message_received;
125128
module_register(&mod, parent);
126129
type = replica::type_t::NONE;
127130
}
@@ -537,6 +540,16 @@ static void *writer(void *arg)
537540
return NULL;
538541
}
539542

543+
static void
544+
new_message_received(struct module *m)
545+
{
546+
auto *s = (struct hd_rum_translator_state *) m->priv_data;
547+
pthread_mutex_lock(&s->qempty_mtx);
548+
s->qempty = 0;
549+
pthread_mutex_unlock(&s->qempty_mtx);
550+
pthread_cond_signal(&s->qempty_cond);
551+
}
552+
540553
static void usage(const char *progname) {
541554
col() << "Usage:\n\t"
542555
<< SBOLD(SRED(progname)

0 commit comments

Comments
 (0)