PSI sics-cvs-psi-2006

This commit is contained in:
2006-05-08 02:00:00 +00:00
committed by Douglas Clowes
parent ae77364de2
commit 6e926b813f
388 changed files with 445529 additions and 14109 deletions

View File

@@ -6,11 +6,9 @@
Mark Koennecke, October 1996
Revised for use with tasker: Mark Koennecke, September 1997
Added code to redirect stdout/sterr to file, Mark Koennecke, May 2000
Define handler in InitServer to ignore SIGPIPE. Paul Hathaway, May 2004
Added code to redirect stdout/sterr to file.
Mark Koennecke, May 2000
Copyright: see copyright.h
----------------------------------------------------------------------------*/
#define NEEDDINTINIT
@@ -19,6 +17,7 @@
#include <assert.h>
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <time.h>
#include "sics.h"
@@ -93,6 +92,8 @@
memset(self,0,sizeof(SicsServer));
*pServ = self;
/* define any signal handlers */
signal(SIGPIPE,SIG_IGN);
/* configure fortify */
iFortifyScope = Fortify_EnterScope();
@@ -157,19 +158,27 @@
{
i = atoi(pPtr);
iCommandTimeOut = i;
}
}
else
{
iCommandTimeOut = 100; /* this is in microseconds and anyway o.k. */
}
pPtr = NULL;
pPtr = IFindOption(pSICSOptions,"ReadUserPasswdTimeout");
if(pPtr != NULL)
{
i = atoi(pPtr);
iPasswordTimeOut = i;
}
}
else
{
iPasswordTimeOut = 1; /* never used, but checked ! */
}
assert((pReader = CreateNetReader(self,iPasswordTimeOut,iCommandTimeOut)) != NULL);
TaskRegister(self->pTasker,
NetReaderTask,
NetReaderSignal,
DeleteNetReader,
NULL, /* call DeleteNetReader later than TaskerDelete */
pReader,1);
self->pReader = pReader;
@@ -179,24 +188,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);
@@ -214,16 +223,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);
@@ -275,7 +284,6 @@
NULL,
pMon,1);
/* install telnet port */
InstallTelnet();
@@ -303,7 +311,6 @@
/* shut tasker down */
TaskerDelete(&self->pTasker);
self->pTasker = NULL;
self->pReader = NULL;
/* save status */
if(!self->simMode)
@@ -338,11 +345,20 @@
}
/* clean out */
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);
if(self->pSics)
DeleteInterp(self->pSics);
/* delete net reader */
DeleteNetReader(self->pReader);
self->pReader = NULL;
/* close the server port */
if(self->pServerPort)
{
@@ -378,11 +394,15 @@
/* close the List system */
LLDsystemClose();
KillFreeConnections();
/* make fortify print his findings */
Fortify_DumpAllMemory(iFortifyScope);
Fortify_LeaveScope();
free(self);
}
/*------------------------------------------------------------------------*/
void RunServer(pServer self)
@@ -439,7 +459,7 @@
/*--------------------------------------------------------------------------
UserWait: the user command for waiting, expects one arg:
time to wait in seconds
*/
---------------------------------------------------------------------------*/
int UserWait(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[])
{
@@ -498,7 +518,7 @@
}
}
/*------------------------------------------------------------------------*/
int SicsWait(long lTime)
int SicsWaitOld(long lTime)
{
WaitStruct sWait;
pTaskMan pTasker = NULL;
@@ -518,7 +538,28 @@
TaskWait(pTasker,lID);
return 1;
}
/*------------------------------------------------------------------------
The new SicsWait is still on probation. It prevents commands to be
executed on the same task on which the Sicswait is acting.
M.K. December 2005
-------------------------------------------------------------------------*/
int SicsWait(long lTime)
{
pTaskMan pTasker = NULL;
time_t endTime;
if(pServ->simMode)
{
return 1;
}
pTasker = GetTasker();
endTime = time(NULL) + lTime;
while(time(NULL) < endTime)
{
TaskYield(pTasker);
}
return 1;
}
/*-------------------------------------------------------------------------*/
void ServerWriteGlobal(char *pMessage,int iOut)
{