Sfoglia il codice sorgente

Fehler im SSL Server behoben

Kolja Strohm 6 anni fa
parent
commit
a3daccf499
3 ha cambiato i file con 21 aggiunte e 7 eliminazioni
  1. 16 7
      MainServer/MainServer.cpp
  2. 2 0
      MainServer/MainServer.h
  3. 3 0
      MainServer/main.cpp

+ 16 - 7
MainServer/MainServer.cpp

@@ -4,13 +4,13 @@
 #include <iostream>
 #include <Klient.h>
 #include <Globals.h>
-#include <AsynchronCall.h>
 
 // Inhalt der MainServer Klasse aus MainServer.h
 // Konstruktor 
 MainServer::MainServer( InitDatei *zDat )
 : Thread()
 {
+    sslServerThread = 0;
 	Network::Start( 100 );
 	std::cout << "MS: Verbindung mit Datenbank wird hergestellt...\n";
 	db = new MSDatenbank( zDat );
@@ -45,6 +45,8 @@ MainServer::~MainServer()
 {
 	ende();
     serverSSL->trenne();
+    if( sslServerThread )
+        delete sslServerThread;
     serverSSL->release();
 	server->trenne();
 	server->release();
@@ -79,20 +81,27 @@ void MainServer::runn()
 
 void MainServer::thread()
 {
-    SSLServer *sslServer = serverSSL;
-    int *cl = &clients;
     MainServer *ms = this;
-    AsynchronCall( [ sslServer, cl, ms ]()
+    if( sslServerThread )
+        delete sslServerThread;
+    sslServerThread = new AsynchronCall( [  ms ]()
     {
-        while( sslServer->isConnected() )
+        while( ms->serverSSL->isConnected() )
         {
-            SSLSKlient *klient = sslServer->getKlient();
+            SSLSKlient *klient = ms->serverSSL->getKlient();
+            if( ms->end && klient )
+            {
+                klient->trenne();
+                klient = klient->release();
+                Sleep( 1000 );
+                return;
+            }
             if( !klient )
                 continue;
             Framework::getThreadRegister()->cleanUpClosedThreads();
             MSKlientSSL *clHandle = new MSKlientSSL( klient, ms->getThis() );
             clHandle->start();
-            (*cl)++;
+            ms->clients++;
         }
     } );
 	while( server->isConnected() )

+ 2 - 0
MainServer/MainServer.h

@@ -5,6 +5,7 @@
 #include <Thread.h>
 #include <InitDatei.h>
 #include "Datenbank.h"
+#include <AsynchronCall.h>
 
 using namespace Framework;
 using namespace Network;
@@ -17,6 +18,7 @@ private:
     SSLServer *serverSSL;
 	InitDatei *dat;
 	MSDatenbank *db;
+    AsynchronCall *sslServerThread;
 	CRITICAL_SECTION cs;
 	int empfangen;
 	int gesendet;

+ 3 - 0
MainServer/main.cpp

@@ -6,6 +6,7 @@
 #include <Text.h>
 #include <Globals.h>
 #include <sys/resource.h>
+#include <Klient.h>
 
 int main()
 {
@@ -50,6 +51,8 @@ int main()
 
 	std::cout << "MS: Der Admin Server läuft. Startforgang beendet.\n";
 	mserver->runn();
+    SSLKlient exitClient;
+    exitClient.verbinde( (unsigned short)(int)*dat->zWert( "SSLPort" ), "127.0.0.1" );
 
 	mserver->ende();
 	mserver->release();