mirror of
https://github.com/open62541/open62541.git
synced 2026-10-16 20:33:18 +08:00
fix(server): Fix readMonitoredItems
This commit is contained in:
committed by
Julius Pfrommer
parent
06a3b0eaaf
commit
982f07963a
@@ -553,24 +553,17 @@ readMonitoredItems(UA_Server *server, const UA_NodeId *sessionId, void *sessionC
|
||||
0, &UA_TYPES[UA_TYPES_UINT32]);
|
||||
|
||||
/* Get the Session */
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_Session *session = UA_Server_getSessionById(server, sessionId);
|
||||
if(!session) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_Session *session = UA_SessionManager_getSessionById(&server->sessionManager, sessionId);
|
||||
if(!session)
|
||||
return UA_STATUSCODE_BADINTERNALERROR;
|
||||
}
|
||||
if(inputSize == 0 || !input[0].data) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
if(inputSize == 0 || !input[0].data)
|
||||
return UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
|
||||
}
|
||||
|
||||
/* Get the Subscription */
|
||||
UA_UInt32 subscriptionId = *((UA_UInt32*)(input[0].data));
|
||||
UA_Subscription *subscription = UA_Session_getSubscriptionById(session, subscriptionId);
|
||||
if(!subscription) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
if(!subscription)
|
||||
return UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
|
||||
}
|
||||
|
||||
/* Count the MonitoredItems */
|
||||
UA_UInt32 sizeOfOutput = 0;
|
||||
@@ -578,22 +571,18 @@ readMonitoredItems(UA_Server *server, const UA_NodeId *sessionId, void *sessionC
|
||||
LIST_FOREACH(monitoredItem, &subscription->monitoredItems, listEntry) {
|
||||
++sizeOfOutput;
|
||||
}
|
||||
if(sizeOfOutput == 0) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
if(sizeOfOutput == 0)
|
||||
return UA_STATUSCODE_GOOD;
|
||||
}
|
||||
|
||||
/* Allocate the output arrays */
|
||||
UA_UInt32 *clientHandles = (UA_UInt32*)
|
||||
UA_Array_new(sizeOfOutput, &UA_TYPES[UA_TYPES_UINT32]);
|
||||
if(!clientHandles) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
if(!clientHandles)
|
||||
return UA_STATUSCODE_BADOUTOFMEMORY;
|
||||
}
|
||||
|
||||
UA_UInt32 *serverHandles = (UA_UInt32*)
|
||||
UA_Array_new(sizeOfOutput, &UA_TYPES[UA_TYPES_UINT32]);
|
||||
if(!serverHandles) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_free(clientHandles);
|
||||
return UA_STATUSCODE_BADOUTOFMEMORY;
|
||||
}
|
||||
@@ -607,8 +596,6 @@ readMonitoredItems(UA_Server *server, const UA_NodeId *sessionId, void *sessionC
|
||||
}
|
||||
UA_Variant_setArray(&output[0], serverHandles, sizeOfOutput, &UA_TYPES[UA_TYPES_UINT32]);
|
||||
UA_Variant_setArray(&output[1], clientHandles, sizeOfOutput, &UA_TYPES[UA_TYPES_UINT32]);
|
||||
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
return UA_STATUSCODE_GOOD;
|
||||
}
|
||||
#endif /* defined(UA_ENABLE_METHODCALLS) && defined(UA_ENABLE_SUBSCRIPTIONS) */
|
||||
|
||||
Reference in New Issue
Block a user