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;
|
||||
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
|
||||
SendBlocks(dtime);
|
||||
|
@ -3854,6 +3859,14 @@ std::string Server::getBuiltinLuaPath()
|
|||
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.
|
||||
void Server::addShutdownError(const ModError &e)
|
||||
{
|
||||
|
|
|
@ -344,8 +344,7 @@ public:
|
|||
void setStepSettings(StepSettings spdata) { m_step_settings.store(spdata); }
|
||||
StepSettings getStepSettings() { return m_step_settings.load(); }
|
||||
|
||||
inline void setAsyncFatalError(const std::string &error)
|
||||
{ m_async_fatal_error.set(error); }
|
||||
void setAsyncFatalError(const std::string &error);
|
||||
inline void setAsyncFatalError(const LuaError &e)
|
||||
{
|
||||
setAsyncFatalError(std::string("Lua: ") + e.what());
|
||||
|
|
Loading…
Add table
Reference in a new issue