Commit 0bec8857 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

Avoid dead-locks during Abort

parent 9df79ec2
...@@ -174,7 +174,6 @@ class LIBEIGER Camera : public HwMaxImageSizeCallbackGen, public EventCallbackGe ...@@ -174,7 +174,6 @@ class LIBEIGER Camera : public HwMaxImageSizeCallbackGen, public EventCallbackGe
void _synchronize(); /// Used during plug-in initialization void _synchronize(); /// Used during plug-in initialization
void _trigger_finished(bool); void _trigger_finished(bool);
void _initialization_finished(bool ok); void _initialization_finished(bool ok);
void _disarm();
void _updateImageSize(); void _updateImageSize();
......
...@@ -253,11 +253,11 @@ void Camera::startAcq() ...@@ -253,11 +253,11 @@ void Camera::startAcq()
if((m_trig_mode == IntTrig) || (m_trig_mode == IntTrigMult)) if((m_trig_mode == IntTrig) || (m_trig_mode == IntTrigMult))
{ {
bool disarm_at_end = (m_frames_triggered + m_nb_triggers == m_nb_frames);
DEB_TRACE() << "Trigger start: " << DEB_VAR1(disarm_at_end);
CommandReq trigger = m_requests->get_command(Requests::TRIGGER); CommandReq trigger = m_requests->get_command(Requests::TRIGGER);
m_trigger_state = RUNNING; m_trigger_state = RUNNING;
m_frames_triggered += m_nb_triggers; m_frames_triggered += m_nb_triggers;
bool disarm_at_end = (m_frames_triggered == m_nb_frames);
DEB_TRACE() << "Trigger start: " << DEB_VAR1(disarm_at_end);
AutoMutexUnlock u(lock); AutoMutexUnlock u(lock);
CallbackPtr cbk(new TriggerCallback(*this)); CallbackPtr cbk(new TriggerCallback(*this));
...@@ -280,6 +280,7 @@ void Camera::stopAcq() ...@@ -280,6 +280,7 @@ void Camera::stopAcq()
// Ongoing Trigger callback might run, avoid Disarm and potential deadlock // Ongoing Trigger callback might run, avoid Disarm and potential deadlock
m_armed = false; m_armed = false;
lock.unlock(); lock.unlock();
DEB_TRACE() << "Aborting";
sendCommand(Requests::ABORT); sendCommand(Requests::ABORT);
} }
...@@ -739,7 +740,8 @@ void Camera::_trigger_finished(bool ok) ...@@ -739,7 +740,8 @@ void Camera::_trigger_finished(bool ok)
if(!ok) { if(!ok) {
DEB_ERROR() << "Error in trigger command"; DEB_ERROR() << "Error in trigger command";
} else if(m_frames_triggered == m_nb_frames) { } else if(m_frames_triggered == m_nb_frames) {
try { _disarm(); } AutoMutexUnlock u(lock);
try { disarm(); }
catch (...) { ok = false; } catch (...) { ok = false; }
} }
...@@ -1143,18 +1145,13 @@ void Camera::disarm() ...@@ -1143,18 +1145,13 @@ void Camera::disarm()
{ {
DEB_MEMBER_FUNCT(); DEB_MEMBER_FUNCT();
AutoMutex lock(m_cond.mutex()); AutoMutex lock(m_cond.mutex());
_disarm(); if (!m_armed)
} return;
void Camera::_disarm() m_armed = false;
{ lock.unlock();
DEB_MEMBER_FUNCT(); DEB_TRACE() << "Disarming";
DEB_PARAM() << DEB_VAR1(m_armed); sendCommand(Requests::DISARM);
if (m_armed) {
DEB_TRACE() << "Disarming";
sendCommand(Requests::DISARM);
m_armed = false;
}
} }
const std::string& Camera::getDetectorIp() const const std::string& Camera::getDetectorIp() const
......
Supports Markdown
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