Skip to content

Commit

Permalink
Bug Fix: Async Method (UA_Server_call) holds serviceMutex during meth…
Browse files Browse the repository at this point in the history
…od callback so blocks main loop
  • Loading branch information
beranat committed Jan 27, 2025
1 parent 403f462 commit 798427f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/server/ua_services_method.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,15 @@ callWithMethodAndObject(UA_Server *server, UA_Session *session,

/* Verify access rights */
UA_Boolean executable = method->executable;
if(session != &server->adminSession) {
if (executable && session != &server->adminSession) {
UA_LOCK_ASSERT(&server->serviceMutex, 1);
UA_UNLOCK(&server->serviceMutex);
executable = executable && server->config.accessControl.
getUserExecutableOnObject(server, &server->config.accessControl,
&session->sessionId, session->sessionHandle,
&request->methodId, method->head.context,
&request->objectId, object->head.context);
UA_LOCK(&server->serviceMutex);
}

if(!executable) {
Expand Down Expand Up @@ -347,11 +350,14 @@ callWithMethodAndObject(UA_Server *server, UA_Session *session,
UA_NODESTORE_RELEASE(server, (const UA_Node*)outputArguments);

/* Call the method */
UA_LOCK_ASSERT(&server->serviceMutex, 1);
UA_UNLOCK(&server->serviceMutex); // It may be ASYNC (in other thread)
result->statusCode = method->method(server, &session->sessionId, session->sessionHandle,
&method->head.nodeId, method->head.context,
&object->head.nodeId, object->head.context,
request->inputArgumentsSize, mutableInputArgs,
result->outputArgumentsSize, result->outputArguments);
UA_LOCK(&server->serviceMutex);
/* TODO: Verify Output matches the argument definition */
}

Expand Down

0 comments on commit 798427f

Please sign in to comment.