Bläddra i källkod

SMBServer: Release connections and associated resources when stopping the server

Tal Aloni 7 år sedan
förälder
incheckning
5a29ef1556
2 ändrade filer med 10 tillägg och 0 borttagningar
  1. 9 0
      SMBLibrary/Server/ConnectionManager.cs
  2. 1 0
      SMBLibrary/Server/SMBServer.cs

+ 9 - 0
SMBLibrary/Server/ConnectionManager.cs

@@ -44,6 +44,15 @@ namespace SMBLibrary.Server
             RemoveConnection(connection);
         }
 
+        public void ReleaseAllConnections()
+        {
+            List<ConnectionState> connections = new List<ConnectionState>(m_activeConnections);
+            foreach (ConnectionState connection in connections)
+            {
+                ReleaseConnection(connection);
+            }
+        }
+
         public List<SessionInformation> GetSessionsInformation()
         {
             List<SessionInformation> result = new List<SessionInformation>();

+ 1 - 0
SMBLibrary/Server/SMBServer.cs

@@ -82,6 +82,7 @@ namespace SMBLibrary.Server
             Log(Severity.Information, "Stopping server");
             m_listening = false;
             SocketUtils.ReleaseSocket(m_listenerSocket);
+            m_connectionManager.ReleaseAllConnections();
         }
 
         // This method Accepts new connections