Fix stop rx stuck (#669)

stop should really stop even if receiver had crashed, so check rx status after sending stop; also ensuring restream  in acquire happens only if thers a callback
This commit is contained in:
Dhanya Thattil 2023-02-20 15:21:22 +01:00 committed by GitHub
parent 878eab9fc3
commit fe281bd1b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 15 deletions

View File

@ -483,6 +483,12 @@ This document describes the differences between v7.0.0.rc1 and v6.1.2
to access shared memory without creating it first. to access shared memory without creating it first.
* Stop detector when receiver is stuck
If receiver was stuck or crashed, stop acquisition command should
stop detector first before checking receiver status to restream
dummy header. Fixed.
* Free and config command fail * Free and config command fail
Free and config command checked mismatch of size of shared memory before Free and config command checked mismatch of size of shared memory before
freeing or loading new config. Fixed. freeing or loading new config. Fixed.

View File

@ -1224,8 +1224,7 @@ int DetectorImpl::acquire() {
// let the progress thread (no callback) know acquisition is done // let the progress thread (no callback) know acquisition is done
if (dataReady == nullptr) { if (dataReady == nullptr) {
setJoinThreadFlag(true); setJoinThreadFlag(true);
} } else if (receiver) {
if (receiver) {
while (numZmqRunning != 0) { while (numZmqRunning != 0) {
Parallel(&Module::restreamStopFromReceiver, {}); Parallel(&Module::restreamStopFromReceiver, {});
std::this_thread::sleep_for(std::chrono::milliseconds(200)); std::this_thread::sleep_for(std::chrono::milliseconds(200));
@ -1315,6 +1314,7 @@ void DetectorImpl::processData(bool receiver) {
} }
// only update progress // only update progress
else { else {
LOG(logINFO) << "Type 'q' and hit enter to stop";
double progress = 0; double progress = 0;
printProgress(progress); printProgress(progress);

View File

@ -870,27 +870,26 @@ void Module::startReadout() {
} }
void Module::stopAcquisition() { void Module::stopAcquisition() {
// get status before stopping acquisition
runStatus s = ERROR, r = ERROR; // get det status before stopping acq
bool zmqstreaming = false; runStatus detStatus = ERROR;
try { try {
if (shm()->useReceiverFlag && getReceiverStreaming()) { detStatus = getRunStatus();
zmqstreaming = true;
s = getRunStatus();
r = getReceiverStatus();
}
} catch (...) { } catch (...) {
// if receiver crashed, stop detector in any case
zmqstreaming = false;
} }
sendToDetectorStop(F_STOP_ACQUISITION); sendToDetectorStop(F_STOP_ACQUISITION);
shm()->stoppedFlag = true; shm()->stoppedFlag = true;
// if rxr streaming and acquisition finished, restream dummy stop packet // restream dummy header, if rxr streaming and det idle before stop
if (zmqstreaming && (s == IDLE) && (r == IDLE)) { try {
if (shm()->useReceiverFlag && getReceiverStreaming()) {
if (detStatus == IDLE && getReceiverStatus() == IDLE) {
restreamStopFromReceiver(); restreamStopFromReceiver();
} }
}
} catch (...) {
}
} }
void Module::restreamStopFromReceiver() { void Module::restreamStopFromReceiver() {