diff --git a/src/ServiceDiscovery/Services.cpp b/src/ServiceDiscovery/Services.cpp index a4be2fc..e952e78 100644 --- a/src/ServiceDiscovery/Services.cpp +++ b/src/ServiceDiscovery/Services.cpp @@ -27,21 +27,24 @@ bool Services::Init(Store &m_variables, zmq::context_t* context_in, SlowControlC if(!m_variables.Get("service_name",m_name)) m_name="test_service"; if(!m_variables.Get("db_name",m_dbname)) m_dbname="daq"; - - if(!m_backend_client.Initialise(m_variables)){ std::clog<<"error initialising slowcontrol client"<& responses, const unsigned int timeout=SERVICES_DEFAULT_TIMEOUT); bool SQLQuery(const std::string& database, const std::string& query, std::string& response, const unsigned int timeout=SERVICES_DEFAULT_TIMEOUT); diff --git a/src/ServiceDiscovery/ServicesBackend.cpp b/src/ServiceDiscovery/ServicesBackend.cpp index aff94e2..3fbe98f 100644 --- a/src/ServiceDiscovery/ServicesBackend.cpp +++ b/src/ServiceDiscovery/ServicesBackend.cpp @@ -936,3 +936,30 @@ bool ServicesBackend::Receive(zmq::socket_t* sock, std::vector& return true; } +bool ServicesBackend::Ready(int timeout){ + + // poll the output sockets for listeners + // only poll dealer socket, pub sockets always return true immediately so ignore the timeout + // polling the input socket checks for a message, so don't do that. + int ret; + try { + dlr_socket_mutex.lock(); + ret = zmq::poll(&out_polls.at(1), 1, timeout); + dlr_socket_mutex.unlock(); + } catch (zmq::error_t& err){ + std::cerr<<"ServicesBackend::Ready caught "< log=nullptr); // possibly move to constructor + bool Ready(int timeout); // check if zmq sockets have connections bool Initialise(std::string configfile); bool Initialise(Store &varaibles_in); bool Finalise();