Skip to content
Snippets Groups Projects
Commit b3b3d8a3 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Reduce locking

parent 261d0bc1
No related branches found
No related tags found
1 merge request!100Resolves #163 garbage segfault
Pipeline #13097 passed
This commit is part of merge request !100. Comments created here will be created in the context of that merge request.
...@@ -39,6 +39,8 @@ Universe::Universe() : ...@@ -39,6 +39,8 @@ Universe::Universe() :
reconnect_attempts_(50), reconnect_attempts_(50),
thread_(Universe::__start, this) { thread_(Universe::__start, this) {
_installBindings(); _installBindings();
LOG(WARNING) << "Deprecated Universe constructor";
} }
Universe::Universe(nlohmann::json &config) : Universe::Universe(nlohmann::json &config) :
...@@ -54,19 +56,20 @@ Universe::Universe(nlohmann::json &config) : ...@@ -54,19 +56,20 @@ Universe::Universe(nlohmann::json &config) :
_installBindings(); _installBindings();
LOG(INFO) << "SEND BUFFER SIZE = " << send_size_; // Add an idle timer job to garbage collect peer objects
// Note: Important to be a timer job to ensure no other timer jobs are
// using the object.
ftl::timer::add(ftl::timer::kTimerIdle10, [this](int64_t ts) { ftl::timer::add(ftl::timer::kTimerIdle10, [this](int64_t ts) {
if (garbage_.size() > 0) {
UNIQUE_LOCK(net_mutex_,lk); UNIQUE_LOCK(net_mutex_,lk);
if (ftl::pool.n_idle() == ftl::pool.size()) { if (ftl::pool.n_idle() == ftl::pool.size()) {
if (garbage_.size() > 0) LOG(INFO) << "Garbage collection"; if (garbage_.size() > 0) LOG(INFO) << "Garbage collection";
while (garbage_.size() > 0) { while (garbage_.size() > 0) {
// FIXME: There is possibly still something with a peer pointer
// that is causing this throw an exception sometimes?
delete garbage_.front(); delete garbage_.front();
garbage_.pop_front(); garbage_.pop_front();
} }
} }
}
return true; return true;
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment