From f963a06e253b9c8c2ff14060d9ce64fcc8e7e15f Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Thu, 13 Apr 2017 12:51:35 +0200 Subject: [PATCH] make connecting channel wait loop more flexible --- fairmq/FairMQDevice.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fairmq/FairMQDevice.cxx b/fairmq/FairMQDevice.cxx index 5aad7232..69e946e9 100644 --- a/fairmq/FairMQDevice.cxx +++ b/fairmq/FairMQDevice.cxx @@ -227,20 +227,20 @@ void FairMQDevice::InitWrapper() // go over the list of channels until all are initialized (and removed from the uninitialized list) int numAttempts = 0; + auto sleepTimeInMS = 50; + auto maxAttempts = fInitializationTimeoutInS * 1000 / sleepTimeInMS; while (!uninitializedConnectingChannels.empty()) { AttachChannels(uninitializedConnectingChannels); - if (++numAttempts > fInitializationTimeoutInS) + if (numAttempts > maxAttempts) { LOG(ERROR) << "could not connect all channels after " << fInitializationTimeoutInS << " attempts"; // TODO: goto ERROR state; exit(EXIT_FAILURE); } - if (numAttempts != 0) - { - this_thread::sleep_for(chrono::milliseconds(1000)); - } + this_thread::sleep_for(chrono::milliseconds(sleepTimeInMS)); + numAttempts++; } Init();