diff --git a/evcontroller.c b/evcontroller.c index fb13c318..81c72d6d 100644 --- a/evcontroller.c +++ b/evcontroller.c @@ -100,7 +100,7 @@ self->start = time(NULL); self->lastt = 0; self->iWarned = 0; - SCSave(&self->conn, pCon); + self->conn = SCSave(pCon, self->conn); /* try at least three times to do it */ for(i = 0; i < 3; i++) @@ -376,7 +376,7 @@ } /*---------------------------- Error Handlers --------------------------------*/ -static void ErrWrite(char *txt, SCStore *conn) +static void ErrWrite(char *txt, SCStore conn) { pExeList pExe; SConnection *pCon = NULL; @@ -384,17 +384,15 @@ static void ErrWrite(char *txt, SCStore *conn) pExe = GetExecutor(); pCon = GetExeOwner(pExe); - if (!pCon) + if (pCon) { - pCon = SCLoad(conn); + SCWrite(pCon,txt,eWarning); } - if(pCon) - { - SCWrite(pCon,txt,eWarning); - } else { - ServerWriteGlobal(txt,eWarning); + pCon = SCStorePush(conn); + SCWrite(pCon, txt, eWarning); + SCStorePop(conn); } } /*-----------------------------------------------------------------------*/ @@ -408,7 +406,7 @@ static void ErrReport(pEVControl self) { sprintf(pBueffel,"WARNING: %s is out of range by %g", self->pName,fDelta); - ErrWrite(pBueffel, &self->conn); + ErrWrite(pBueffel, self->conn); self->iWarned = 1; } } @@ -481,7 +479,7 @@ static void ErrReport(pEVControl self) snprintf(pBueffel,255, "ERROR: %s while processing errorscript for %s", pTcl->result,self->pName); - ErrWrite(pBueffel, &self->conn); + ErrWrite(pBueffel, self->conn); } /* assume that everything is fine again after the script @@ -495,7 +493,7 @@ static void ErrReport(pEVControl self) snprintf(pBueffel,255, "ERROR: script error handling requested for %s, but no script given", self->pName); - ErrWrite(pBueffel, &self->conn); + ErrWrite(pBueffel, self->conn); } return 1; @@ -525,7 +523,7 @@ static void ErrReport(pEVControl self) ErrReport(self); - ErrWrite("Running to safe value", &self->conn); + ErrWrite("Running to safe value", self->conn); self->pDriv->SetValue(self->pDriv, ObVal(self->pParam,SAFEVALUE)); self->eMode = EVIdle; self->iWarned = 0; @@ -617,7 +615,7 @@ static void ErrReport(pEVControl self) { sprintf(pBueffel,"Environment device %s back in tolerances again", self->pName); - ErrWrite(pBueffel, &self->conn); + ErrWrite(pBueffel, self->conn); self->iWarned = 0; } return 1; @@ -798,6 +796,7 @@ static void ErrReport(pEVControl self) pRes->pName = strdup(pName); pRes->eMode = EVIdle; pRes->iWarned = 0; + pRes->conn = NULL; /* a terminal error gives a -1 in iRet */ if(iRet < 0) @@ -870,6 +869,10 @@ static void ErrReport(pEVControl self) { free(self->runScript); } + if (self->conn != NULL) + { + SCStoreFree(self->conn); + } free(self); } /*--------------------------------------------------------------------------*/