make shutdown more proper (releasing all memory)

This commit is contained in:
zolliker
2005-09-02 13:57:14 +00:00
parent 2e1778abb7
commit 9a051e8289
4 changed files with 30 additions and 12 deletions

1
help.c
View File

@ -21,6 +21,7 @@ static char *helpDirs = NULL;
static char *defaultFile="master.txt";
/*----------------------------------------------------------------------*/
void KillHelp(void *pData){
KillDummy(pData);
if(helpDirs != NULL){
free(helpDirs);
helpDirs = NULL;

11
macro.c
View File

@ -167,9 +167,9 @@
{
if(strcmp(lastCommand,comBuffer) == 0)
{
Tcl_AppendResult(pInter,"ERROR: Never ending loop in unknown\n",
Tcl_AppendResult(pInter,"ERROR: Never ending loop in unknown\n",
"Offending command: ",comBuffer,
"Probably Tcl command not found",NULL);
" Probably Tcl command not found",NULL);
SCSetInterrupt(pCon,eAbortBatch);
return TCL_ERROR;
}
@ -218,6 +218,13 @@
free(pData);
pUnbekannt = NULL;
}
/*-----------------------------------------------------------------------*/
void KillSicsUnknown(void) {
if (pUnbekannt) {
UnknownKill(pUnbekannt);
pUnbekannt = NULL;
}
}
/*------------------------------------------------------------------------
Implementation of a protected exec command
--------------------------------------------------------------------------*/

View File

@ -46,6 +46,7 @@
int MacroPush(SConnection *pCon);
int MacroPop(void);
void KillSicsUnknown(void);
#endif

View File

@ -177,7 +177,7 @@
TaskRegister(self->pTasker,
NetReaderTask,
NetReaderSignal,
DeleteNetReader,
NULL, /* call DeleteNetReader later than TaskerDelete */
pReader,1);
self->pReader = pReader;
@ -187,24 +187,24 @@
{
printf("Cannot find ServerPort number in options file %s\n",
"This value is required!");
IFDeleteOptions(pSICSOptions);
DeleteInterp(self->pSics);
IFDeleteOptions(pSICSOptions);
return 0;
}
iRet = sscanf(pText,"%d",&iPort);
if( (iRet != 1) || (iPort < 1024) )
{
printf("Invalid port number specified in Server initialisation file\n");
IFDeleteOptions(pSICSOptions);
DeleteInterp(self->pSics);
IFDeleteOptions(pSICSOptions);
return 0;
}
self->pServerPort = NETOpenPort(iPort);
if(!self->pServerPort)
{
printf("Cannot open Server Socket\n");
IFDeleteOptions(pSICSOptions);
DeleteInterp(self->pSics);
IFDeleteOptions(pSICSOptions);
return 0;
}
NetReadRegister(pReader, self->pServerPort, naccept, NULL);
@ -222,16 +222,16 @@
{
printf("Cannot find InterruptPort number in options file %s\n",
"This value is required!");
IFDeleteOptions(pSICSOptions);
DeleteInterp(self->pSics);
IFDeleteOptions(pSICSOptions);
return 0;
}
iRet = sscanf(pText,"%d",&iPort);
if( (iRet != 1) || (iPort < 1024) )
{
printf("Invalid port number specified in Server initialisation file\n");
IFDeleteOptions(pSICSOptions);
DeleteInterp(self->pSics);
IFDeleteOptions(pSICSOptions);
return 0;
}
iRet = ServerSetupInterrupt(iPort,pReader,self->pTasker);
@ -310,7 +310,6 @@
/* shut tasker down */
TaskerDelete(&self->pTasker);
self->pTasker = NULL;
self->pReader = NULL;
/* save status */
if(!self->simMode)
@ -345,14 +344,20 @@
}
/* clean out */
if(pSICSOptions)
IFDeleteOptions(pSICSOptions);
if(self->pSics)
{
DeleteInterp(self->pSics);
self->pSics = NULL;
}
/* remove options after interpreter as some object kill functions
may use options */
if(pSICSOptions)
IFDeleteOptions(pSICSOptions);
/* delete net reader */
DeleteNetReader(self->pReader);
self->pReader = NULL;
/* close the server port */
if(self->pServerPort)
{
@ -388,11 +393,15 @@
/* close the List system */
LLDsystemClose();
KillFreeConnections();
/* make fortify print his findings */
Fortify_DumpAllMemory(iFortifyScope);
Fortify_LeaveScope();
free(self);
}
/*------------------------------------------------------------------------*/
void RunServer(pServer self)