[mapguide-commits] r6909 - in branches/2.4/MgDev/Desktop/MgDesktop: . Services Services/Feature Services/Feature/Commands

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Jul 18 07:59:25 PDT 2012


Author: jng
Date: 2012-07-18 07:59:25 -0700 (Wed, 18 Jul 2012)
New Revision: 6909

Modified:
   branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.h
   branches/2.4/MgDev/Desktop/MgDesktop/Services/DataReader.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/CreateFeatureSource.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/GetProviderCapabilities.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionPool.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionPool.h
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.h
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FeatureConnection.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FeatureConnection.h
   branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureReader.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/SqlReader.cpp
Log:
mg-desktop changes:
 - Fix connection pooling behaviour due to the recent integration of server code that resulted in connection leaks.
 - Delegate connection closing to MgFdoConnectionUtil. This allows us to keep track of all calls to CreateConnection and CloseConnection ensuring we aren't missing any calls.

Modified: branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.h	2012-07-18 09:50:18 UTC (rev 6908)
+++ branches/2.4/MgDev/Desktop/MgDesktop/MgDesktop.h	2012-07-18 14:59:25 UTC (rev 6909)
@@ -80,12 +80,12 @@
 
 //Uncomment to debug memory leaks. This is the header for Visual Leak Detector
 //See: http://vld.codeplex.com for download and setup
-//#ifdef _WIN32
-//#ifdef _DEBUG
-//#define USING_VLD
-//#include <vld.h>
-//#endif
-//#endif
+#ifdef _WIN32
+#ifdef _DEBUG
+#define USING_VLD
+#include <vld.h>
+#endif
+#endif
 
 //Uncomment to get extra FDO join chatter when running unit tests
 //#define DEBUG_FDOJOIN

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/DataReader.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/DataReader.cpp	2012-07-18 09:50:18 UTC (rev 6908)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/DataReader.cpp	2012-07-18 14:59:25 UTC (rev 6909)
@@ -3,6 +3,7 @@
 #include "Services/Feature/FeatureConnection.h"
 #include "Services/Feature/FeatureUtil.h"
 #include "Services/Feature/RasterHelper.h"
+#include "Services/Feature/FdoConnectionUtil.h"
 #include "Fdo.h"
 
 MgdDataReader::MgdDataReader(MgFeatureConnection* conn, FdoIDataReader* reader)
@@ -648,10 +649,11 @@
     FdoPtr<FdoIConnection> fdoConnection = m_connection->GetConnection();
 
     // Release the connection.
+    //m_connection = NULL;
+    MgFdoConnectionPool::ReturnConnection(m_connection);
     m_connection = NULL;
+    //MgFdoConnectionUtil::CloseConnection(fdoConnection);
 
-    fdoConnection->Close();
-
 	MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgdDataReader::Close");
 }
 

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/CreateFeatureSource.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/CreateFeatureSource.cpp	2012-07-18 09:50:18 UTC (rev 6908)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/CreateFeatureSource.cpp	2012-07-18 14:59:25 UTC (rev 6909)
@@ -131,7 +131,7 @@
         CreateDataStore(conn);
         ApplySchemaAndCreateSpatialContext(conn);
 
-        conn->Close();
+        MgFdoConnectionUtil::CloseConnection(conn);
 
         Ptr<MgResourceService> resourceService = GetResourceService();
         if (NULL != (MgResourceService*)resourceService)

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/GetProviderCapabilities.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/GetProviderCapabilities.cpp	2012-07-18 09:50:18 UTC (rev 6908)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/Commands/GetProviderCapabilities.cpp	2012-07-18 14:59:25 UTC (rev 6909)
@@ -19,6 +19,7 @@
 #include "GetProviderCapabilities.h"
 #include "Services/Feature/FeatureConnection.h"
 #include "Services/Feature/FeatureUtil.h"
+#include "Services/Feature/FdoConnectionUtil.h"
 
 static std::map<FdoThreadCapability, std::string>          s_FdoThreadCapability;
 static std::map<FdoSpatialContextExtentType, std::string>  s_FdoSpatialContextExtentType;
