mirror of https://github.com/kiwix/libkiwix.git
Add a `Server::isRunning` to know if the server is running or not.
This commit is contained in:
parent
7d83127d58
commit
1fcc2ad709
|
@ -117,6 +117,11 @@ namespace kiwix
|
||||||
*/
|
*/
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell if the server is running or not.
|
||||||
|
*/
|
||||||
|
bool isRunning();
|
||||||
|
|
||||||
int getPort();
|
int getPort();
|
||||||
std::string getAddress();
|
std::string getAddress();
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,13 @@ void Server::stop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Server::isRunning() {
|
||||||
|
if (!mp_server) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return mp_server->isRunning();
|
||||||
|
}
|
||||||
|
|
||||||
int Server::getPort()
|
int Server::getPort()
|
||||||
{
|
{
|
||||||
return mp_server->getPort();
|
return mp_server->getPort();
|
||||||
|
|
|
@ -415,8 +415,13 @@ bool InternalServer::start() {
|
||||||
void InternalServer::stop()
|
void InternalServer::stop()
|
||||||
{
|
{
|
||||||
MHD_stop_daemon(mp_daemon);
|
MHD_stop_daemon(mp_daemon);
|
||||||
|
mp_daemon = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InternalServer::isRunning() const
|
||||||
|
{
|
||||||
|
return mp_daemon != nullptr;
|
||||||
|
}
|
||||||
static MHD_Result staticHandlerCallback(void* cls,
|
static MHD_Result staticHandlerCallback(void* cls,
|
||||||
struct MHD_Connection* connection,
|
struct MHD_Connection* connection,
|
||||||
const char* url,
|
const char* url,
|
||||||
|
|
|
@ -104,6 +104,7 @@ class InternalServer : Server::Configuration {
|
||||||
void** cont_cls);
|
void** cont_cls);
|
||||||
bool start();
|
bool start();
|
||||||
void stop();
|
void stop();
|
||||||
|
bool isRunning() const;
|
||||||
std::string getAddress() { return m_addr; }
|
std::string getAddress() { return m_addr; }
|
||||||
int getPort() { return m_port; }
|
int getPort() { return m_port; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue