geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbarr...@apache.org
Subject [46/46] geode-native git commit: GEODE-2741: Workaround for static de-init issues with CLR.
Date Wed, 17 May 2017 17:50:28 GMT
GEODE-2741: Workaround for static de-init issues with CLR.


Project: http://git-wip-us.apache.org/repos/asf/geode-native/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode-native/commit/767033e5
Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/767033e5
Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/767033e5

Branch: refs/heads/develop
Commit: 767033e5cfd70b3ad41cac67d63db464b3697a85
Parents: d58a5e3
Author: Jacob Barrett <jbarrett@pivotal.io>
Authored: Wed May 17 04:09:22 2017 +0000
Committer: Jacob Barrett <jbarrett@pivotal.io>
Committed: Wed May 17 05:05:51 2017 +0000

----------------------------------------------------------------------
 src/cppcache/include/geode/CacheFactory.hpp     |  3 +-
 src/cppcache/src/CacheFactory.cpp               | 14 ++++----
 .../src/CacheTransactionManagerImpl.cpp         |  4 +--
 src/cppcache/src/TXState.cpp                    |  2 +-
 src/cppcache/src/ThinClientStickyManager.cpp    | 34 ++++++++++----------
 src/cppcache/src/TssConnectionWrapper.cpp       |  2 +-
 src/cppcache/src/TssConnectionWrapper.hpp       |  3 +-
 7 files changed, 33 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode-native/blob/767033e5/src/cppcache/include/geode/CacheFactory.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/CacheFactory.hpp b/src/cppcache/include/geode/CacheFactory.hpp
index 5d519bb..b9c149d 100644
--- a/src/cppcache/include/geode/CacheFactory.hpp
+++ b/src/cppcache/include/geode/CacheFactory.hpp
@@ -494,7 +494,8 @@ class CPPCACHE_EXPORT CacheFactory
                                     bool closeOk, CachePtr& cptr);
 
   // Set very first time some creates cache
-  static CacheFactoryPtr default_CacheFactory;
+  // TODO shared_ptr - remove or refactor with global work
+  static CacheFactoryPtr* default_CacheFactory;
   static PoolPtr createOrGetDefaultPool();
   static void* m_cacheMap;
   static void init();

http://git-wip-us.apache.org/repos/asf/geode-native/blob/767033e5/src/cppcache/src/CacheFactory.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheFactory.cpp b/src/cppcache/src/CacheFactory.cpp
index ec332e5..97a2adf 100644
--- a/src/cppcache/src/CacheFactory.cpp
+++ b/src/cppcache/src/CacheFactory.cpp
@@ -55,7 +55,7 @@ typedef std::map<std::string, CachePtr> StringToCachePtrMap;
 
 void* CacheFactory::m_cacheMap = (void*)NULL;
 
