wesnothd: Only reset the commands FIFO stream when reloading if needed

May or may not fix the issue noted in commit
62eb55a5a712b3e2157cf7fc0bb12873c4f0a574 regarding the SIGHUP handler,
which is in charge of scheduling load_config() to run. Rather
unfortunately, I'm unable to reproduce the issue on my own machine, so
I'll have to take this to production and test it live.
This commit is contained in:
Ignacio R. Morelle 2014-06-24 20:47:58 -04:00
parent 46815ee008
commit 6629fdf64e
2 changed files with 7 additions and 2 deletions

View File

@ -333,6 +333,7 @@ server::server(int port, const std::string& config_file, size_t min_threads,
not_logged_in_(),
rooms_(players_),
input_(),
input_path_(),
config_file_(config_file),
cfg_(read_config()),
accepted_versions_(),
@ -499,8 +500,11 @@ void server::load_config() {
# endif
#endif
const std::string fifo_path = (cfg_["fifo_path"].empty() ? std::string(FIFODIR) + "/socket" : std::string(cfg_["fifo_path"]));
input_.reset();
input_.reset(new input_stream(fifo_path));
// Reset (replace) the input stream only if the FIFO path changed.
if(fifo_path != input_path_) {
input_.reset(new input_stream(fifo_path));
}
input_path_ = fifo_path;
save_replays_ = cfg_["save_replays"].to_bool();
replay_save_path_ = cfg_["replay_save_path"].str();

View File

@ -106,6 +106,7 @@ private:
/** server socket/fifo. */
boost::scoped_ptr<input_stream> input_;
std::string input_path_;
const std::string config_file_;
config cfg_;