mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
Revert "force the HTTPManager to listen on IPv4"
This reverts commit 220ad189a0
.
This commit is contained in:
parent
220ad189a0
commit
34b3fb1c0c
2 changed files with 26 additions and 8 deletions
|
@ -29,14 +29,10 @@ HTTPManager::HTTPManager(quint16 port, const QString& documentRoot, HTTPRequestH
|
||||||
_requestHandler(requestHandler),
|
_requestHandler(requestHandler),
|
||||||
_port(port)
|
_port(port)
|
||||||
{
|
{
|
||||||
qCDebug(embeddedwebserver) << "Attempting to bind TCP socket on port " << QString::number(_port);
|
bindSocket();
|
||||||
|
_isListeningTimer = new QTimer(this);
|
||||||
if (listen(QHostAddress::AnyIPv4, _port)) {
|
connect(_isListeningTimer, &QTimer::timeout, this, &HTTPManager::isTcpServerListening);
|
||||||
qCDebug(embeddedwebserver) << "TCP socket is listening on" << serverAddress() << "and port" << serverPort();
|
_isListeningTimer->start(SOCKET_CHECK_INTERVAL_IN_MS);
|
||||||
} else {
|
|
||||||
qCritical() << "Failed to open HTTP server socket:" << errorString() << " - forcing exit.";
|
|
||||||
QCoreApplication::exit(SOCKET_ERROR_EXIT_CODE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTTPManager::incomingConnection(qintptr socketDescriptor) {
|
void HTTPManager::incomingConnection(qintptr socketDescriptor) {
|
||||||
|
@ -166,3 +162,18 @@ bool HTTPManager::requestHandledByRequestHandler(HTTPConnection* connection, con
|
||||||
return _requestHandler && _requestHandler->handleHTTPRequest(connection, url);
|
return _requestHandler && _requestHandler->handleHTTPRequest(connection, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HTTPManager::isTcpServerListening() {
|
||||||
|
if (!isListening()) {
|
||||||
|
qCWarning(embeddedwebserver) << "Socket on port " << QString::number(_port) << " is no longer listening";
|
||||||
|
bindSocket();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HTTPManager::bindSocket() {
|
||||||
|
qCDebug(embeddedwebserver) << "Attempting to bind TCP socket on port " << QString::number(_port);
|
||||||
|
if (!listen(QHostAddress::Any, _port)) {
|
||||||
|
qCritical() << "Failed to open HTTP server socket:" << errorString() << " can't continue";
|
||||||
|
QCoreApplication::exit(SOCKET_ERROR_EXIT_CODE);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -37,6 +37,12 @@ public:
|
||||||
|
|
||||||
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false);
|
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void isTcpServerListening();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool bindSocket();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Accepts all pending connections
|
/// Accepts all pending connections
|
||||||
virtual void incomingConnection(qintptr socketDescriptor);
|
virtual void incomingConnection(qintptr socketDescriptor);
|
||||||
|
@ -44,6 +50,7 @@ protected:
|
||||||
|
|
||||||
QString _documentRoot;
|
QString _documentRoot;
|
||||||
HTTPRequestHandler* _requestHandler;
|
HTTPRequestHandler* _requestHandler;
|
||||||
|
QTimer* _isListeningTimer;
|
||||||
const quint16 _port;
|
const quint16 _port;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue