AcquisitionDevice: Fix potential infinite loop

This commit is contained in:
2026-02-28 17:32:34 +01:00
parent ab077625b9
commit fe61cfcfde

View File

@@ -81,44 +81,47 @@ void AcquisitionDevice::WaitForActionComplete() {
while (c.type != Completion::Type::End) {
DeviceOutput* output;
bool skip_analysis = false;
try {
output = GetDeviceOutput(c.handle);
} catch (const JFJochException &e) {
if (logger)
logger->ErrorException(e);
continue;
skip_analysis = true;
}
c.module_number = output->module_statistics.module_number;
c.packet_count = output->module_statistics.packet_count;
c.frame_number = output->module_statistics.frame_number;
if (!skip_analysis) {
c.module_number = output->module_statistics.module_number;
c.packet_count = output->module_statistics.packet_count;
c.frame_number = output->module_statistics.frame_number;
if (c.frame_number >= expected_frames) {
Cancel();
// this frame is not of any interest, therefore its location can be immediately released
SendWorkRequest(c.handle);
} else if (c.module_number >= max_modules) {
// Module number out of bounds, don't process
if (logger != nullptr)
logger->Error("Completion with wrong module number data stream {} completion frame number {} module {} handle {}",
data_stream, c.frame_number, c.module_number, c.handle);
SendWorkRequest(c.handle);
} else if (c.frame_number < counters.GetSlowestFrameNumber()) {
// Module is falling behind, needs to return the handle then
SendWorkRequest(c.handle);
} else {
try {
counters.UpdateCounters(&c);
} catch (const JFJochException &e) {
if (logger)
logger->ErrorException(e);
if (c.frame_number >= expected_frames) {
Cancel();
// this frame is not of any interest, therefore its location can be immediately released
SendWorkRequest(c.handle);
} else if (c.module_number >= max_modules) {
// Module number out of bounds, don't process
if (logger != nullptr)
logger->Error("Completion with wrong module number data stream {} completion frame number {} module {} handle {}",
data_stream, c.frame_number, c.module_number, c.handle);
SendWorkRequest(c.handle);
} else if (c.frame_number < counters.GetSlowestFrameNumber()) {
// Module is falling behind, needs to return the handle then
SendWorkRequest(c.handle);
} else {
try {
counters.UpdateCounters(&c);
} catch (const JFJochException &e) {
if (logger)
logger->ErrorException(e);
SendWorkRequest(c.handle);
}
}
if (logger != nullptr)
logger->Debug("Data stream {} completion frame number {} module {} handle {}",
data_stream, c.frame_number, c.module_number, c.handle);
}
if (logger != nullptr)
logger->Debug("Data stream {} completion frame number {} module {} handle {}",
data_stream, c.frame_number, c.module_number, c.handle);
c = work_completion_queue.GetBlocking();
}
counters.SetAcquisitionFinished();