@@ -92,7 +93,7 @@
     // Check if the connection needs to be closed
     if(m_fdoConn->GetConnectionState() == FdoConnectionState_Open)
     {
-        m_fdoConn->Close();
+        MgFdoConnectionUtil::CloseConnection(m_fdoConn);
     }
 
     m_fdoConn = NULL;

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionPool.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionPool.cpp	2012-07-18 09:50:18 UTC (rev 6908)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionPool.cpp	2012-07-18 14:59:25 UTC (rev 6909)
@@ -3,9 +3,6 @@
 #include "FdoConnectionPool.h"
 #include "FdoConnectionUtil.h"
 
-INT64 MgFdoConnectionPool::sm_nConnectionsRequested = 0L;
-INT64 MgFdoConnectionPool::sm_nConnectionsReturned = 0L;
-
 //connection pool record -- contains database pointer
 //plus extra timing information/status
 struct PoolRec
@@ -62,10 +59,10 @@
     if (!g_bPoolingEnabled || it == g_pool.freePool.end() || it->second.size() == 0)
     {
         conn = MgFdoConnectionUtil::CreateConnection(featureSourceId);
+        conn->Open();
     #ifdef DEBUG_FDO_CONNECTION_POOL
-        ACE_DEBUG((LM_INFO, ACE_TEXT("[Created]: (%W)\n"), featureSourceId->ToString().c_str()));
+        ACE_DEBUG((LM_INFO, ACE_TEXT("[Created]: (%W) (refcount: %d)\n"), featureSourceId->ToString().c_str(), conn->GetRefCount()));
     #endif
-        conn->Open();
         bNewInstance = true;
     }
     else
@@ -74,12 +71,12 @@
         {
             PoolRec rec = it->second.back();
             it->second.pop_back();
-        #ifdef DEBUG_FDO_CONNECTION_POOL
-            ACE_DEBUG((LM_INFO, ACE_TEXT("[Re-used]: (%W) %d in cache\n"), featureSourceId->ToString().c_str(), it->second.size()));
-        #endif
             if (FdoConnectionState_Closed == rec._conn->GetConnectionState())
                 rec._conn->Open();
             conn = rec._conn;
+        #ifdef DEBUG_FDO_CONNECTION_POOL
+            ACE_DEBUG((LM_INFO, ACE_TEXT("[Re-used]: (%W) %d in cache (refcount: %d)\n"), featureSourceId->ToString().c_str(), it->second.size(), conn->GetRefCount()));
+        #endif
             bNewInstance = false;
         }
         else
@@ -88,10 +85,10 @@
             ACE_DEBUG((LM_INFO, ACE_TEXT("Provider for (%W) is not poolable\n"), featureSourceId->ToString().c_str()));
         #endif
             conn = MgFdoConnectionUtil::CreateConnection(featureSourceId);
+            conn->Open();
         #ifdef DEBUG_FDO_CONNECTION_POOL
-            ACE_DEBUG((LM_INFO, ACE_TEXT("[Created]: (%W)\n"), featureSourceId->ToString().c_str()));
+            ACE_DEBUG((LM_INFO, ACE_TEXT("[Created]: (%W) (refcount: %d)\n"), featureSourceId->ToString().c_str(), conn->GetRefCount()));
         #endif
-            conn->Open();
             bNewInstance = true;
         }
     }
@@ -103,19 +100,24 @@
 
     MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgFdoConnectionPool::GetConnection")
 
-    sm_nConnectionsRequested++;
-
     return conn.Detach();
 }
 
+FdoIConnection* MgFdoConnectionPool::GetConnection(CREFSTRING providerName, CREFSTRING connectionString)
+{
+    return MgFdoConnectionUtil::CreateConnection(providerName, connectionString);
+}
+
 void MgFdoConnectionPool::ReturnConnection(MgFeatureConnection* conn)
 {
     MG_FEATURE_SERVICE_TRY()
 
     ScopedLock scc(g_pool.mutex);
     STRING providerName = conn->GetProviderName();
-    FdoPtr<FdoIConnection> fdoConn = conn->GetConnection();
+    FdoPtr<FdoIConnection> fdoConn = conn->m_fdoConn; //conn->GetConnection();
     
+    //If feature source is empty, it means the connection was not created via its feature source id
+    //meaning it's not poolable and can't be returned.
     STRING fsIdStr;
     Ptr<MgResourceIdentifier> fsId = conn->GetFeatureSource();
     if (NULL != fsId.p)
@@ -128,48 +130,43 @@
     if (g_bPoolingEnabled)
     {
         STRING providerName = MgFdoConnectionUtil::ParseNonQualifiedProviderName(conn->GetProviderName());
-        if (!g_excludedProviders->Contains(providerName))
+        if (!g_excludedProviders->Contains(providerName) && !fsIdStr.empty())
         {
             std::vector<PoolRec>& vec = g_pool.freePool[fsIdStr];
             vec.push_back(PoolRec(fdoConn, time(NULL), fsIdStr));
         #ifdef DEBUG_FDO_CONNECTION_POOL
-            ACE_DEBUG((LM_INFO, ACE_TEXT("[Returned] (%W) %d in cache\n"), fsIdStr.c_str(), vec.size()));
+            ACE_DEBUG((LM_INFO, ACE_TEXT("[Returned] (%W) %d in cache (refcount: %d)\n"), fsIdStr.c_str(), vec.size(), fdoConn->GetRefCount()));
         #endif
             bReturned = true;
         }
         else
         {
-            fdoConn->Close();
+            MgFdoConnectionUtil::CloseConnection(fdoConn);
         #ifdef DEBUG_FDO_CONNECTION_POOL
-            ACE_DEBUG((LM_INFO, ACE_TEXT("[Closed] (%W) - Provider excluded from pooling\n"), fsIdStr.c_str()));
+            ACE_DEBUG((LM_INFO, ACE_TEXT("[Closed] (%W) - Provider excluded from pooling (refcount: %d)\n"), fsIdStr.c_str(), fdoConn->GetRefCount()));
         #endif
             bProviderExcluded = true;
         }
     }
     else
     {
-        fdoConn->Close();
+        MgFdoConnectionUtil::CloseConnection(fdoConn);
         #ifdef DEBUG_FDO_CONNECTION_POOL
-            ACE_DEBUG((LM_INFO, ACE_TEXT("[Closed] (%W) - Connection Pooling disabled\n"), fsIdStr.c_str()));
+        ACE_DEBUG((LM_INFO, ACE_TEXT("[Closed] (%W) - Connection Pooling disabled (refcount: %d)\n"), fsIdStr.c_str(), fdoConn->GetRefCount()));
         #endif
     }
 
     MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionPool::ReturnConnection", mgStackParams);
-    logDetail.AddResourceIdentifier(L"FeatureSource", fsId);
+    logDetail.AddString(L"FeatureSource", fsIdStr.empty() ? L"<No Feature Source>" : fsIdStr);
     logDetail.AddBool(L"ReturnedToPool", bReturned);
     logDetail.AddBool(L"ProviderExcluded", bProviderExcluded);
     logDetail.Create();
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgFdoConnectionPool::ReturnConnection")
-
-    sm_nConnectionsReturned++;
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgFdoConnectionPool::ReturnConnection")   
 }
 
 void MgFdoConnectionPool::Initialize(MgConfiguration* pConfiguration)
 {
-    sm_nConnectionsRequested = 0L;
-    sm_nConnectionsReturned = 0L;
-
     MG_FEATURE_SERVICE_TRY()
 
     bool bDataConnectionPoolEnabled = MgConfigProperties::DefaultFeatureServicePropertyDataConnectionPoolEnabled;
@@ -225,21 +222,11 @@
 
     ScopedLock scc(g_pool.mutex);
 
-    MgLogDetail logDetail(MgServiceType::FeatureService, MgLogDetail::InternalTrace, L"MgFdoConnectionPool::Cleanup", mgStackParams);
-    logDetail.AddInt64(L"ConnectionsRequested", sm_nConnectionsRequested);
-    logDetail.AddInt64(L"ConnectionsReturned", sm_nConnectionsReturned);
-    logDetail.Create();
-
-    if (sm_nConnectionsRequested != sm_nConnectionsReturned)
-    {
-        ACE_DEBUG((LM_INFO, ACE_TEXT("[WARNING] %d connections have leaked for this session (ie. not returned)\n"), (sm_nConnectionsRequested - sm_nConnectionsReturned)));
-    }
-    
     for (ConnPool::iterator it = g_pool.freePool.begin(); it != g_pool.freePool.end(); ++it)
     {
         while (it->second.size())
         {
-            it->second.back()._conn->Close();
+            MgFdoConnectionUtil::CloseConnection(it->second.back()._conn);
             it->second.back()._conn->Release();
         #ifdef DEBUG_FDO_CONNECTION_POOL
             ACE_DEBUG((LM_INFO, ACE_TEXT("[Cleanup]: (%W) %d in cache\n"), it->second.back()._fsId.c_str(), it->second.size()));
@@ -248,6 +235,10 @@
         }
     }
 
+#ifdef DEBUG_FDO_CONNECTION_POOL
+    MgFdoConnectionUtil::CheckCallStats();
+#endif
+
     MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgFdoConnectionPool::Cleanup")
 }
 
@@ -270,7 +261,7 @@
         INT32 purged = 0;
         while (it->second.size())
         {
-            it->second.back()._conn->Close();
+            MgFdoConnectionUtil::CloseConnection(it->second.back()._conn);
             it->second.back()._conn->Release();
             it->second.pop_back();
             purged++;
@@ -312,7 +303,7 @@
         {
             while (it->second.size())
             {
-                it->second.back()._conn->Close();
+                MgFdoConnectionUtil::CloseConnection(it->second.back()._conn);
                 it->second.back()._conn->Release();
                 it->second.pop_back();
                 purged++;

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionPool.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionPool.h	2012-07-18 09:50:18 UTC (rev 6908)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionPool.h	2012-07-18 14:59:25 UTC (rev 6909)
@@ -36,8 +36,6 @@
     static void GetCacheInfo(std::vector<PoolCacheEntry*>& entries); //Caller responsible for cleanup of contents
 
 private:
-    static INT64 sm_nConnectionsRequested;
-    static INT64 sm_nConnectionsReturned;
     static bool StringStartsWith(CREFSTRING haystack, CREFSTRING needle);
 };
 

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.cpp	2012-07-18 09:50:18 UTC (rev 6908)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.cpp	2012-07-18 14:59:25 UTC (rev 6909)
@@ -5,8 +5,13 @@
 #include "Services/Resource/UnmanagedDataManager.h"
 #include "CryptographyUtil.h"
 
+INT64 MgFdoConnectionUtil::sm_nConnectionsCreated = 0L;
+INT64 MgFdoConnectionUtil::sm_nConnectionsClosed = 0L;
+
 FdoIConnection* MgFdoConnectionUtil::CreateConnection(CREFSTRING providerName, CREFSTRING connectionString)
 {
+    sm_nConnectionsCreated++;
+
     FdoPtr<FdoIConnection> conn;
 
     MG_FEATURE_SERVICE_TRY()
@@ -44,6 +49,8 @@
 
 FdoIConnection* MgFdoConnectionUtil::CreateConnection(MgResourceIdentifier* resource)
 {
+    sm_nConnectionsCreated++;
+
     FdoPtr<FdoIConnection> conn;
 
 	MG_FEATURE_SERVICE_TRY()
@@ -275,4 +282,31 @@
     }
 
     return fs;
-}
\ No newline at end of file
+}
+
+void MgFdoConnectionUtil::CloseConnection(FdoIConnection* conn)
+{
+    sm_nConnectionsClosed++;
+    try 
+    {
+        conn->Close();
+    }
+    catch (FdoException* ex)
+    {
+        FDO_SAFE_RELEASE(ex);
+    }
+    catch (...) 
+    { 
+    
+    }
+}
+
+#ifdef DEBUG_FDO_CONNECTION_POOL
+void MgFdoConnectionUtil::CheckCallStats()
+{
+    if (sm_nConnectionsCreated > sm_nConnectionsClosed)
+    {
+        ACE_DEBUG((LM_INFO, ACE_TEXT("[WARNING] Create/Close call mismatch - Create calls: %d, Close calls: %d\n"), sm_nConnectionsCreated, sm_nConnectionsClosed));
+    }
+}
+#endif
\ No newline at end of file

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.h	2012-07-18 09:50:18 UTC (rev 6908)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FdoConnectionUtil.h	2012-07-18 14:59:25 UTC (rev 6909)
@@ -1,13 +1,6 @@
 #ifndef DESKTOP_FDO_CONNECTION_UTIL_H
 #define DESKTOP_FDO_CONNECTION_UTIL_H
 
-#define RELEASE_AND_DEBUG_FDO_CONNECTION_REF_COUNT(methodName, fdoConn, expectedRefCount) \
-    FdoInt32 iRefCount = fdoConn->Release(); \
-    if (iRefCount != expectedRefCount) \
-    { \
-        ACE_DEBUG((LM_INFO, ACE_TEXT("[%W - WARNING] Expected refcount of %d. Instead, got a refcount of %d\n"), methodName, expectedRefCount, iRefCount)); \
-    } \
-
 class MgFdoConnectionPool;
 class FdoIConnection;
 class MgResourceIdentifier;
@@ -25,6 +18,7 @@
 
 public:
     static MdfModel::FeatureSource* GetFeatureSource(MgResourceIdentifier* resource);
+    static void CloseConnection(FdoIConnection* conn);
 
 private:
     static void PerformTagSubstitution(MgdResourceService* resSvc, REFSTRING str, MgResourceIdentifier* resource, CREFSTRING username = L"", CREFSTRING password = L"");
@@ -36,6 +30,13 @@
 
     //Createa a connection by raw FDO connection string. No tag subsitution is performed.
 	static FdoIConnection* CreateConnection(CREFSTRING provider, CREFSTRING connectionString);    
+#ifdef DEBUG_FDO_CONNECTION_POOL
+    static void CheckCallStats();
+#endif
+
+private:
+    static INT64 sm_nConnectionsCreated;
+    static INT64 sm_nConnectionsClosed;
 };
 
 #endif
