mirror of
https://github.com/minetest/minetest.git
synced 2025-03-06 20:48:40 +01:00
Stop ServerThread immediately on errors
This commit is contained in:
parent
9dd09d1056
commit
d0d7c11fe1
2 changed files with 14 additions and 2 deletions
|
@ -625,6 +625,11 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
|
||||||
ZoneScoped;
|
ZoneScoped;
|
||||||
auto framemarker = FrameMarker("Server::AsyncRunStep()-frame").started();
|
auto framemarker = FrameMarker("Server::AsyncRunStep()-frame").started();
|
||||||
|
|
||||||
|
if (!m_async_fatal_error.get().empty()) {
|
||||||
|
infostream << "Refusing server step in error state" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Send blocks to clients
|
// Send blocks to clients
|
||||||
SendBlocks(dtime);
|
SendBlocks(dtime);
|
||||||
|
@ -3854,6 +3859,14 @@ std::string Server::getBuiltinLuaPath()
|
||||||
return porting::path_share + DIR_DELIM + "builtin";
|
return porting::path_share + DIR_DELIM + "builtin";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Server::setAsyncFatalError(const std::string &error)
|
||||||
|
{
|
||||||
|
m_async_fatal_error.set(error);
|
||||||
|
// make sure server steps stop happening immediately
|
||||||
|
if (m_thread)
|
||||||
|
m_thread->stop();
|
||||||
|
}
|
||||||
|
|
||||||
// Not thread-safe.
|
// Not thread-safe.
|
||||||
void Server::addShutdownError(const ModError &e)
|
void Server::addShutdownError(const ModError &e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -344,8 +344,7 @@ public:
|
||||||
void setStepSettings(StepSettings spdata) { m_step_settings.store(spdata); }
|
void setStepSettings(StepSettings spdata) { m_step_settings.store(spdata); }
|
||||||
StepSettings getStepSettings() { return m_step_settings.load(); }
|
StepSettings getStepSettings() { return m_step_settings.load(); }
|
||||||
|
|
||||||
inline void setAsyncFatalError(const std::string &error)
|
void setAsyncFatalError(const std::string &error);
|
||||||
{ m_async_fatal_error.set(error); }
|
|
||||||
inline void setAsyncFatalError(const LuaError &e)
|
inline void setAsyncFatalError(const LuaError &e)
|
||||||
{
|
{
|
||||||
setAsyncFatalError(std::string("Lua: ") + e.what());
|
setAsyncFatalError(std::string("Lua: ") + e.what());
|
||||||
|
|
Loading…
Add table
Reference in a new issue