From 9335afcca53a29c7b8b85d318a99ac7c48f78677 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Mon, 2 Jan 2023 15:52:17 +0000 Subject: [PATCH] - fixed - outstanding call not released in IedConnection_getDataSetDirectoryAsync (LIB61850-379) --- src/iec61850/client/ied_connection.c | 31 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/iec61850/client/ied_connection.c b/src/iec61850/client/ied_connection.c index 9ab48163..b7395c7b 100644 --- a/src/iec61850/client/ied_connection.c +++ b/src/iec61850/client/ied_connection.c @@ -3294,8 +3294,6 @@ uint32_t IedConnection_createDataSetAsync(IedConnection self, IedClientError* error, const char* dataSetReference, LinkedList /* char* */ dataSetElements, IedConnection_GenericServiceHandler handler, void* parameter) { - uint32_t invokeId = 0; - char domainIdBuffer[65]; char itemIdBuffer[DATA_SET_MAX_NAME_LENGTH + 1]; @@ -3338,7 +3336,7 @@ IedConnection_createDataSetAsync(IedConnection self, IedClientError* error, cons isAssociationSpecific = true; } - MmsError mmsError; + MmsError mmsError = MMS_ERROR_NONE; IedConnectionOutstandingCall call = iedConnection_allocateOutstandingCall(self); @@ -3379,8 +3377,6 @@ IedConnection_createDataSetAsync(IedConnection self, IedClientError* error, cons &mmsError, domainId, itemId, dataSetEntries, createDataSetAsyncHandler, self); } - invokeId = call->invokeId; - *error = iedConnection_mapMmsErrorToIedError(mmsError); cleanup_list: @@ -3388,7 +3384,15 @@ cleanup_list: LinkedList_destroyDeep(dataSetEntries, (LinkedListValueDeleteFunction) MmsVariableAccessSpecification_destroy); exit_function: - return invokeId; + + if (mmsError != MMS_ERROR_NONE) { + iedConnection_releaseOutstandingCall(self, call); + + return 0; + } + else { + return call->invokeId; + } } LinkedList /* */ @@ -3513,6 +3517,8 @@ getDataSetDirectoryAsyncHandler(uint32_t invokeId, void* parameter, MmsError mms if (handler) handler(call->invokeId, call->callbackParameter, err, dataSetMembers, deletable); + + iedConnection_releaseOutstandingCall(self, call); } if (specs) @@ -3523,8 +3529,6 @@ uint32_t IedConnection_getDataSetDirectoryAsync(IedConnection self, IedClientError* error, const char* dataSetReference, IedConnection_GetDataSetDirectoryHandler handler, void* parameter) { - uint32_t invokeId = 0; - IedConnectionOutstandingCall call = iedConnection_allocateOutstandingCall(self); if (call == NULL) { @@ -3580,7 +3584,6 @@ IedConnection_getDataSetDirectoryAsync(IedConnection self, IedClientError* error MmsError mmsError = MMS_ERROR_NONE; - if (isAssociationSpecific) MmsConnection_readNamedVariableListDirectoryAssociationSpecificAsync(self->connection, &(call->invokeId), &mmsError, itemId, getDataSetDirectoryAsyncHandler, self); @@ -3590,7 +3593,15 @@ IedConnection_getDataSetDirectoryAsync(IedConnection self, IedClientError* error *error = iedConnection_mapMmsErrorToIedError(mmsError); exit_function: - return invokeId; + + if (mmsError != MMS_ERROR_NONE) { + iedConnection_releaseOutstandingCall(self, call); + + return 0; + } + else { + return call->invokeId; + } } ClientDataSet