switched NetworkServerThread to new thread creation method, SSL is working

This commit is contained in:
Max-Wilhelm Bruker 2012-03-10 16:16:31 +01:00
parent 0719d4c6ed
commit decf1c04bd
6 changed files with 98 additions and 165 deletions

View file

@ -25,7 +25,7 @@
#include "server_room.h"
#include "serversocketinterface.h"
#include "serversocketthread.h"
#include "networkserverthread.h"
#include "networkserverinterface.h"
#include "server_logger.h"
#include "main.h"
#include "passwordhasher.h"
@ -50,8 +50,15 @@ void Servatrice_GameServer::incomingConnection(int socketDescriptor)
void Servatrice_NetworkServer::incomingConnection(int socketDescriptor)
{
NetworkServerThread *thread = new NetworkServerThread(socketDescriptor, server, cert, privateKey);
QThread *thread = new QThread;
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
NetworkServerInterface *interface = new NetworkServerInterface(socketDescriptor, cert, privateKey, server);
interface->moveToThread(thread);
connect(interface, SIGNAL(destroyed()), thread, SLOT(quit()));
thread->start();
QMetaObject::invokeMethod(interface, "initServer", Qt::QueuedConnection);
}
Servatrice::Servatrice(QSettings *_settings, QObject *parent)
@ -150,12 +157,15 @@ Servatrice::Servatrice(QSettings *_settings, QObject *parent)
continue;
}
NetworkServerThread *thread = new NetworkServerThread(prop.hostname, prop.address.toString(), prop.controlPort, prop.cert, this, cert, key);
thread->start();
QThread *thread = new QThread;
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
QMutex initMutex;
initMutex.lock();
thread->initWaitCondition.wait(&initMutex);
NetworkServerInterface *interface = new NetworkServerInterface(prop.hostname, prop.address.toString(), prop.controlPort, prop.cert, cert, key, this);
interface->moveToThread(thread);
connect(interface, SIGNAL(destroyed()), thread, SLOT(quit()));
thread->start();
QMetaObject::invokeMethod(interface, "initClient", Qt::BlockingQueuedConnection);
}
} } catch (QString error) {