If we dynamically allocate a HTTP port, then attempt to reuse that port when Cantata restarts

This commit is contained in:
craig.p.drummond
2013-05-01 07:03:55 +00:00
committed by craig.p.drummond
parent 63ff21f740
commit 7230782891
6 changed files with 216 additions and 180 deletions

View File

@@ -66,6 +66,7 @@ bool HttpServer::readConfig()
{
QString addr=Settings::self()->httpAddress();
quint16 port=Settings::self()->httpPort();
quint16 prevPort=Settings::self()->httpAllocatedPort();
if (socket && socket->isListening() && port==socket->serverPort() && addr==socket->configuredAddress() && Settings::self()->enableHttp()) {
return true;
@@ -84,7 +85,10 @@ bool HttpServer::readConfig()
if (Settings::self()->enableHttp()) {
thread=new QThread(0);
socket=new HttpSocket(addr, port);
socket=new HttpSocket(addr, port, prevPort);
if (socket->serverPort()!=port) {
Settings::self()->saveHttpAllocatedPort(socket->serverPort());
}
socket->moveToThread(thread);
thread->start();
return socket->isListening();