mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-17 11:28:16 +00:00
Reenabled handling of SIGHUP
This commit is contained in:
parent
084a7c279e
commit
de8f839da2
@ -124,16 +124,6 @@ static lg::log_domain log_config("config");
|
|||||||
#ifndef SIGHUP
|
#ifndef SIGHUP
|
||||||
#define SIGHUP 20
|
#define SIGHUP 20
|
||||||
#endif
|
#endif
|
||||||
/** @todo FIXME: should define SIGINT here too, but to what? */
|
|
||||||
|
|
||||||
static sig_atomic_t config_reload = 0;
|
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
static void reload_config(int signal) {
|
|
||||||
assert(signal == SIGHUP);
|
|
||||||
config_reload = 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void exit_sigint(int signal) {
|
static void exit_sigint(int signal) {
|
||||||
assert(signal == SIGINT);
|
assert(signal == SIGINT);
|
||||||
@ -453,7 +443,8 @@ server::server(int port, bool keep_alive, const std::string& config_file, size_t
|
|||||||
last_ping_(time(NULL)),
|
last_ping_(time(NULL)),
|
||||||
last_stats_(last_ping_),
|
last_stats_(last_ping_),
|
||||||
last_uh_clean_(last_ping_),
|
last_uh_clean_(last_ping_),
|
||||||
cmd_handlers_()
|
cmd_handlers_(),
|
||||||
|
sighup_(io_service_, SIGHUP)
|
||||||
{
|
{
|
||||||
boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), port);
|
boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), port);
|
||||||
acceptor_.open(endpoint.protocol());
|
acceptor_.open(endpoint.protocol());
|
||||||
@ -469,16 +460,23 @@ server::server(int port, bool keep_alive, const std::string& config_file, size_t
|
|||||||
load_config();
|
load_config();
|
||||||
ban_manager_.read();
|
ban_manager_.read();
|
||||||
|
|
||||||
setup_fifo();
|
sighup_.async_wait(boost::bind(&server::handle_sighup, this, _1, _2));
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
signal(SIGHUP, reload_config);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
signal(SIGINT, exit_sigint);
|
signal(SIGINT, exit_sigint);
|
||||||
signal(SIGTERM, exit_sigterm);
|
signal(SIGTERM, exit_sigterm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void server::handle_sighup(const boost::system::error_code& error, int) {
|
||||||
|
assert(!error);
|
||||||
|
|
||||||
|
WRN_SERVER << "SIGHUP caught, reloading config\n";
|
||||||
|
|
||||||
|
cfg_ = read_config();
|
||||||
|
load_config();
|
||||||
|
|
||||||
|
sighup_.async_wait(boost::bind(&server::handle_sighup, this, _1, _2));
|
||||||
|
}
|
||||||
|
|
||||||
void server::setup_fifo() {
|
void server::setup_fifo() {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
const int res = mkfifo(input_path_.c_str(),0660);
|
const int res = mkfifo(input_path_.c_str(),0660);
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include <boost/shared_array.hpp>
|
#include <boost/shared_array.hpp>
|
||||||
#include <boost/ptr_container/ptr_vector.hpp>
|
#include <boost/ptr_container/ptr_vector.hpp>
|
||||||
|
|
||||||
|
#include <boost/asio/signal_set.hpp>
|
||||||
|
|
||||||
class server
|
class server
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -223,6 +225,9 @@ private:
|
|||||||
void motd_handler(const std::string &, const std::string &, std::string &, std::ostringstream *);
|
void motd_handler(const std::string &, const std::string &, std::string &, std::ostringstream *);
|
||||||
void searchlog_handler(const std::string &, const std::string &, std::string &, std::ostringstream *);
|
void searchlog_handler(const std::string &, const std::string &, std::string &, std::ostringstream *);
|
||||||
void dul_handler(const std::string &, const std::string &, std::string &, std::ostringstream *);
|
void dul_handler(const std::string &, const std::string &, std::string &, std::ostringstream *);
|
||||||
|
|
||||||
|
boost::asio::signal_set sighup_;
|
||||||
|
void handle_sighup(const boost::system::error_code& error, int signal_number);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user