[ https://issues.apache.org/jira/browse/GEODE-8553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17209112#comment-17209112 ]
ASF GitHub Bot commented on GEODE-8553: --------------------------------------- mreddington commented on a change in pull request #660: URL: https://github.com/apache/geode-native/pull/660#discussion_r500561294 ########## File path: cppcache/src/ThinClientLocatorHelper.cpp ########## @@ -174,30 +176,25 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewCallBackConn( ClientProxyMembershipID& memId, std::list<ServerLocation>& outEndpoint, std::string&, int redundancy, const std::set<ServerLocation>& exclEndPts, const std::string& serverGrp) { - std::lock_guard<decltype(m_locatorLock)> guard(m_locatorLock); auto& sysProps = m_poolDM->getConnectionManager() .getCacheImpl() ->getDistributedSystem() .getSystemProperties(); - int locatorsRetry = 3; - if (m_poolDM) { - int poolRetry = m_poolDM->getRetryAttempts(); - locatorsRetry = poolRetry <= 0 ? locatorsRetry : poolRetry; - } + + auto poolRetry = m_poolDM->getRetryAttempts(); + auto locatorsRetry = poolRetry <= 0 ? 3 : poolRetry; + LOGFINER( "ThinClientLocatorHelper::getEndpointForNewCallBackConn locatorsRetry = " "%d ", locatorsRetry); - for (unsigned attempts = 0; - attempts < - (m_locHostPort.size() == 1 ? locatorsRetry : m_locHostPort.size()); - attempts++) { - ServerLocation loc; - if (m_locHostPort.size() == 1) { - loc = m_locHostPort[0]; - } else { - loc = m_locHostPort[attempts]; - } + + auto locators = getLocators(); + auto locatorsSize = locators.size(); + auto maxAttempts = locatorsSize == 1 ? locatorsRetry : locatorsSize; + + for (auto attempts = 0ULL; attempts < maxAttempts; ++attempts) { + const auto& loc = locatorsSize == 1 ? locators[0] : locators[attempts]; Review comment: I'm not opposed to changing the business logic, since A) this business logic is not part of any formal specification, we make no promises here and are free to do what we want, and B) this code contains obvious bugs. That said, so long as the bug is addressed, whatever solution you like. Your suggestion is just fine. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Reduce ThinClientLocatorHelper lock time > ---------------------------------------- > > Key: GEODE-8553 > URL: https://issues.apache.org/jira/browse/GEODE-8553 > Project: Geode > Issue Type: Improvement > Components: native client > Affects Versions: 1.12.0, 1.13.0 > Reporter: Mario Salazar de Torres > Assignee: Mario Salazar de Torres > Priority: Major > Labels: pull-request-available > > During my troublshootings, I've seen that locking m_locatorLock for the whole > scope of the class function members might cause some inter-locks. > Problem here and in many other places of the NC is that networking operations > are performed while a mutex is locked. Therefore if *thread A* takes longer > than expected in performing its network operation, it might block another one > which does not requires any resource of the first *thread A*. Hence, the > inter-lock. > This improvement is the first one of a series regarding to lock scope > reduction when it comes with code regarding networking in NC. > -- This message was sent by Atlassian Jira (v8.3.4#803005)