diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-06-17 12:04:12 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-06-17 12:04:12 +0200 |
commit | 925afed1b90871a52fb19f0ee2cb99cd26a53bae (patch) | |
tree | be77dd198b7725a3709f2a387b3094b0bfcc547f | |
parent | cb43342a295c6ab01d3895dd4bf21af60b76adaa (diff) |
Don't exit on rehash if the pid file cannot be written
-rw-r--r-- | include/inspircd.h | 3 | ||||
-rw-r--r-- | include/modules.h | 2 | ||||
-rw-r--r-- | src/configreader.cpp | 2 | ||||
-rw-r--r-- | src/inspircd.cpp | 12 |
4 files changed, 11 insertions, 8 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index e2eaf8292..78348ed54 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -779,9 +779,10 @@ class CoreExport InspIRCd /** Attempt to write the process id to a given file * @param filename The PID file to attempt to write to + * @param exitonfail If true and the PID fail cannot be written log to stdout and exit, otherwise only log on failure * @return This function may bail if the file cannot be written */ - void WritePID(const std::string &filename); + void WritePID(const std::string& filename, bool exitonfail = true); /** This constructor initialises all the subsystems and reads the config file. * @param argc The argument count passed to main() diff --git a/include/modules.h b/include/modules.h index 9857012fc..4d4d0871f 100644 --- a/include/modules.h +++ b/include/modules.h @@ -116,7 +116,7 @@ struct ModResult { * and numerical comparisons in preprocessor macros if they wish to support * multiple versions of InspIRCd in one file. */ -#define INSPIRCD_VERSION_API 9 +#define INSPIRCD_VERSION_API 10 /** * This #define allows us to call a method in all diff --git a/src/configreader.cpp b/src/configreader.cpp index 5b298ddd8..301db14e8 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -729,7 +729,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid) // write once here, to try it out and make sure its ok if (valid) - ServerInstance->WritePID(this->PID); + ServerInstance->WritePID(this->PID, !old); if (old && valid) { diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 656be220f..0fa90fca5 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -294,7 +294,7 @@ bool InspIRCd::DaemonSeed() #endif } -void InspIRCd::WritePID(const std::string &filename) +void InspIRCd::WritePID(const std::string& filename, bool exitonfail) { #ifndef _WIN32 std::string fname(filename); @@ -307,10 +307,12 @@ void InspIRCd::WritePID(const std::string &filename) outfile.close(); } else - { - std::cout << "Failed to write PID-file '" << fname << "', exiting." << std::endl; - this->Logs->Log("STARTUP",DEFAULT,"Failed to write PID-file '%s', exiting.",fname.c_str()); - Exit(EXIT_STATUS_PID); + {
+ if (exitonfail)
+ std::cout << "Failed to write PID-file '" << fname << "', exiting." << std::endl; + this->Logs->Log("STARTUP",DEFAULT,"Failed to write PID-file '%s'%s",fname.c_str(), (exitonfail ? ", exiting." : ""));
+ if (exitonfail) + Exit(EXIT_STATUS_PID);
} #endif } |