diff --git a/bb/src/connections.cc b/bb/src/connections.cc index 8c7b07113..9392dff8f 100644 --- a/bb/src/connections.cc +++ b/bb/src/connections.cc @@ -327,22 +327,23 @@ int setupWhoami(string whoami, string instance) \brief Connection authentication response handler */ static boost::property_tree::ptree myV; -boost::property_tree::ptree getVersionPropertyTree(){ - return myV; +pthread_once_t init_myV = PTHREAD_ONCE_INIT; +void set_myV(void){ + bbVersionToTree(BBAPI_CLIENTVERSIONSTR, myV); } -static bool myVersionInit(){ - bbVersionToTree(BBAPI_CLIENTVERSIONSTR, myV); - return true; +boost::property_tree::ptree getVersionPropertyTree(){ + pthread_once(&init_myV, set_myV); + return myV; } -static bool myV_set = myVersionInit(); int versionCheck(const std::string& pReceivedVersion){ + auto vt = getVersionPropertyTree(); boost::property_tree::ptree receivedV; bbVersionToTree(pReceivedVersion, receivedV); - std::string myVersionString = myV.get("version.major", "NOTFOUND_"+process_whoami); + std::string myVersionString = vt.get("version.major", "NOTFOUND_"+process_whoami); if(myVersionString != receivedV.get("version.major", "xyz")) { stringstream errorText; @@ -352,7 +353,7 @@ int versionCheck(const std::string& pReceivedVersion){ bberror << err("error.whoami", process_whoami); SET_RC_RAS_AND_BAIL(-1, bb.cfgerr.versionmismatch); } - if( myV.get("gitcommit", "commit_NOTFOUND_"+process_whoami) != receivedV.get("gitcommit", "xyz")) + if( vt.get("gitcommit", "commit_NOTFOUND_"+process_whoami) != receivedV.get("gitcommit", "xyz")) LOG(bb,info)<<"gitcommit levels are different, received="<