Commit a86b77fa authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline
Browse files

Merge branch 'fix_empty_recv_frames' into 'passive_recv'

parents 4a3715eb c9075f41
Pipeline #23434 failed with stages
in 1 minute and 40 seconds
......@@ -375,7 +375,7 @@ class Eiger : public Model
return (t.m_state == Thread::Running);
}
void processOneFrame(Thread& t);
void processOneFrame(Thread& t, AutoMutex& l);
Eiger *m_eiger;
int m_idx;
......@@ -387,7 +387,6 @@ class Eiger : public Model
FrameType m_next_frame;
FrameType m_last_frame;
SortedIntList m_in_process;
bool m_finishing;
FrameMap::Item *m_frame_map_item;
ThreadList m_thread_list;
};
......
......@@ -109,14 +109,18 @@ class FrameMap
Mutex mutex;
void set(int reset)
{ count = reset; }
{
mutex.lock();
count = reset;
mutex.unlock();
}
bool dec_test_and_reset(int reset)
{
mutex.lock();
bool zero = (--count == 0);
if (zero)
set(reset);
count = reset;
mutex.unlock();
return zero;
}
......
Subproject commit 328dc17931b59e66a0f5c1347b35b807f6426bde
Subproject commit 90c6756b1fdd4cb9c80918ba0275a05b8fd4b157
......@@ -435,7 +435,10 @@ void Camera::removeSharedMem()
DEB_MEMBER_FUNCT();
ostringstream cmd;
cmd << "sls_detector_get " << m_det_id << "-free";
system(cmd.str().c_str());
string cmd_str = cmd.str();
int ret = system(cmd_str.c_str());
if (ret != 0)
THROW_HW_ERROR(Error) << "Error executing " << DEB_VAR1(cmd_str);
}
void Camera::createReceivers()
......@@ -535,6 +538,8 @@ void Camera::setSkipFrameFreq(FrameType skip_frame_freq)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(skip_frame_freq);
if (skip_frame_freq)
THROW_HW_ERROR(NotSupported) << "Skip frame not supported yet";
m_skip_frame_freq = skip_frame_freq;
setNbFrames(m_lima_nb_frames);
}
......
......@@ -357,6 +357,7 @@ void Eiger::Geometry::Recv::copy(const FrameData& data)
void Eiger::Geometry::Recv::fillBadFrame(FrameType frame, char *bptr)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR2(m_idx, frame);
FrameData data;
for (int i = 0; i < getNbPorts(); ++i)
data.src[i] = NULL;
......@@ -638,10 +639,9 @@ void Eiger::Recv::Thread::threadFunction()
m_state = Ready;
broadcast();
while (m_state != Stop) {
AutoMutexUnlock u(l);
m_recv->processOneFrame(*this);
}
while (m_state != Stop)
m_recv->processOneFrame(*this, l);
m_state = End;
broadcast();
}
......@@ -660,7 +660,7 @@ void Eiger::Recv::Thread::prepareAcq()
}
Eiger::Recv::Recv(Eiger *eiger, int idx)
: m_eiger(eiger), m_idx(idx), m_finishing(false)
: m_eiger(eiger), m_idx(idx)
{
DEB_CONSTRUCTOR();
DEB_PARAM() << DEB_VAR1(m_idx);
......@@ -698,7 +698,6 @@ void Eiger::Recv::prepareAcq()
{
DEB_MEMBER_FUNCT();
m_finishing = false;
m_in_process.clear();
Camera *cam = m_eiger->getCamera();
......@@ -731,7 +730,7 @@ void Eiger::Recv::stopAcq()
(*it)->stopAcq();
AutoMutex l = lock();
while (m_finishing)
while (!m_in_process.empty())
wait();
}
......@@ -763,12 +762,10 @@ void Eiger::Recv::setNbProcessingThreads(int nb_proc_threads)
}
}
void Eiger::Recv::processOneFrame(Thread& t)
void Eiger::Recv::processOneFrame(Thread& t, AutoMutex& l)
{
DEB_MEMBER_FUNCT();
AutoMutex l = lock();
if (!checkForRecvState(t))
return;
......@@ -778,8 +775,7 @@ void Eiger::Recv::processOneFrame(Thread& t)
{
public:
Sync(FrameType f, Recv& r)
: frame(f), recv(r), in_proc(r.m_in_process),
finishing(r.m_finishing), do_finish(false)
: frame(f), recv(r), in_proc(r.m_in_process)
{
in_proc.insert(frame);
}
......@@ -787,31 +783,19 @@ void Eiger::Recv::processOneFrame(Thread& t)
~Sync()
{
in_proc.erase(frame);
if (do_finish)
endFinish();
recv.broadcast();
}
void startFinish()
{
do_finish = true;
while (finishing ||
(!in_proc.empty() && (*in_proc.begin() < frame)))
while (!in_proc.empty() && (*in_proc.begin() < frame))
recv.wait();
finishing = true;
}
void endFinish()
{
finishing = false;
}
private:
FrameType frame;
Recv& recv;
SortedIntList& in_proc;
bool& finishing;
bool do_finish;
} sync(frame, *this);
bool ok;
......
......@@ -72,7 +72,6 @@ FrameMap::Item::frameFinished(FrameType frame, bool no_check, bool valid)
if (finished)
finfo.finished.insert(f);
}
m_last_frame = frame;
if (DEB_CHECK_ANY(DebTypeReturn)) {
PrettySortedList finished_list(finfo.finished);
......@@ -82,6 +81,8 @@ FrameMap::Item::frameFinished(FrameType frame, bool no_check, bool valid)
AutoMutex l = lock();
m_last_frame = frame;
FrameType f = finfo.first_lost;
for (int i = 0; i < finfo.nb_lost; ++i, ++f)
m_bad_frame_list.push_back(f);
......@@ -138,8 +139,10 @@ FrameArray FrameMap::getItemFrameArray() const
{
FrameArray frame_array;
ItemList::const_iterator it, end = m_item_list.end();
for (it = m_item_list.begin(); it != end; ++it)
for (it = m_item_list.begin(); it != end; ++it) {
AutoMutex l = (*it)->lock();
frame_array.push_back((*it)->m_last_frame);
}
return frame_array;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment