[mapguide-commits] r8392 - trunk/MgDev/Server/src/Core

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Oct 7 02:29:39 PDT 2014


Author: jng
Date: 2014-10-07 02:29:39 -0700 (Tue, 07 Oct 2014)
New Revision: 8392

Modified:
   trunk/MgDev/Server/src/Core/ClientAcceptor.cpp
Log:
#2492: Reclaim any dangling sockets on server restart. The allows for immediate server restart on Linux when it dies due to segfault. No observable side-effects on Windows.

Modified: trunk/MgDev/Server/src/Core/ClientAcceptor.cpp
===================================================================
--- trunk/MgDev/Server/src/Core/ClientAcceptor.cpp	2014-10-07 09:26:41 UTC (rev 8391)
+++ trunk/MgDev/Server/src/Core/ClientAcceptor.cpp	2014-10-07 09:29:39 UTC (rev 8392)
@@ -55,7 +55,14 @@
     // Set a large backlog so INET will not block connections
     // so often.  It takes time to clean the port up and
     // make it available for other connections.
-    if (m_SockAcceptor.open(m_Addr, 0, PF_INET, 32) != -1)
+    //
+    // Also set reuse_addr = 1 to avoid the case where the mgserver
+    // process dies by segfault and we have to wait several minutes for
+    // the dangling sockets to be cleared out by the system before mgserver
+    // can be started again (dangling sockets will cause a "port already in 
+    // use" error when restarting mgserver). With reuse_addr = 1, mgserver 
+    // will reclaim these dangling sockets when this method is called
+    if (m_SockAcceptor.open(m_Addr, 1 /* reuse_addr */, PF_INET, 32) != -1)
     {
         MgLogManager* pMan = MgLogManager::GetInstance();
         if(pMan->IsTraceLogEnabled())



More information about the mapguide-commits mailing list