Skip to content

Commit abf1885

Browse files
fix: quick handling invoke message
adds thread safety. With a lot of threads, the id was generated in not thread safe manner the id generation was moved under the mutex - it is the only place where it is generated. This way it is unique now.
1 parent 3fcf930 commit abf1885

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/olink/clientnode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ void ClientNode::invokeRemote(const std::string& methodId, const nlohmann::json&
4949
{
5050
static const std::string invokeRemoteLog = "ClientNode.invokeRemote: ";
5151
emitLog(LogLevel::Info, invokeRemoteLog, methodId);
52-
int requestId = nextRequestId();
5352
std::unique_lock<std::mutex> lock(m_pendingInvokesMutex);
53+
int requestId = nextRequestId();
5454
m_invokesPending[requestId] = func;
5555
lock.unlock();
5656
nlohmann::json msg = Protocol::invokeMessage(requestId, methodId, args);

0 commit comments

Comments
 (0)