mirror of
https://github.com/lubosz/overte.git
synced 2025-04-12 17:32:30 +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 "HTTPManager.h"
|
||||
|
||||
const int SOCKET_ERROR_EXIT_CODE = 2;
|
||||
const int SOCKET_CHECK_INTERVAL_IN_MS = 30000;
|
||||
|
||||
HTTPManager::HTTPManager(quint16 port, const QString& documentRoot, HTTPRequestHandler* requestHandler, QObject* parent) :
|
||||
|
@ -172,15 +173,18 @@ void HTTPManager::isTcpServerListening() {
|
|||
bool HTTPManager::bindSocket() {
|
||||
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();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void HTTPManager::queuedExit() {
|
||||
QCoreApplication::exit(SOCKET_ERROR_EXIT_CODE);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
|
||||
private slots:
|
||||
void isTcpServerListening();
|
||||
void queuedExit();
|
||||
|
||||
private:
|
||||
bool bindSocket();
|
||||
|
|
Loading…
Reference in a new issue