Fix the cycle-referenced caused memory leak by shared_ptr used, this issue is
recognized by valgrind memcheck tool.
This commit is contained in:
parent
90c91783fd
commit
4dd2ae389a
3 changed files with 11 additions and 8 deletions
|
|
@ -100,7 +100,7 @@ protected:
|
|||
* @brief Traps the specified signals for the entire process.
|
||||
*/
|
||||
CORE_POSIX_DLL_PUBLIC
|
||||
std::shared_ptr<SignalTrap> trap_signals_for_process(
|
||||
SignalTrap* trap_signals_for_process(
|
||||
std::initializer_list<core::posix::Signal> blocked_signals);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -203,12 +203,10 @@ private:
|
|||
};
|
||||
}
|
||||
|
||||
std::shared_ptr<core::posix::SignalTrap> core::posix::trap_signals_for_process(
|
||||
std::initializer_list<core::posix::Signal> blocked_signals)
|
||||
core::posix::SignalTrap* core::posix::trap_signals_for_process(
|
||||
std::initializer_list<core::posix::Signal> blocked_signals)
|
||||
{
|
||||
return std::make_shared<impl::SignalTrap>(
|
||||
impl::SignalTrap::Scope::process,
|
||||
blocked_signals);
|
||||
return new impl::SignalTrap(impl::SignalTrap::Scope::process, blocked_signals);
|
||||
}
|
||||
|
||||
std::shared_ptr<core::posix::SignalTrap> core::posix::trap_signals_for_all_subsequent_threads(
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ anbox::cmds::SessionManager::SessionManager()
|
|||
use_system_dbus_));
|
||||
|
||||
action([this](const cli::Command::Context &) {
|
||||
auto trap = core::posix::trap_signals_for_process(
|
||||
core::posix::SignalTrap* trap = core::posix::trap_signals_for_process(
|
||||
{core::posix::Signal::sig_term, core::posix::Signal::sig_int});
|
||||
trap->signal_raised().connect([trap](const core::posix::Signal &signal) {
|
||||
INFO("Signal %i received. Good night.", static_cast<int>(signal));
|
||||
|
|
@ -139,11 +139,13 @@ anbox::cmds::SessionManager::SessionManager()
|
|||
});
|
||||
|
||||
if (standalone_ && !experimental_) {
|
||||
delete trap;
|
||||
ERROR("Experimental features selected, but --experimental flag not set");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!fs::exists("/dev/binder") || !fs::exists("/dev/ashmem")) {
|
||||
delete trap;
|
||||
ERROR("Failed to start as either binder or ashmem kernel drivers are not loaded");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
@ -176,8 +178,10 @@ anbox::cmds::SessionManager::SessionManager()
|
|||
input_manager,
|
||||
display_frame,
|
||||
single_window_);
|
||||
if (!platform)
|
||||
if (!platform) {
|
||||
delete trap;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
auto app_db = std::make_shared<application::Database>();
|
||||
|
||||
|
|
@ -283,6 +287,7 @@ anbox::cmds::SessionManager::SessionManager()
|
|||
|
||||
rt->stop();
|
||||
|
||||
delete trap;
|
||||
return EXIT_SUCCESS;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue