Make Server outlive buffer manager

Fixes crashes when trying to access the server to get the session
on hooks run during destruction of other managers.

Fixes #1622
This commit is contained in:
Maxime Coste 2017-10-10 08:04:19 +08:00
parent 80d2506c34
commit d1b9c24afc

View File

@ -550,8 +550,10 @@ int run_server(StringView session, StringView server_init,
set_signal_handler(SIGTERM, [](int) { terminate = true; }); set_signal_handler(SIGTERM, [](int) { terminate = true; });
} }
StringRegistry string_registry;
EventManager event_manager; EventManager event_manager;
Server server{session.empty() ? to_string(getpid()) : session.str()};
StringRegistry string_registry;
GlobalScope global_scope; GlobalScope global_scope;
ShellManager shell_manager; ShellManager shell_manager;
CommandManager command_manager; CommandManager command_manager;
@ -574,8 +576,6 @@ int run_server(StringView session, StringView server_init,
GlobalScope::instance().options().get_local_option("readonly").set<bool>(flags & ServerFlags::ReadOnly); GlobalScope::instance().options().get_local_option("readonly").set<bool>(flags & ServerFlags::ReadOnly);
Server server{session.empty() ? to_string(getpid()) : session.str()};
bool startup_error = false; bool startup_error = false;
if (not (flags & ServerFlags::IgnoreKakrc)) try if (not (flags & ServerFlags::IgnoreKakrc)) try
{ {