- fixed some issues related to "config listen 1" mode
i.e. do not write some lines twice when in this mode
This commit is contained in:
@ -68,6 +68,7 @@ void WriteToCommandLogId(char *prompt, int id, char *text)
|
||||
time_t now;
|
||||
char stamp1[32], stamp2[32], buffer[80];
|
||||
int doStamp, doStampId;
|
||||
int old;
|
||||
|
||||
/* suppress status messages */
|
||||
if (strstr(text, "status =") != NULL) {
|
||||
@ -196,6 +197,7 @@ void WriteToCommandLogId(char *prompt, int id, char *text)
|
||||
if (pServ->pTasker != NULL) {
|
||||
if (doStamp) {
|
||||
TaskSignal(pServ->pTasker, COMLOG, stamp1);
|
||||
SCOnlySockWrite(GetSendingConnection(), stamp1, eLog);
|
||||
}
|
||||
TaskSignal(pServ->pTasker, COMLOG, pCopy);
|
||||
}
|
||||
|
38
conman.c
38
conman.c
@ -98,7 +98,8 @@ typedef struct {
|
||||
static int iName = 0;
|
||||
static long lastIdent = 0;
|
||||
/*------------- sending connection (prevent double write when listening) ----*/
|
||||
static int sendingConnection = 0;
|
||||
static SConnection *sendingConnection = NULL;
|
||||
static int sendingSockHandle = 0;
|
||||
/*------------- storing connection and context for later use ----*/
|
||||
struct SCStore {
|
||||
SConnection *pCon;
|
||||
@ -139,6 +140,23 @@ void KillFreeConnections()
|
||||
{
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SConnection *GetSendingConnection(void)
|
||||
{
|
||||
return sendingConnection;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void SetSendingConnection(SConnection *pCon)
|
||||
{
|
||||
sendingConnection = pCon;
|
||||
if (pCon) {
|
||||
sendingSockHandle = pCon->sockHandle;
|
||||
} else {
|
||||
sendingSockHandle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static SConnection *SCMakeConnection()
|
||||
{
|
||||
@ -700,14 +718,14 @@ static void testAndWriteCommandLog(SConnection * pCon, char *buffer,
|
||||
{
|
||||
if (SCGetRights(pCon) <= usUser) {
|
||||
if (SCinMacro(pCon) != 1) {
|
||||
sendingConnection = pCon->sockHandle;
|
||||
SetSendingConnection(pCon);
|
||||
WriteToCommandLogId(NULL, pCon->sockHandle, buffer);
|
||||
sendingConnection = 0;
|
||||
SetSendingConnection(NULL);
|
||||
} else {
|
||||
if (iOut == eLog || iOut == eLogError) {
|
||||
sendingConnection = pCon->sockHandle;
|
||||
SetSendingConnection(pCon);
|
||||
WriteToCommandLogId(NULL, pCon->sockHandle, buffer);
|
||||
sendingConnection = 0;
|
||||
SetSendingConnection(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1000,7 +1018,9 @@ int SCLogWrite(SConnection * self, char *buffer, int iOut)
|
||||
if (!VerifyConnection(self)) {
|
||||
return 0;
|
||||
}
|
||||
SetSendingConnection(self);
|
||||
WriteToCommandLogId(NULL, self->sockHandle, buffer);
|
||||
SetSendingConnection(NULL);
|
||||
|
||||
if(self->iProtocolID == 5) {
|
||||
if (strlen(buffer) + 30 > 1024) {
|
||||
@ -1614,7 +1634,7 @@ int SCInvoke(SConnection * self, SicsInterp * pInter, char *pCommand)
|
||||
* case
|
||||
*/
|
||||
if (SCGetWriteFunc(self) != SCNotWrite) {
|
||||
sendingConnection = self->sockHandle;
|
||||
SetSendingConnection(self);
|
||||
if (self->sockHandle >= 0) {
|
||||
if(strstr(pCommand,"Poch") == NULL){
|
||||
WriteToCommandLogCmd(self->sockHandle, pCommand);
|
||||
@ -1622,7 +1642,7 @@ int SCInvoke(SConnection * self, SicsInterp * pInter, char *pCommand)
|
||||
} else {
|
||||
WriteToCommandLog("CRON>>", pCommand);
|
||||
}
|
||||
sendingConnection = 0;
|
||||
SetSendingConnection(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2164,11 +2184,11 @@ void SCSignalFunction(void *pData, int iSignal, void *pSigData)
|
||||
} else if (iSignal == SICSBROADCAST) {
|
||||
pPtr = (char *) pSigData;
|
||||
if (pPtr != NULL) {
|
||||
SCWrite(self, pPtr, eWarning);
|
||||
SCPureSockWrite(self, pPtr, eWarning);
|
||||
}
|
||||
} else if (iSignal == COMLOG && self->listening == 1) {
|
||||
pPtr = (char *) pSigData;
|
||||
if (pPtr != NULL && self->sockHandle != sendingConnection) {
|
||||
if (pPtr != NULL && self->sockHandle != sendingSockHandle) {
|
||||
doSockWrite(self, pPtr);
|
||||
}
|
||||
} else if (iSignal == TOKENRELEASE) {
|
||||
|
Reference in New Issue
Block a user