Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ServiceDiscovery/ServiceDiscovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ void* ServiceDiscovery::MulticastListenThread(void* arg){
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
if (setsockopt(sock.at(i), IPPROTO_IP, IP_ADD_MEMBERSHIP,&mreq, sizeof(mreq)) < 0) {
perror("setsockopt mreq");
printf("Failed to goin multicast group listen thread");
printf("Failed to join multicast group listen thread");
exit(1);
}

Expand Down
15 changes: 9 additions & 6 deletions src/ServiceDiscovery/Services.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"<<std::endl;
return false;
}

// TODO FIXME with better mechanism
// after Initilising the slow control client needs ~15 seconds for the middleman to connect
std::this_thread::sleep_for(std::chrono::seconds(15));
// hopefully the middleman has found us by now
// wait for the middleman to connect. ServiceDiscovery broadcasts are sent out intermittently,
// so we need to wait for the middleman to receive one & connect before we can communicate with it.
int pub_period=5;
m_variables.Get("service_publish_sec",pub_period);
Ready(pub_period*1000);

return true;
}

bool Services::Ready(const unsigned int timeout){
return m_backend_client.Ready(timeout);
}

// ===========================================================================
// Write Functions
// ---------------
Expand Down
1 change: 1 addition & 0 deletions src/ServiceDiscovery/Services.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace ToolFramework {
Services();
~Services();
bool Init(Store &m_variables, zmq::context_t* context_in, SlowControlCollection* sc_vars_in, bool new_service=false);
bool Ready(const unsigned int timeout=10000); // default service discovery broadcast period is 5s, middleman also checks intermittently, compound total time should be <10s...

bool SQLQuery(const std::string& database, const std::string& query, std::vector<std::string>& 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);
Expand Down
Loading