Skip to content

Commit fe96054

Browse files
committed
Bug Fix: Async Method (UA_Server_call) holds serviceMutex during method callback so blocks main loop
1 parent 403f462 commit fe96054

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/server/ua_services_method.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,15 @@ callWithMethodAndObject(UA_Server *server, UA_Session *session,
265265

266266
/* Verify access rights */
267267
UA_Boolean executable = method->executable;
268-
if(session != &server->adminSession) {
268+
if (executable && session != &server->adminSession) {
269+
UA_LOCK_ASSERT(&server->serviceMutex, 1);
270+
UA_UNLOCK(&server->serviceMutex);
269271
executable = executable && server->config.accessControl.
270272
getUserExecutableOnObject(server, &server->config.accessControl,
271273
&session->sessionId, session->sessionHandle,
272274
&request->methodId, method->head.context,
273275
&request->objectId, object->head.context);
276+
UA_LOCK(&server->serviceMutex);
274277
}
275278

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

349352
/* Call the method */
353+
UA_LOCK_ASSERT(&server->serviceMutex, 1);
354+
UA_UNLOCK(&server->serviceMutex); // It may be ASYNC (in other thread)
350355
result->statusCode = method->method(server, &session->sessionId, session->sessionHandle,
351356
&method->head.nodeId, method->head.context,
352357
&object->head.nodeId, object->head.context,
353358
request->inputArgumentsSize, mutableInputArgs,
354359
result->outputArgumentsSize, result->outputArguments);
360+
UA_LOCK(&server->serviceMutex);
355361
/* TODO: Verify Output matches the argument definition */
356362
}
357363

0 commit comments

Comments
 (0)