-CacheFactoryPtr CacheFactory::default_CacheFactory = nullptr;
+CacheFactoryPtr* CacheFactory::default_CacheFactory = nullptr;
 
 PoolPtr CacheFactory::createOrGetDefaultPool() {
   ACE_Guard<ACE_Recursive_Thread_Mutex> connectGuard(*g_disconnectLock);
@@ -71,9 +71,10 @@ PoolPtr CacheFactory::createOrGetDefaultPool() {
 
   // if default_poolFactory is null then we are not using latest API....
   if (pool == nullptr && Cache_CreatedFromCacheFactory) {
-    if (default_CacheFactory != nullptr) {
-      pool = default_CacheFactory->determineDefaultPool(cache);
+    if (default_CacheFactory && (*default_CacheFactory)) {
+      pool = (*default_CacheFactory)->determineDefaultPool(cache);
     }
+    (*default_CacheFactory) = nullptr;
     default_CacheFactory = nullptr;
   }
 
@@ -225,7 +226,7 @@ CachePtr CacheFactory::create() {
   cache = getAnyInstance(false);
 
   if (cache == nullptr) {
-    default_CacheFactory = shared_from_this();
+    default_CacheFactory = new CacheFactoryPtr(shared_from_this());
     Cache_CreatedFromCacheFactory = true;
     cache = create(DEFAULT_CACHE_NAME, dsPtr,
                    dsPtr->getSystemProperties()->cacheXMLFile(), nullptr);
@@ -237,8 +238,9 @@ CachePtr CacheFactory::create() {
       determineDefaultPool(cache);
     } else {
       // not yet created, create from first cacheFactory instance
-      if (default_CacheFactory != nullptr) {
-        default_CacheFactory->determineDefaultPool(cache);
+      if (default_CacheFactory && (*default_CacheFactory)) {
+        (*default_CacheFactory)->determineDefaultPool(cache);
+        (*default_CacheFactory) = nullptr;
         default_CacheFactory = nullptr;
       }
       determineDefaultPool(cache);

http://git-wip-us.apache.org/repos/asf/geode-native/blob/767033e5/src/cppcache/src/CacheTransactionManagerImpl.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheTransactionManagerImpl.cpp b/src/cppcache/src/CacheTransactionManagerImpl.cpp
index bdea6db..58e5a02 100644
--- a/src/cppcache/src/CacheTransactionManagerImpl.cpp
+++ b/src/cppcache/src/CacheTransactionManagerImpl.cpp
@@ -313,7 +313,7 @@ GfErrType CacheTransactionManagerImpl::rollback(TXState* txState,
 }
 
 ThinClientPoolDM* CacheTransactionManagerImpl::getDM() {
-  TcrConnection* conn = TssConnectionWrapper::s_geodeTSSConn->getConnection();
+  TcrConnection* conn = (*TssConnectionWrapper::s_geodeTSSConn)->getConnection();
   if (conn != NULL) {
     ThinClientPoolDM* dm = conn->getEndpointObject()->getPoolHADM();
     if (dm != NULL) {
@@ -334,7 +334,7 @@ TransactionIdPtr CacheTransactionManagerImpl::suspend() {
   }
 
   // get the current connection that this transaction is using
-  TcrConnection* conn = TssConnectionWrapper::s_geodeTSSConn->getConnection();
+  TcrConnection* conn = (*TssConnectionWrapper::s_geodeTSSConn)->getConnection();
   if (conn == NULL) {
     LOGFINE("Thread local connection is null. Returning NULL transaction Id.");
     return nullptr;

http://git-wip-us.apache.org/repos/asf/geode-native/blob/767033e5/src/cppcache/src/TXState.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TXState.cpp b/src/cppcache/src/TXState.cpp
index 89f327a..ad81186 100644
--- a/src/cppcache/src/TXState.cpp
+++ b/src/cppcache/src/TXState.cpp
@@ -110,7 +110,7 @@ void TXState::releaseStickyConnection() {
   // Since this is called during cleanup or through destructor, we should not
   // throw exception from here,
   // which can cause undefined cleanup.
-  TcrConnection* conn = TssConnectionWrapper::s_geodeTSSConn->getConnection();
+  TcrConnection* conn = (*TssConnectionWrapper::s_geodeTSSConn)->getConnection();
   if (conn != NULL) {
     ThinClientPoolDM* dm = conn->getEndpointObject()->getPoolHADM();
     if (dm != NULL) {

http://git-wip-us.apache.org/repos/asf/geode-native/blob/767033e5/src/cppcache/src/ThinClientStickyManager.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/ThinClientStickyManager.cpp b/src/cppcache/src/ThinClientStickyManager.cpp
index cfac1db..af6ce46 100644
--- a/src/cppcache/src/ThinClientStickyManager.cpp
+++ b/src/cppcache/src/ThinClientStickyManager.cpp
@@ -23,7 +23,7 @@ bool ThinClientStickyManager::getStickyConnection(
   bool maxConnLimit = false;
   bool connFound = false;
   // ACE_Guard<ACE_Recursive_Thread_Mutex> guard( m_stickyLock );
-  conn = TssConnectionWrapper::s_geodeTSSConn->getConnection();
+  conn = (*TssConnectionWrapper::s_geodeTSSConn)->getConnection();
 
   if (!conn) {
     conn =
@@ -50,34 +50,34 @@ bool ThinClientStickyManager::getStickyConnection(
 
 void ThinClientStickyManager::getSingleHopStickyConnection(
     TcrEndpoint* theEP, TcrConnection*& conn) {
-  conn = TssConnectionWrapper::s_geodeTSSConn->getSHConnection(theEP,
+  conn = (*TssConnectionWrapper::s_geodeTSSConn)->getSHConnection(theEP,
                                                                m_dm->getName());
 }
 
 void ThinClientStickyManager::addStickyConnection(TcrConnection* conn) {
   ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_stickyLock);
   TcrConnection* oldConn =
-      TssConnectionWrapper::s_geodeTSSConn->getConnection();
+      (*TssConnectionWrapper::s_geodeTSSConn)->getConnection();
   if (oldConn) {
     std::set<TcrConnection**>::iterator it = m_stickyConnList.find(
-        TssConnectionWrapper::s_geodeTSSConn->getConnDoublePtr());
+        (*TssConnectionWrapper::s_geodeTSSConn)->getConnDoublePtr());
     if (it != m_stickyConnList.end()) {
       oldConn->setAndGetBeingUsed(false, false);
       m_stickyConnList.erase(it);
       PoolPtr p = nullptr;
-      TssConnectionWrapper::s_geodeTSSConn->setConnection(NULL, p);
+      (*TssConnectionWrapper::s_geodeTSSConn)->setConnection(NULL, p);
       m_dm->put(oldConn, false);
     }
   }
 
   if (conn) {
-    TssConnectionWrapper::s_geodeTSSConn->setConnection(
+    (*TssConnectionWrapper::s_geodeTSSConn)->setConnection(
         conn, m_dm->shared_from_this());
     conn->setAndGetBeingUsed(true, true);  // this is done for transaction
                                            // thread when some one resume
                                            // transaction
     m_stickyConnList.insert(
-        TssConnectionWrapper::s_geodeTSSConn->getConnDoublePtr());
+        (*TssConnectionWrapper::s_geodeTSSConn)->getConnDoublePtr());
   }
 }
 
@@ -86,21 +86,21 @@ void ThinClientStickyManager::setStickyConnection(TcrConnection* conn,
   // ACE_Guard<ACE_Recursive_Thread_Mutex> guard( m_stickyLock );
   if (!conn) {
     ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_stickyLock);
-    TssConnectionWrapper::s_geodeTSSConn->setConnection(
+    (*TssConnectionWrapper::s_geodeTSSConn)->setConnection(
         NULL, m_dm->shared_from_this());
   } else {
     TcrConnection* currentConn =
-        TssConnectionWrapper::s_geodeTSSConn->getConnection();
+        (*TssConnectionWrapper::s_geodeTSSConn)->getConnection();
     if (currentConn != conn)  // otherwsie no need to set it again
     {
       ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_stickyLock);
-      TssConnectionWrapper::s_geodeTSSConn->setConnection(
+      (*TssConnectionWrapper::s_geodeTSSConn)->setConnection(
           conn, m_dm->shared_from_this());
       conn->setAndGetBeingUsed(
           false,
           forTransaction);  // if transaction then it will keep this as used
       m_stickyConnList.insert(
-          TssConnectionWrapper::s_geodeTSSConn->getConnDoublePtr());
+          (*TssConnectionWrapper::s_geodeTSSConn)->getConnDoublePtr());
     } else {
       currentConn->setAndGetBeingUsed(
           false,
@@ -111,7 +111,7 @@ void ThinClientStickyManager::setStickyConnection(TcrConnection* conn,
 
 void ThinClientStickyManager::setSingleHopStickyConnection(
     TcrEndpoint* ep, TcrConnection*& conn) {
-  TssConnectionWrapper::s_geodeTSSConn->setSHConnection(ep, conn);
+  (*TssConnectionWrapper::s_geodeTSSConn)->setSHConnection(ep, conn);
 }
 
 void ThinClientStickyManager::cleanStaleStickyConnection() {
@@ -188,11 +188,11 @@ bool ThinClientStickyManager::canThisConnBeDeleted(TcrConnection* conn)
{
   return canBeDeleted;
 }
 void ThinClientStickyManager::releaseThreadLocalConnection() {
-  TcrConnection* conn = TssConnectionWrapper::s_geodeTSSConn->getConnection();
+  TcrConnection* conn = (*TssConnectionWrapper::s_geodeTSSConn)->getConnection();
   if (conn) {
     ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_stickyLock);
     std::set<TcrConnection**>::iterator it = m_stickyConnList.find(
-        TssConnectionWrapper::s_geodeTSSConn->getConnDoublePtr());
+        (*TssConnectionWrapper::s_geodeTSSConn)->getConnDoublePtr());
     LOGDEBUG("ThinClientStickyManager::releaseThreadLocalConnection()");
     if (it != m_stickyConnList.end()) {
       m_stickyConnList.erase(it);
@@ -200,10 +200,10 @@ void ThinClientStickyManager::releaseThreadLocalConnection() {
                                false);  // now this can be used by next one
       m_dm->put(conn, false);
     }
-    TssConnectionWrapper::s_geodeTSSConn->setConnection(
+    (*TssConnectionWrapper::s_geodeTSSConn)->setConnection(
         NULL, m_dm->shared_from_this());
   }
-  TssConnectionWrapper::s_geodeTSSConn->releaseSHConnections(
+  (*TssConnectionWrapper::s_geodeTSSConn)->releaseSHConnections(
       m_dm->shared_from_this());
 }
 bool ThinClientStickyManager::isNULL(TcrConnection** conn) {
@@ -213,5 +213,5 @@ bool ThinClientStickyManager::isNULL(TcrConnection** conn) {
 
 void ThinClientStickyManager::getAnyConnection(TcrConnection*& conn) {
   conn =
-      TssConnectionWrapper::s_geodeTSSConn->getAnyConnection(m_dm->getName());
+      (*TssConnectionWrapper::s_geodeTSSConn)->getAnyConnection(m_dm->getName());
 }

http://git-wip-us.apache.org/repos/asf/geode-native/blob/767033e5/src/cppcache/src/TssConnectionWrapper.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TssConnectionWrapper.cpp b/src/cppcache/src/TssConnectionWrapper.cpp
index a30cc3d..edf510e 100644
--- a/src/cppcache/src/TssConnectionWrapper.cpp
+++ b/src/cppcache/src/TssConnectionWrapper.cpp
@@ -18,7 +18,7 @@
 #include "TcrConnection.hpp"
 #include "ThinClientPoolDM.hpp"
 using namespace apache::geode::client;
-ACE_TSS<TssConnectionWrapper> TssConnectionWrapper::s_geodeTSSConn;
+ACE_TSS<TssConnectionWrapper>* TssConnectionWrapper::s_geodeTSSConn = new ACE_TSS<TssConnectionWrapper>();
 TssConnectionWrapper::TssConnectionWrapper() {
   PoolPtr p = nullptr;
   m_pool = p;

http://git-wip-us.apache.org/repos/asf/geode-native/blob/767033e5/src/cppcache/src/TssConnectionWrapper.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/TssConnectionWrapper.hpp b/src/cppcache/src/TssConnectionWrapper.hpp
index e37d062..e808bde 100644
--- a/src/cppcache/src/TssConnectionWrapper.hpp
+++ b/src/cppcache/src/TssConnectionWrapper.hpp
@@ -58,7 +58,8 @@ class TssConnectionWrapper {
   TssConnectionWrapper(const TssConnectionWrapper&);
 
  public:
-  static ACE_TSS<TssConnectionWrapper> s_geodeTSSConn;
+  // TODO shared_ptr - remove or refactor with global work
+  static ACE_TSS<TssConnectionWrapper>* s_geodeTSSConn;
   TcrConnection* getConnection() { return m_tcrConn; }
   TcrConnection* getSHConnection(TcrEndpoint* ep, const char* poolname);
   void setConnection(TcrConnection* conn, const PoolPtr& pool) {


Mime
View raw message