mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 01:47:31 +02:00
exit with a code to indicate error
This commit is contained in:
parent
3e4a05a57b
commit
0fbbfb77d1
2 changed files with 8 additions and 3 deletions
|
@ -20,6 +20,7 @@
|
||||||
#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) :
|
||||||
|
@ -172,15 +173,18 @@ 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::AnyIPv4, _port)) {
|
if (false) {
|
||||||
qCDebug(embeddedwebserver) << "TCP socket is listening on" << serverAddress() << "and port" << serverPort();
|
qCDebug(embeddedwebserver) << "TCP socket is listening on" << serverAddress() << "and port" << serverPort();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "Failed to open HTTP server socket:" << errorString() << " can't continue";
|
qCritical() << "Failed to open HTTP server socket:" << errorString() << " can't continue";
|
||||||
QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "queuedExit", Qt::QueuedConnection);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HTTPManager::queuedExit() {
|
||||||
|
QCoreApplication::exit(SOCKET_ERROR_EXIT_CODE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void isTcpServerListening();
|
void isTcpServerListening();
|
||||||
|
void queuedExit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool bindSocket();
|
bool bindSocket();
|
||||||
|
|
Loading…
Reference in a new issue