\ No newline at end of file

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FeatureConnection.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FeatureConnection.cpp	2012-07-18 09:50:18 UTC (rev 6908)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FeatureConnection.cpp	2012-07-18 14:59:25 UTC (rev 6909)
@@ -1,18 +1,22 @@
 #include "Fdo.h"
 #include "FdoConnectionUtil.h"
 #include "FeatureConnection.h"
+#ifdef DEBUG_FDO_CONNECTION_POOL
+#include <WinBase.h>
+#endif
 
 // Initialize the minimum required memeber variables
 MgFeatureConnection::MgFeatureConnection(MgResourceIdentifier* featureSourceIdentifier)
 {
     Initialize();
-#ifdef DEBUG_FDO_CONNECTION_POOL
-    ACE_DEBUG((LM_INFO, ACE_TEXT("MgFeatureConnection::MgFeatureConnection(MgResourceIdentifier*)\n")));
-#endif
     //This is a potentially poolable connection
     m_fdoConn = MgFdoConnectionPool::GetConnection(featureSourceIdentifier);
     CHECKNULL(m_fdoConn, L"MgFeatureConnection.MgFeatureConnection()");
 
+#ifdef DEBUG_FDO_CONNECTION_POOL
+    ACE_DEBUG((LM_INFO, ACE_TEXT("MgFeatureConnection::MgFeatureConnection(MgResourceIdentifier*) - refcount: %d\n"), m_fdoConn->GetRefCount()));
+#endif
+
     m_resourceId = SAFE_ADDREF(featureSourceIdentifier);
     m_bIsCreatedFromFeatureSource = true;
 }
@@ -21,15 +25,16 @@
 MgFeatureConnection::MgFeatureConnection(CREFSTRING providerName, CREFSTRING connectionString)
 {
     Initialize();
-#ifdef DEBUG_FDO_CONNECTION_POOL
-    ACE_DEBUG((LM_INFO, ACE_TEXT("MgFeatureConnection::MgFeatureConnection(CREFSTRING, CREFSTRING)\n")));
-#endif
     //This is not a poolable connection
-    m_fdoConn = MgFdoConnectionUtil::CreateConnection(providerName, connectionString); //pFdoConnectionManager->Open(providerName, connectionString);
+    m_fdoConn = MgFdoConnectionPool::GetConnection(providerName, connectionString);
     CHECKNULL(m_fdoConn, L"MgFeatureConnection.MgFeatureConnection()");
     if (!connectionString.empty())
         m_fdoConn->Open();
 
+#ifdef DEBUG_FDO_CONNECTION_POOL
+    ACE_DEBUG((LM_INFO, ACE_TEXT("MgFeatureConnection::MgFeatureConnection(CREFSTRING, CREFSTRING) - refcount: %d\n"), m_fdoConn->GetRefCount()));
+#endif
+
     m_resourceId = NULL;
     m_bIsCreatedFromFeatureSource = false;
 }
@@ -66,7 +71,8 @@
     if (NULL != m_fdoConn)
     {
     #ifdef DEBUG_FDO_CONNECTION_POOL
-        ACE_DEBUG((LM_INFO, ACE_TEXT("MgFeatureConnection::Close()\n")));
+        FdoInt32 iRefCount = m_fdoConn->GetRefCount();
+        ACE_DEBUG((LM_INFO, ACE_TEXT("MgFeatureConnection::Close() - refcount %d\n"), iRefCount));
     #endif
         MgFdoConnectionPool::ReturnConnection(this);
         m_fdoConn = NULL;

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FeatureConnection.h
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FeatureConnection.h	2012-07-18 09:50:18 UTC (rev 6908)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/FeatureConnection.h	2012-07-18 14:59:25 UTC (rev 6909)
@@ -9,6 +9,8 @@
 
 class MgFeatureConnection : public MgGuardDisposable
 {
+    friend class MgFdoConnectionPool;
+
 public:
     MgFeatureConnection(MgResourceIdentifier* featureSourceIdentifier);
     MgFeatureConnection(CREFSTRING providerName, CREFSTRING connectionString);

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureReader.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureReader.cpp	2012-07-18 09:50:18 UTC (rev 6908)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureReader.cpp	2012-07-18 14:59:25 UTC (rev 6909)
@@ -3,6 +3,7 @@
 #include "Services/Feature/FeatureConnection.h"
 #include "Services/Feature/FeatureUtil.h"
 #include "Services/Feature/RasterHelper.h"
+#include "Services/Feature/FdoConnectionUtil.h"
 #include "Fdo.h"
 
 MgdFeatureReader::MgdFeatureReader(MgFeatureConnection* conn, FdoIFeatureReader* reader)
@@ -620,15 +621,14 @@
     MG_FEATURE_SERVICE_TRY()
 
     m_reader->Close(); 
-    m_connection->Close();
-
-    /*
+    
     // Get the FDO connection
     FdoPtr<FdoIConnection> fdoConnection = m_connection->GetConnection();
     // Release the connection.
+    //m_connection = NULL;
+    MgFdoConnectionPool::ReturnConnection(m_connection);
     m_connection = NULL;
-    fdoConnection->Close();
-    */
+    //MgFdoConnectionUtil::CloseConnection(fdoConnection);
 
     MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgdFeatureReader::Close");
 }

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/SqlReader.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/SqlReader.cpp	2012-07-18 09:50:18 UTC (rev 6908)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/SqlReader.cpp	2012-07-18 14:59:25 UTC (rev 6909)
@@ -1,5 +1,6 @@
 #include "SqlReader.h"
 #include "Services/Feature/FeatureConnection.h"
+#include "Services/Feature/FdoConnectionUtil.h"
 #include "Fdo.h"
 
 MgdSqlDataReader::MgdSqlDataReader(MgFeatureConnection* conn, FdoISQLDataReader* reader)
@@ -535,10 +536,11 @@
     FdoPtr<FdoIConnection> fdoConnection = m_connection->GetConnection();
 
     // Release the connection.
+    //m_connection = NULL;
+    MgFdoConnectionPool::ReturnConnection(m_connection);
     m_connection = NULL;
+    //MgFdoConnectionUtil::CloseConnection(fdoConnection);
 
-    fdoConnection->Close();
-
 	MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgdDataReader::Close");
 }
 



More information about the mapguide-commits mailing list