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

@ -449,11 +449,14 @@ void
mmsMsg_createExtendedFilename(const char* basepath, char* extendedFileName, char* fileName) mmsMsg_createExtendedFilename(const char* basepath, char* extendedFileName, char* fileName)
{ {
#if (CONFIG_SET_FILESTORE_BASEPATH_AT_RUNTIME == 1) #if (CONFIG_SET_FILESTORE_BASEPATH_AT_RUNTIME == 1)
strncpy(extendedFileName, basepath, 512); strncpy(extendedFileName, basepath, 511);
strncat(extendedFileName, fileName, 512); extendedFileName[511] = 0;
strncat(extendedFileName, fileName, 511);
extendedFileName[511] = 0;
#else #else
strcpy(extendedFileName, CONFIG_VIRTUAL_FILESTORE_BASEPATH); 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 #endif
} }

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

Loading…
Cancel
Save