|
@@ -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() )
|