Skip to content

Commit

Permalink
fix(server): Add required locks to readSessionDiagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfr committed Feb 20, 2024
1 parent 16a182e commit 5953dd2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/server/ua_server_ns0_diagnostics.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,22 @@ readSessionDiagnostics(UA_Server *server,
const UA_NodeId *nodeId, void *nodeContext,
UA_Boolean sourceTimestamp,
const UA_NumericRange *range, UA_DataValue *value) {
UA_LOCK(&server->serviceMutex);

/* Get the Session */
UA_Session *session = UA_Server_getSessionById(server, sessionId);
if(!session)
if(!session) {
UA_UNLOCK(&server->serviceMutex);
return UA_STATUSCODE_BADINTERNALERROR;
}

/* Read the BrowseName */
UA_QualifiedName bn;
UA_StatusCode res = readWithReadValue(server, nodeId, UA_ATTRIBUTEID_BROWSENAME, &bn);
if(res != UA_STATUSCODE_GOOD)
if(res != UA_STATUSCODE_GOOD) {
UA_UNLOCK(&server->serviceMutex);
return res;
}

union {
UA_SessionDiagnosticsDataType sddt;
Expand Down Expand Up @@ -412,6 +418,7 @@ readSessionDiagnostics(UA_Server *server,

cleanup:
UA_QualifiedName_clear(&bn);
UA_UNLOCK(&server->serviceMutex);
return res;
}

Expand Down

0 comments on commit 5953dd2

Please sign in to comment.