Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1021 from IBM/updateStaticInit
Browse files Browse the repository at this point in the history
Update connections.cc
  • Loading branch information
tgooding authored Feb 8, 2022
2 parents 03eb299 + 1430517 commit 0b3d0c0
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions bb/src/connections.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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="<<pReceivedVersion<<" my Version="<<BBAPI_CLIENTVERSIONSTR;
return 0;
}
Expand Down

0 comments on commit 0b3d0c0

Please sign in to comment.