提交 ce11662a 编写于 作者: N Nikolai Kochetov

Fix build.

上级 42a0ad77
......@@ -228,12 +228,8 @@ int Server::main(const std::vector<std::string> & /*args*/)
* settings, available functions, data types, aggregate functions, databases...
*/
auto shared_context = Context::createShared();
auto global_context_holder = Context::createGlobal(shared_context.get());
/// Global context is owned by Server only. Is is assumed that noboby can access context after server was stopped.
/// To check it, set global_context to nullptr at the and, to get explicit segfault if it is not true.
global_context = &global_context_holder;
SCOPE_EXIT(global_context = nullptr);
auto global_context = std::make_unique<Context>(Context::createGlobal(shared_context.get()));
global_context_ptr = global_context.get();
global_context->makeGlobalContext();
global_context->setApplicationType(Context::ApplicationType::SERVER);
......@@ -331,7 +327,9 @@ int Server::main(const std::vector<std::string> & /*args*/)
/** Explicitly destroy Context. It is more convenient than in destructor of Server, because logger is still available.
* At this moment, no one could own shared part of Context.
*/
global_context_ptr = nullptr;
global_context.reset();
shared_context.reset();
LOG_DEBUG(log, "Destroyed global context.");
});
......
......@@ -35,7 +35,7 @@ public:
Context & context() const override
{
return *global_context;
return *global_context_ptr;
}
bool isCancelled() const override
......@@ -56,7 +56,7 @@ protected:
std::string getDefaultCorePath() const override;
private:
Context * global_context = nullptr;
Context * global_context_ptr = nullptr;
};
}
......@@ -446,6 +446,8 @@ SharedContextHolder::~SharedContextHolder() = default;
SharedContextHolder::SharedContextHolder(std::unique_ptr<ContextShared> shared_context)
: shared(std::move(shared_context)) {}
void SharedContextHolder::reset() { shared.reset(); }
Context Context::createGlobal(ContextShared * shared)
{
......
......@@ -137,7 +137,7 @@ struct SharedContextHolder
SharedContextHolder(SharedContextHolder &&) noexcept;
ContextShared * get() const { return shared.get(); }
void reset();
private:
std::unique_ptr<ContextShared> shared;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册