Skip to content

Commit ec90eb0

Browse files
committed
fix hd-rum-transcode crash
crashes since the commit ab5d2a5 (2025-06-17) That commit started to enforce existence of control socket, which is not true in case of the reflector. fixes ab5d2a5 closes GH-461
1 parent ebca9e1 commit ec90eb0

7 files changed

Lines changed: 31 additions & 22 deletions

File tree

src/audio/filter/controlport_stats.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@
5353
#include "lib_common.h"
5454

5555
struct state_controlport_stats{
56-
state_controlport_stats(struct module *mod) : mod(MODULE_CLASS_DATA, mod, this)
56+
explicit state_controlport_stats(struct module *mod)
57+
: mod(MODULE_CLASS_DATA, mod, this), control(get_control_state(mod))
5758
{
58-
control = (control_state *) (get_module(get_root_module(mod),
59-
"control"))
60-
->priv_data;
6159
}
6260

6361
module_raii mod;

src/control_socket.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,26 @@ int control_audio_ch_report_count(struct control_state *state){
10431043
return state ? state->audio_channel_report_count : 0;
10441044
}
10451045

1046+
/**
1047+
* finds control socket state from module hierarchy
1048+
*
1049+
* @param mod module in the tree (doesn't need to be root), may be nullptr (nullptr is returned then)
1050+
* @returns found state; nullptr if state not found (or mod=0)
1051+
*/
1052+
struct control_state *
1053+
get_control_state(struct module *mod)
1054+
{
1055+
if (mod == nullptr) {
1056+
return nullptr;
1057+
}
1058+
struct module *control_mod =
1059+
get_module(get_root_module(mod), "control");
1060+
if (control_mod == nullptr) {
1061+
return nullptr;
1062+
}
1063+
return (struct control_state *) control_mod->priv_data;
1064+
}
1065+
10461066
static void print_control_help() {
10471067
color_printf("Control internal commands:\n"
10481068
TBOLD("\texit") "\n"

src/control_socket.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author Martin Pulec <martin.pulec@cesnet.cz>
44
*/
55
/*
6-
* Copyright (c) 2013-2021 CESNET, z. s. p. o.
6+
* Copyright (c) 2013-2025 CESNET
77
* All rights reserved.
88
*
99
* Redistribution and use in source and binary forms, with or without
@@ -51,13 +51,13 @@ struct module;
5151
* @retval 0 if success
5252
*/
5353
int control_init(int port, int connection_type, struct control_state **state, struct module *root_module, int force_ip_version);
54+
struct control_state *get_control_state(struct module *mod);
5455
void control_start(struct control_state *state);
5556
void control_done(struct control_state *s);
5657
void control_report_stats(struct control_state *state, const std::string & stat_line);
5758
void control_report_event(struct control_state *state, const std::string & event_line);
5859
bool control_stats_enabled(struct control_state *state);
5960
int control_audio_ch_report_count(struct control_state *state);
6061

61-
6262
#endif // control_socket_h_
6363

src/rtp/audio_decoders.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,7 @@ void *audio_decoder_init(char *audio_channel_map, const char *audio_scale, const
271271
s->packet_counter = packet_counter_init(0);
272272

273273
s->audio_decompress = NULL;
274-
275-
s->control = (struct control_state *) get_module(
276-
get_root_module(parent), "control")
277-
->priv_data;
274+
s->control = get_control_state(parent);
278275

279276
if (strlen(encryption) > 0) {
280277
s->dec_funcs = static_cast<const struct openssl_decrypt_info *>(load_library("openssl_decrypt",

src/rtp/video_decoders.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,21 +335,20 @@ struct main_msg_reconfigure {
335335
*/
336336
struct state_video_decoder
337337
{
338-
state_video_decoder(struct module *parent) {
338+
explicit state_video_decoder(struct module *parent)
339+
: control(get_control_state(parent))
340+
{
339341
module_init_default(&mod);
340342
mod.cls = MODULE_CLASS_DECODER;
341343
mod.priv_data = this;
342344
mod.new_message = decoder_process_message;
343345
module_register(&mod, parent);
344-
control = (struct control_state *) get_module(
345-
get_root_module(parent), "control")
346-
->priv_data;
347346
}
348347
~state_video_decoder() {
349348
module_done(&mod);
350349
}
351350
struct module mod;
352-
struct control_state *control = {};
351+
struct control_state *control;
353352

354353
thread decompress_thread_id,
355354
fec_thread_id;

src/transmit.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,7 @@ struct tx *tx_init(struct module *parent, unsigned mtu, enum tx_media_type media
263263
}
264264

265265
tx->bitrate = bitrate;
266-
267-
if (parent) {
268-
tx->control = (struct control_state *) get_module(
269-
get_root_module(parent), "control")->priv_data;
270-
}
266+
tx->control = get_control_state(parent);
271267

272268
return tx;
273269
}

src/video_rxtx/ultragrid_rtp.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ ultragrid_rtp_video_rxtx::ultragrid_rtp_video_rxtx(const map<string, param_u> &p
9292
throw ug_no_error();
9393
}
9494

95-
m_control = (struct control_state *) get_module(
96-
get_root_module(m_common.parent), "control")->priv_data;
95+
m_control = get_control_state(m_common.parent);
9796
}
9897

9998
ultragrid_rtp_video_rxtx::~ultragrid_rtp_video_rxtx()

0 commit comments

Comments
 (0)