Skip to content

reactor of FrameReceiverController called twice when expected frame received and released #524

Description

@JamesOHeaDLS

reactor_.stop() is called twice when handle_frame_release_channel() (within FrameReceiverController.cpp) has received and released all the expected frames:

if (config_.frame_count_ && (frames_released_ >= config_.frame_count_)) {
    LOG4CXX_INFO(
        logger_,
        "Specified number of frames (" << config_.frame_count_ << ") received and released, terminating"
    );
    this->stop();
    reactor_.stop();
}

Once via this->stop() which is called with deferred defaulting to False. This results in the else branch within the stop function running:

void FrameReceiverController::stop(const bool deferred)
{
    if (deferred) {
        reactor_.register_timer(deferred_action_delay_ms, 1, boost::bind(&FrameReceiverController::stop, this, false));
    } else {
        LOG4CXX_TRACE(logger_, "FrameReceiverController::stop()");
        terminate_controller_ = true;
        reactor_.stop();
    }
}

And then a second explicit call directly afterwards.

Instead, I think this->stop(True) should be called to do a controlled stop. I also think this explicit call of reactor_.stop within handle_frame_release_channel is incorrect anyway as it is it means the reactor is being stopped from within one of its own handlers.

I believe this double call is why, in the C++ CI run of odinDataTest, the frameReceiver terminating message appears twice, and may be linked to why this CI sometimes fails in an apparent race condition.

22364 [0x7f9ca2812dc0] INFO Test.App null - Process to launch: test
22364 [0x7f9ca2812dc0] DEBUG Test.App null - Launching /home/runner/work/excalibur-detector/excalibur-detector/prefix/bin/frameTests --log_level=all -- (5850)
23365 [0x7f9ca2812dc0] DEBUG Test.App null - Terminating /home/runner/work/excalibur-detector/excalibur-detector/prefix/bin/frameReceiver(5827)
23365 [0x7f9ca2812dc0] DEBUG Test.App null - Terminating /home/runner/work/excalibur-detector/excalibur-detector/prefix/bin/frameProcessor(5831)
23365 [0x7f9ca2812dc0] DEBUG Test.App null - Terminating /home/runner/work/excalibur-detector/excalibur-detector/prefix/bin/frameTests --log_level=all -- (0)
23365 [0x7f9ca2812dc0] DEBUG Test.App null - Terminating /home/runner/work/excalibur-detector/excalibur-detector/prefix/bin/frameReceiver(5827)
Error: The operation was canceled.

Metadata

Metadata

Assignees

Labels

bugBUG! Needs fixing!good first issueGood issue for new developers looking to explore and contribute to the codebase

Type

Fields

No fields configured for Bug.

Projects

Status
🤷‍♂️ Needs Triage

Relationships

None yet

Development

No branches or pull requests

Issue actions