Skip to content

Commit 20cb0c5

Browse files
authored
Fix Node Registration (#481)
* Change the lambda capture to copy id_type and event_type by value to prevent them from being out of scope in the event task when the condition.wait returns early due to a shutdown * Fix possibly dangling reference to a temporary warning * Remove mis-leading comment * model.notify()/condition.notify_all() should be part of the request chain
1 parent 0059a0b commit 20cb0c5

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

Development/cmake/NmosCppLibraries.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ target_compile_definitions(
3030
slog INTERFACE
3131
SLOG_STATIC
3232
SLOG_LOGGING_SEVERITY=${SLOG_LOGGING_SEVERITY}
33-
BST_THREAD_BOOST # provide bst::chrono::duration, etc. using either std:: or boost:: symbols
33+
BST_THREAD_BOOST
3434
)
3535
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
3636
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)

Development/nmos-cpp-node/node_implementation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ void node_implementation_init(nmos::node_model& model, nmos::experimental::contr
14621462

14631463
utility::ostringstream_t role;
14641464
role << U("sender-monitor-") << ++count;
1465-
const auto& sender = nmos::find_resource(model.node_resources, sender_id);
1465+
const auto sender = nmos::find_resource(model.node_resources, sender_id);
14661466
auto sender_monitor = nmos::make_sender_monitor(++oid, true, sender_monitors_block_oid, role.str(), nmos::fields::label(sender->data), nmos::fields::description(sender->data), value_of({ { nmos::nc::details::make_touchpoint_nmos({nmos::ncp_touchpoint_resource_types::sender, sender_id}) } }));
14671467
// optionally indicate dependencies within the device model
14681468
nmos::set_object_dependency_paths(sender_monitor, { {U("root"), U("sender-monitors")} });

Development/nmos/authorization_operation.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,10 +1271,8 @@ namespace nmos
12711271

12721272
authorization_service_error = true;
12731273
}
1274-
});
1275-
request.then([&]
1276-
{
1277-
condition.notify_all();
1274+
1275+
model.notify();
12781276
});
12791277

12801278
// wait for the request because interactions with the Authorization API endpoint must be sequential
@@ -1853,10 +1851,8 @@ namespace nmos
18531851

18541852
authorization_service_error = true;
18551853
}
1856-
});
1857-
request.then([&]
1858-
{
1859-
condition.notify_all();
1854+
1855+
model.notify();
18601856
});
18611857

18621858
// wait for the request because interactions with the Authorization API endpoint must be sequential
@@ -1998,10 +1994,8 @@ namespace nmos
19981994

19991995
authorization_service_error = true;
20001996
}
2001-
});
2002-
request.then([&]
2003-
{
2004-
condition.notify_all();
1997+
1998+
model.notify();
20051999
});
20062000

20072001
// wait for the request because interactions with the Authorization API endpoint must be sequential

Development/nmos/node_behaviour.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ namespace nmos
10191019
}
10201020
}
10211021

1022-
request = details::request_registration(*registration_client, events.at(0), gate, token).then([&](pplx::task<void> finally)
1022+
request = details::request_registration(*registration_client, events.at(0), gate, token).then([&, id_type, event_type](pplx::task<void> finally)
10231023
{
10241024
auto lock = model.write_lock(); // in order to update local state
10251025

0 commit comments

Comments
 (0)