mirror of https://github.com/kiwix/libkiwix.git
Revert "Server can be started on a random free port"
This change failed to build under the following platforms due to an older version of libmicrohttpd missing support for the MHD_DAEMON_INFO_BIND_PORT query: - Linux (native_dyn) - Linux (win32_dyn)
This commit is contained in:
parent
b0f65a02f2
commit
9a893a854e
|
@ -53,7 +53,6 @@ namespace kiwix
|
||||||
void setRoot(const std::string& root);
|
void setRoot(const std::string& root);
|
||||||
void setAddress(const std::string& addr) { m_addr = addr; }
|
void setAddress(const std::string& addr) { m_addr = addr; }
|
||||||
void setPort(int port) { m_port = port; }
|
void setPort(int port) { m_port = port; }
|
||||||
int getPort() const { return m_port; }
|
|
||||||
void setNbThreads(int threads) { m_nbThreads = threads; }
|
void setNbThreads(int threads) { m_nbThreads = threads; }
|
||||||
void setVerbose(bool verbose) { m_verbose = verbose; }
|
void setVerbose(bool verbose) { m_verbose = verbose; }
|
||||||
void setTaskbar(bool withTaskbar, bool withLibraryButton)
|
void setTaskbar(bool withTaskbar, bool withLibraryButton)
|
||||||
|
|
|
@ -109,8 +109,6 @@ class InternalServer {
|
||||||
bool start();
|
bool start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
int getPort() const { return m_port; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Response handle_request(const RequestContext& request);
|
Response handle_request(const RequestContext& request);
|
||||||
Response build_500(const std::string& msg);
|
Response build_500(const std::string& msg);
|
||||||
|
@ -164,9 +162,7 @@ bool Server::start() {
|
||||||
m_withTaskbar,
|
m_withTaskbar,
|
||||||
m_withLibraryButton,
|
m_withLibraryButton,
|
||||||
m_blockExternalLinks));
|
m_blockExternalLinks));
|
||||||
auto s = mp_server->start();
|
return mp_server->start();
|
||||||
m_port = mp_server->getPort();
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::stop() {
|
void Server::stop() {
|
||||||
|
@ -249,8 +245,6 @@ bool InternalServer::start() {
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (m_port == 0)
|
|
||||||
m_port = MHD_get_daemon_info(mp_daemon, MHD_DAEMON_INFO_BIND_PORT)->port;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,6 @@ ZimFileServer::ZimFileServer(int serverPort, std::string zimpath)
|
||||||
|
|
||||||
if ( !server->start() )
|
if ( !server->start() )
|
||||||
throw std::runtime_error("ZimFileServer failed to start");
|
throw std::runtime_error("ZimFileServer failed to start");
|
||||||
if ( serverPort == 0 )
|
|
||||||
serverPort = server->getPort();
|
|
||||||
|
|
||||||
client.reset(new httplib::Client(address, serverPort));
|
client.reset(new httplib::Client(address, serverPort));
|
||||||
}
|
}
|
||||||
|
@ -66,7 +64,7 @@ class ServerTest : public ::testing::Test
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<ZimFileServer> zfs1_;
|
std::unique_ptr<ZimFileServer> zfs1_;
|
||||||
|
|
||||||
const int PORT = 0;
|
const int PORT = 8001;
|
||||||
const std::string ZIMFILE = "./test/zimfile.zim";
|
const std::string ZIMFILE = "./test/zimfile.zim";
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in New Issue