[mapguide-commits] r4491 - in sandbox/adsk/2.1: Common/MapGuideCommon/Services Server/src/Core

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Jan 7 17:30:51 EST 2010


Author: brucedechant
Date: 2010-01-07 17:30:49 -0500 (Thu, 07 Jan 2010)
New Revision: 4491

Modified:
   sandbox/adsk/2.1/Common/MapGuideCommon/Services/SiteManager.cpp
   sandbox/adsk/2.1/Common/MapGuideCommon/Services/SiteManager.h
   sandbox/adsk/2.1/Server/src/Core/Server.cpp
Log:
Fix for trac ticket 1131 - Load balancing doesn't support fail over
http://trac.osgeo.org/mapguide/ticket/1131

Notes:
- Updated background check server(s) thread to shutdown faster
- Disabled starting the background check server(s) thread if we are running unit tests




Modified: sandbox/adsk/2.1/Common/MapGuideCommon/Services/SiteManager.cpp
===================================================================
--- sandbox/adsk/2.1/Common/MapGuideCommon/Services/SiteManager.cpp	2010-01-07 20:29:35 UTC (rev 4490)
+++ sandbox/adsk/2.1/Common/MapGuideCommon/Services/SiteManager.cpp	2010-01-07 22:30:49 UTC (rev 4491)
@@ -98,10 +98,18 @@
         }
 
         // Sleep the thread as thread resume/suspend is not supported on all platforms
-        ACE_OS::sleep(sleepTime);
+        for(size_t i=0;i<sleepTime;i++)
+        {
+            ACE_OS::sleep(1);
 
-        // Update whether we are done or not
-        bDone = siteManager->GetCheckServersThreadDone();
+            // Update whether we are done or not
+            bDone = siteManager->GetCheckServersThreadDone();
+            if(bDone)
+            {
+                // We don't want to sleep anymore as we need to shutdown this thread ASAP
+                break;
+            }
+        }
     }
 
     return 0;
@@ -291,12 +299,6 @@
 
     m_bCheckServersThreadDone = false;
 
-    // Need a thread manager
-    ACE_Thread_Manager* manager = ACE_Thread_Manager::instance();
-    
-    // Create the background thread
-    manager->spawn(ACE_THR_FUNC(CheckServers), &m_threadData);
-
     MG_CATCH_AND_THROW(L"MgSiteManager.Initialize")
 }
 
@@ -561,3 +563,17 @@
     ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_mutex));
     m_bCheckServersThreadDone = bDone;
 }
+
+void MgSiteManager::StartCheckServersThread()
+{
+    // Need a thread manager
+    ACE_Thread_Manager* manager = ACE_Thread_Manager::instance();
+    
+    // Create the background thread
+    manager->spawn(ACE_THR_FUNC(CheckServers), &m_threadData);
+}
+
+void MgSiteManager::StopCheckServersThread()
+{
+    SetCheckServersThreadDone(true);
+}

Modified: sandbox/adsk/2.1/Common/MapGuideCommon/Services/SiteManager.h
===================================================================
--- sandbox/adsk/2.1/Common/MapGuideCommon/Services/SiteManager.h	2010-01-07 20:29:35 UTC (rev 4490)
+++ sandbox/adsk/2.1/Common/MapGuideCommon/Services/SiteManager.h	2010-01-07 22:30:49 UTC (rev 4491)
@@ -79,6 +79,8 @@
 
     bool GetCheckServersThreadDone();
     void SetCheckServersThreadDone(bool bDone);
+    void StartCheckServersThread();
+    void StopCheckServersThread();
 
 private:
 

Modified: sandbox/adsk/2.1/Server/src/Core/Server.cpp
===================================================================
--- sandbox/adsk/2.1/Server/src/Core/Server.cpp	2010-01-07 20:29:35 UTC (rev 4490)
+++ sandbox/adsk/2.1/Server/src/Core/Server.cpp	2010-01-07 22:30:49 UTC (rev 4491)
@@ -541,6 +541,10 @@
                                     nResult = siteThreads.Activate();
                                     if(nResult == 0)
                                     {
+                                        // Let the site manager know that the check servers background thread needs to start
+                                        MgSiteManager* siteManager = MgSiteManager::GetInstance();
+                                        siteManager->StartCheckServersThread();
+
                                         MG_LOG_TRACE_ENTRY(L"MgServer::svc() - Before Event Loop");
                                         nResult = ACE_Reactor::instance()->run_reactor_event_loop();
                                         MG_LOG_TRACE_ENTRY(L"MgServer::svc() - After Event Loop");
@@ -575,6 +579,9 @@
                                         adminThreads.close();
                                         siteThreads.close();
 
+                                        // Let the site manager know that the check servers background thread needs to stop
+                                        siteManager->StopCheckServersThread();
+
                                         // Ensure the thread manager waits until all operation threads are done before closing
                                         threadManager.wait();
                                         threadManager.close();



More information about the mapguide-commits mailing list