This is the first working version of the new logging system. Some work
in fine tuning still needs to be done. But is reasonably OK now.
This commit is contained in:
42
nread.c
42
nread.c
@@ -29,7 +29,6 @@
|
||||
#include "passwd.h"
|
||||
#include "conman.h"
|
||||
#include "SCinter.h"
|
||||
#include "servlog.h"
|
||||
#include "costa.h"
|
||||
#include "task.h"
|
||||
#include "emon.h"
|
||||
@@ -39,7 +38,6 @@
|
||||
#include "interrupt.h"
|
||||
#include "telnet.h"
|
||||
#include "nread.h"
|
||||
#include "commandlog.h"
|
||||
#include "uselect.h"
|
||||
#include "trace.h"
|
||||
#include "protocol.h"
|
||||
@@ -163,7 +161,7 @@ int NetReadRegister(pNetRead self, mkChannel * pSock, eNRType eType,
|
||||
if (sEntry.pSock->sockid == pSock->sockid) {
|
||||
snprintf(buffer, sizeof buffer, "NetReadRegister twice %d type %d",
|
||||
pSock->sockid, eType);
|
||||
WriteToCommandLog("SYS>", buffer);
|
||||
Log(ERROR,"sys", buffer);
|
||||
return 1;
|
||||
}
|
||||
iRet = LLDnodePtr2Next(self->iList);
|
||||
@@ -219,7 +217,7 @@ static int NetReadAccept(pNetRead self, mkChannel * pSock)
|
||||
pRes = SCreateConnection(self->pMain->pSics,pNew,3);
|
||||
*/
|
||||
if (!pRes) {
|
||||
SICSLogWrite("Failure to allocate new Connection", eInternal);
|
||||
Log(ERROR,"sys","%s","Failure to allocate new Connection");
|
||||
NETClosePort(pNew);
|
||||
free(pNew);
|
||||
return 0;
|
||||
@@ -266,9 +264,7 @@ static int NetReadRead(pNetRead self, pNetItem pItem)
|
||||
if (SCMatchRights(pItem->pCon, usUser)) {
|
||||
traceCommand(ConID(pItem->pCon),"interrupt: %d",iInt);
|
||||
TaskSignal(self->pMain->pTasker, SICSINT, &iInt);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "INTERRUPT %d issued on sock %d",
|
||||
iInt, pItem->pCon->pSock->sockid);
|
||||
WriteToCommandLog("SYS>", pBueffel);
|
||||
Log(ERROR,"com","sock%03.3d:INTERRUPT", pItem->pCon->pSock->sockid);
|
||||
if (iInt == eEndServer) {
|
||||
TaskStop(self->pMain->pTasker);
|
||||
}
|
||||
@@ -363,7 +359,7 @@ static int TelnetAccept(pNetRead self, mkChannel * pSock)
|
||||
pRes = SCreateConnection(self->pMain->pSics,pNew,usSpy);
|
||||
*/
|
||||
if (!pRes) {
|
||||
SICSLogWrite("Failure to allocate new Connection", eInternal);
|
||||
Log(ERROR,"sys","%s","Failure to allocate new Connection");
|
||||
NETClosePort(pNew);
|
||||
free(pNew);
|
||||
return 0;
|
||||
@@ -371,8 +367,7 @@ static int TelnetAccept(pNetRead self, mkChannel * pSock)
|
||||
/* Create a task object for the telnet connection */
|
||||
pTel = CreateTelnet(pRes);
|
||||
if (!pTel) {
|
||||
SICSLogWrite("Failure to allocate new Telnet Task Object",
|
||||
eInternal);
|
||||
Log(ERROR,"sys","%s","Failure to allocate new Telnet Task Object");
|
||||
SCDeleteConnection(pRes);
|
||||
return 0;
|
||||
}
|
||||
@@ -467,9 +462,6 @@ static int TelnetRead(pNetRead self, pNetItem pItem)
|
||||
}
|
||||
TaskSignal(self->pMain->pTasker, SICSINT, &iInt);
|
||||
traceCommand(ConID(pItem->pCon),"interrupt: %d",iInt);
|
||||
snprintf(pError,sizeof(pError)-1, "INTERRUPT %d issued on sock %d", iInt,
|
||||
pItem->pCon->pSock->sockid);
|
||||
WriteToCommandLog("SYS>", pError);
|
||||
if (iInt == eEndServer) {
|
||||
TaskStop(self->pMain->pTasker);
|
||||
}
|
||||
@@ -627,7 +619,7 @@ static int TelnetRead(pNetRead self, pNetItem pItem)
|
||||
default:
|
||||
/* There is something wrong here! */
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: bad telnet code %d", cChar);
|
||||
SICSLogWrite(pError, eInternal);
|
||||
Log(ERROR,"sys","%s",pError);
|
||||
pItem->tStatus = tData;
|
||||
break;
|
||||
|
||||
@@ -706,15 +698,15 @@ int NetReaderTask(void *pData)
|
||||
}
|
||||
conCount++;
|
||||
if (conCount > 100) {
|
||||
WriteToCommandLog("WAYTOMANYCONNECTIONS> ",
|
||||
Log(ERROR,"sys","%s","WAYTOMANYCONNECTIONS:%s ",
|
||||
GetCharArray(self->conList));
|
||||
}
|
||||
iRet = LLDnodePtr2Next(self->iList);
|
||||
}
|
||||
|
||||
if (conCount > 100) {
|
||||
WriteToCommandLog("WAYTOMANYCONNECTIONS> ",
|
||||
GetCharArray(self->conList));
|
||||
Log(ERROR,"sys","%s","WAYTOMANYCONNECTIONS:%s ",
|
||||
GetCharArray(self->conList));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1043,8 +1035,6 @@ static int testAndInvokeInterrupt(pCommandCBData self, int handle)
|
||||
TaskSignal(pServ->pTasker, SICSINT, &iInt);
|
||||
snprintf(buffer, 512, "INTERRUPT %d issued on sock %d",
|
||||
iInt, handle);
|
||||
WriteToCommandLog("SYS>", buffer);
|
||||
SICSLogWrite(buffer, eInternal);
|
||||
if (iInt == eEndServer) {
|
||||
TaskStop(pServ->pTasker);
|
||||
}
|
||||
@@ -1115,12 +1105,12 @@ static int CommandAcceptCB(int handle, void *userData)
|
||||
pCon = SCreateConnection(pServ->pSics, handle, 3);
|
||||
usData = malloc(sizeof(CommandCBData));
|
||||
if (pCon == NULL || usData == NULL) {
|
||||
SICSLogWrite("Failure to allocate new Connection", eInternal);
|
||||
Log(ERROR,"sys","%s","Failure to allocate new Connection");
|
||||
return 0;
|
||||
}
|
||||
usData->command = CreateDynString(256, 256);
|
||||
if (usData->command == NULL) {
|
||||
SICSLogWrite("Failure to allocate new Connection", eInternal);
|
||||
Log(ERROR,"sys","%s","Failure to allocate new Connection");
|
||||
return 0;
|
||||
}
|
||||
usData->pCon = pCon;
|
||||
@@ -1301,8 +1291,7 @@ static int ANETTelnetProcess(int handle, void *usData)
|
||||
|
||||
default:
|
||||
/* There is something wrong here! */
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: bad telnet code %d", cChar);
|
||||
SICSLogWrite(pError, eInternal);
|
||||
Log(ERROR,"sys","Bad telnet code %d", cChar);
|
||||
self->state = tData;
|
||||
break;
|
||||
|
||||
@@ -1323,12 +1312,12 @@ static int TelnetAcceptCB(int handle, void *userData)
|
||||
pCon = SCreateConnection(pServ->pSics, handle, 3);
|
||||
usData = malloc(sizeof(CommandCBData));
|
||||
if (pCon == NULL || usData == NULL) {
|
||||
SICSLogWrite("Failure to allocate new Connection", eInternal);
|
||||
Log(ERROR,"sys","%s","Failure to allocate new Connection");
|
||||
return 0;
|
||||
}
|
||||
usData->command = CreateDynString(256, 256);
|
||||
if (usData->command == NULL) {
|
||||
SICSLogWrite("Failure to allocate new Connection", eInternal);
|
||||
Log(ERROR,"sys","%s","Failure to allocate new Connection");
|
||||
return 0;
|
||||
}
|
||||
usData->pCon = pCon;
|
||||
@@ -1336,7 +1325,7 @@ static int TelnetAcceptCB(int handle, void *userData)
|
||||
/* Create a task object for the telnet connection */
|
||||
pTel = CreateTelnet(pCon);
|
||||
if (!pTel) {
|
||||
SICSLogWrite("Failure to allocate new Telnet Task Object", eInternal);
|
||||
Log(ERROR,"sys","%s","Failure to allocate new Telnet Task Object");
|
||||
SCDeleteConnection(pCon);
|
||||
return 0;
|
||||
}
|
||||
@@ -1356,7 +1345,6 @@ static int TelnetAcceptCB(int handle, void *userData)
|
||||
static void NREADlog(int level, char *txt, void *userData)
|
||||
{
|
||||
traceSys("anet","%s",txt);
|
||||
SICSLogWrite(txt, (level == ANETERROR) ? eLogError : eLog);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user