diff --git a/src/iec61850/client/ied_connection.c b/src/iec61850/client/ied_connection.c index 3ca81e11..28f28660 100644 --- a/src/iec61850/client/ied_connection.c +++ b/src/iec61850/client/ied_connection.c @@ -1951,10 +1951,16 @@ IedConnection_getFile(IedConnection self, IedClientError* error, const char* fil return clientFileReadHandler.byteReceived; } - static void mmsConnectionFileCloseHandler (uint32_t invokeId, void* parameter, MmsError mmsError, bool success) { + (void)success; + + if (mmsError != MMS_ERROR_NONE) { + if (DEBUG_IED_CLIENT) + printf("IED_CLIENT: failed to close file error: %i (mms-error: %i)\n", iedConnection_mapMmsErrorToIedError(mmsError), mmsError); + } + IedConnection self = (IedConnection) parameter; IedConnectionOutstandingCall call = iedConnection_lookupOutstandingCall(self, invokeId); @@ -1985,11 +1991,19 @@ mmsConnectionFileReadHandler (uint32_t invokeId, void* parameter, MmsError mmsEr handler(call->specificParameter2.getFileInfo.originalInvokeId, call->callbackParameter, err, invokeId, NULL, 0, false); - /* close file */ - call->invokeId = MmsConnection_fileCloseAsync(self->connection, &mmsError, frsmId, mmsConnectionFileCloseHandler, self); + if (mmsError != MMS_ERROR_SERVICE_TIMEOUT) { + /* close file */ + call->invokeId = MmsConnection_fileCloseAsync(self->connection, &mmsError, frsmId, mmsConnectionFileCloseHandler, self); + + if (mmsError != MMS_ERROR_NONE) + iedConnection_releaseOutstandingCall(self, call); + } + else { + if (DEBUG_IED_CLIENT) + printf("IED_CLIENT: getFile timeout -> stop download\n"); - if (mmsError != MMS_ERROR_NONE) iedConnection_releaseOutstandingCall(self, call); + } } else { bool cont = handler(call->specificParameter2.getFileInfo.originalInvokeId, call->callbackParameter, IED_ERROR_OK, invokeId, buffer, byteReceived, moreFollows);