- fixed memory leak in ISO server

pull/266/head
Michael Zillgith 5 years ago
parent 767bc887de
commit e59aa5521e

@ -48,6 +48,7 @@ int main(int argc, char** argv) {
if (error == IED_ERROR_OK) {
#if 0
/************************
* Direct control
***********************/
@ -149,29 +150,31 @@ int main(int argc, char** argv) {
else {
printf("Reading status for simpleIOGenericIO/GGIO1.SPCSO3 failed!\n");
}
#endif
/***********************************************
* Select before operate with enhanced security
***********************************************/
control = ControlObjectClient_create("simpleIOGenericIO/GGIO1.SPCSO4", con);
ControlObjectClient control = ControlObjectClient_create("TESTIED1LD0/CBCSWI1.Pos", con);
ControlObjectClient_setCommandTerminationHandler(control, commandTerminationHandler, NULL);
ctlVal = MmsValue_newBoolean(true);
MmsValue* ctlVal = MmsValue_newBoolean(true);
if (ControlObjectClient_selectWithValue(control, ctlVal)) {
if (ControlObjectClient_operate(control, ctlVal, 0 /* operate now */)) {
printf("simpleIOGenericIO/GGIO1.SPCSO4 operated successfully\n");
printf("TESTIED1LD0/CBCSWI1.Pos\n");
}
else {
printf("failed to operate simpleIOGenericIO/GGIO1.SPCSO4!\n");
printf("TESTIED1LD0/CBCSWI1.Pos!\n");
}
}
else {
printf("failed to select simpleIOGenericIO/GGIO1.SPCSO4!\n");
printf("failed to select TESTIED1LD0/CBCSWI1.Pos!\n");
}
MmsValue_delete(ctlVal);
@ -181,7 +184,7 @@ int main(int argc, char** argv) {
ControlObjectClient_destroy(control);
#if 0
/*********************************************************************
* Direct control with enhanced security (expect CommandTermination-)
*********************************************************************/
@ -205,6 +208,7 @@ int main(int argc, char** argv) {
Thread_sleep(1000);
ControlObjectClient_destroy(control);
#endif
IedConnection_close(con);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -772,7 +772,7 @@ IsoClientConnection_destroy(IsoClientConnection self)
if (self->receiveBuffer != NULL)
GLOBAL_FREEMEM(self->receiveBuffer);
if (self->cotpConnection != NULL) {
if ( self->cotpConnection->handleSet != NULL )
if (self->cotpConnection->handleSet != NULL)
Handleset_destroy(self->cotpConnection->handleSet);
GLOBAL_FREEMEM(self->cotpConnection);
}

@ -449,11 +449,14 @@ void
mmsMsg_createExtendedFilename(const char* basepath, char* extendedFileName, char* fileName)
{
#if (CONFIG_SET_FILESTORE_BASEPATH_AT_RUNTIME == 1)
strncpy(extendedFileName, basepath, 512);
strncat(extendedFileName, fileName, 512);
strncpy(extendedFileName, basepath, 511);
extendedFileName[511] = 0;
strncat(extendedFileName, fileName, 511);
extendedFileName[511] = 0;
#else
strcpy(extendedFileName, CONFIG_VIRTUAL_FILESTORE_BASEPATH);
strncat(extendedFileName, fileName, sizeof(CONFIG_VIRTUAL_FILESTORE_BASEPATH) + 256);
strncat(extendedFileName, fileName, sizeof(CONFIG_VIRTUAL_FILESTORE_BASEPATH) + 255);
extendedFileName[sizeof(CONFIG_VIRTUAL_FILESTORE_BASEPATH) + 255] = 0;
#endif
}

@ -119,7 +119,13 @@ finalizeIsoConnection(IsoConnection self)
GLOBAL_FREEMEM(self->cotpReadBuf);
GLOBAL_FREEMEM(self->cotpWriteBuf);
if (self->cotpConnection) {
if (self->cotpConnection->handleSet)
Handleset_destroy(self->cotpConnection->handleSet);
}
GLOBAL_FREEMEM(self->cotpConnection);
self->cotpConnection = NULL;
#if (CONFIG_MMS_THREADLESS_STACK != 1)
Semaphore_destroy(self->conMutex);
@ -590,6 +596,11 @@ IsoConnection_destroy(IsoConnection self)
if (self->socket != NULL)
Socket_destroy(self->socket);
if (self->cotpConnection) {
if (self->cotpConnection->handleSet)
Handleset_destroy(self->cotpConnection->handleSet);
}
GLOBAL_FREEMEM(self);
}

Loading…
Cancel
Save