main: safeguard disconnect from transient bricks

This commit is contained in:
Thomas Schoebel-Theuer 2022-06-02 11:54:01 +02:00 committed by Thomas Schoebel-Theuer
parent 86eb014173
commit 4e928bafc9
1 changed files with 17 additions and 0 deletions

View File

@ -5541,8 +5541,25 @@ int _stop_trans(struct mars_rotate *rot)
write_info_links(rot);
for (i = TL_INPUT_LOG1; i <= TL_INPUT_LOG2; i++) {
struct trans_logger_input *trans_input;
trans_input = trans_brick->inputs[i];
if (trans_input && !trans_input->is_operating) {
struct mars_brick *prev_brick;
if (!trans_input->connect)
continue;
/* For safety, do not mock with a transient
* predecessor.
* In general, the predecessor may be in shared use
* otherwise.
*/
prev_brick = (void *)trans_input->connect->brick;
if (prev_brick &&
!prev_brick->power.led_on &&
!prev_brick->power.led_off)
continue;
(void)mars_disconnect((void*)trans_input);
}
}