mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 23:54:14 +02:00
leave the listen check but queue Application quit
This commit is contained in:
parent
34b3fb1c0c
commit
3e4a05a57b
1 changed files with 12 additions and 5 deletions
|
@ -20,7 +20,6 @@
|
||||||
#include "EmbeddedWebserverLogging.h"
|
#include "EmbeddedWebserverLogging.h"
|
||||||
#include "HTTPManager.h"
|
#include "HTTPManager.h"
|
||||||
|
|
||||||
const int SOCKET_ERROR_EXIT_CODE = 2;
|
|
||||||
const int SOCKET_CHECK_INTERVAL_IN_MS = 30000;
|
const int SOCKET_CHECK_INTERVAL_IN_MS = 30000;
|
||||||
|
|
||||||
HTTPManager::HTTPManager(quint16 port, const QString& documentRoot, HTTPRequestHandler* requestHandler, QObject* parent) :
|
HTTPManager::HTTPManager(quint16 port, const QString& documentRoot, HTTPRequestHandler* requestHandler, QObject* parent) :
|
||||||
|
@ -30,6 +29,7 @@ HTTPManager::HTTPManager(quint16 port, const QString& documentRoot, HTTPRequestH
|
||||||
_port(port)
|
_port(port)
|
||||||
{
|
{
|
||||||
bindSocket();
|
bindSocket();
|
||||||
|
|
||||||
_isListeningTimer = new QTimer(this);
|
_isListeningTimer = new QTimer(this);
|
||||||
connect(_isListeningTimer, &QTimer::timeout, this, &HTTPManager::isTcpServerListening);
|
connect(_isListeningTimer, &QTimer::timeout, this, &HTTPManager::isTcpServerListening);
|
||||||
_isListeningTimer->start(SOCKET_CHECK_INTERVAL_IN_MS);
|
_isListeningTimer->start(SOCKET_CHECK_INTERVAL_IN_MS);
|
||||||
|
@ -171,9 +171,16 @@ void HTTPManager::isTcpServerListening() {
|
||||||
|
|
||||||
bool HTTPManager::bindSocket() {
|
bool HTTPManager::bindSocket() {
|
||||||
qCDebug(embeddedwebserver) << "Attempting to bind TCP socket on port " << QString::number(_port);
|
qCDebug(embeddedwebserver) << "Attempting to bind TCP socket on port " << QString::number(_port);
|
||||||
if (!listen(QHostAddress::Any, _port)) {
|
|
||||||
|
if (listen(QHostAddress::AnyIPv4, _port)) {
|
||||||
|
qCDebug(embeddedwebserver) << "TCP socket is listening on" << serverAddress() << "and port" << serverPort();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
qCritical() << "Failed to open HTTP server socket:" << errorString() << " can't continue";
|
qCritical() << "Failed to open HTTP server socket:" << errorString() << " can't continue";
|
||||||
QCoreApplication::exit(SOCKET_ERROR_EXIT_CODE);
|
QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection);
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue