Skip to content

Commit

Permalink
Fix reference to local binding in lambda capture (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
srmainwaring authored Jun 29, 2023
1 parent 3a10798 commit 9698d56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions core/src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,7 @@ bool Config::load_middlewares(
*/
for (const auto& [mw_name, mw_config] : middlewares)
{
const auto& ref_mw_name = mw_name;
const std::string& middleware_type = mw_config.type;

logger << utils::Logger::Level::DEBUG
Expand Down Expand Up @@ -1250,10 +1251,10 @@ bool Config::load_middlewares(
// Check if another middleware relies on types builtin or dynamically loaded by the middleware but not
// explicit in the configuration file
if ( middlewares.end() ==
std::find_if(middlewares.begin(), middlewares.end(), [&mw_name](const Entry& mw)
std::find_if(middlewares.begin(), middlewares.end(), [&ref_mw_name](const Entry& mw)
{
auto& from = mw.second.types_from;
return mw_name != mw.first && std::find(from.begin(), from.end(), mw_name) != from.end();
return ref_mw_name != mw.first && std::find(from.begin(), from.end(), ref_mw_name) != from.end();
}))
{
logger << utils::Logger::Level::ERROR
Expand Down
6 changes: 4 additions & 2 deletions core/src/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,23 @@ class InstanceHandle::Implementation
* For each systemhandle, creates a working thread that will check that the
* SystemHandle instance is alive and calls spin_once() to execute pending work.
*/
const auto& ref_mw_name = mw_name;
const auto& ref_systemhandle_info = systemhandle_info;
auto runner = [&]()
{
++_active_middlewares;

while (!interrupted && !_quit)
{
const bool okay = systemhandle_info.handle->spin_once();
const bool okay = ref_systemhandle_info.handle->spin_once();

if (!okay)
{
_quit = true;
_return_code = 1;
_logger << utils::Logger::Level::ERROR
<< "Runtime Error: SystemHandle of middleware named '"
<< mw_name
<< ref_mw_name
<< "' has experienced a failure! We will now quit."
<< std::endl;
}
Expand Down

0 comments on commit 9698d56

Please sign in to comment.