Skip to content

Commit 2d22bb9

Browse files
author
=
committed
added local copies of builder in invokeMethod for thread safety
1 parent 6aae8ea commit 2d22bb9

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/communication/RpcClient.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,17 @@ RpcClient::InvokeHandle RpcClient::invokeMethod(v1::UMessage&& request,
208208
RpcClient::InvokeHandle RpcClient::invokeMethod(
209209
const v1::UUri& method, datamodel::builder::Payload&& payload,
210210
Callback&& callback) {
211-
return invokeMethod(builder_.withMethod(method).build(std::move(payload)),
211+
//makes a local copy of the builder to make this call thread safe
212+
auto local_builder = builder_;
213+
return invokeMethod(local_builder.withMethod(method).build(std::move(payload)),
212214
std::move(callback));
213215
}
214216

215217
RpcClient::InvokeHandle RpcClient::invokeMethod(const v1::UUri& method,
216218
Callback&& callback) {
217-
return invokeMethod(builder_.withMethod(method).build(),
219+
//makes a local copy of the builder to make this call thread safe
220+
auto local_builder = builder_;
221+
return invokeMethod(local_builder.withMethod(method).build(),
218222
std::move(callback));
219223
}
220224

0 commit comments

Comments
 (0)