From 64d44c2824cc87e56ab34d01ff0e02498b26bd0e Mon Sep 17 00:00:00 2001 From: Koennecke Mark Date: Thu, 30 Jul 2015 13:57:55 +0200 Subject: [PATCH] Assorted bug fixes - If SctProcessNode ran into a timeout, its action data wa sdeleted. If data came later, this caused SICS to crash. This is now fixed - sget leaked connections under certain circumstances - Cosmetic fix to hipadaba.c - yet another chnage to the TRICS file format in fourmess.c, now it prints magnetic field instead of the proton count --- fourmess.c | 27 ++++++++++++++++++++++++--- hipadaba.c | 2 +- scriptcontext.c | 13 ++++++++++++- sicsget.c | 1 + 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/fourmess.c b/fourmess.c index ac72764a..0fc084db 100644 --- a/fourmess.c +++ b/fourmess.c @@ -393,7 +393,7 @@ static int FourMessStoreIntern(pSICSOBJ self, SConnection * pCon, double fHkl[3], double fPosition[4], char *extra) { pFourMess priv = self->pPrivate; - float fSum, fSigma, fTemp, fStep, fPreset; + float fSum, fSigma, fTemp, fMF, fStep, fPreset; int i, iLF, iRet, iNP, ii; long *lCounts = NULL; pEVControl pEva = NULL; @@ -486,6 +486,23 @@ static int FourMessStoreIntern(pSICSOBJ self, SConnection * pCon, iRet = EVCGetPos(pEva, pCon, &fTemp); } + /* get mf */ + fMF = -777.77; + pEva = (pEVControl) FindCommandData(pServ->pSics, "mf", + "Environment Controller"); + if (pEva == NULL) { + pPtr = (pDummy) FindCommandData(pServ->pSics, "mf", + "RemObject"); + if (pPtr != NULL) { + pDriv = pPtr->pDescriptor->GetInterface(pPtr, DRIVEID); + if (pDriv != NULL) { + fMF = pDriv->GetValue(pPtr, pCon); + } + } + } else { + iRet = EVCGetPos(pEva, pCon, &fMF); + } + /* write profile */ if (priv->profFile) { /* collect data */ @@ -493,12 +510,16 @@ static int FourMessStoreIntern(pSICSOBJ self, SConnection * pCon, GetScanVarStep(priv->pScanner, 0, &fStep); fPreset = GetScanPreset(priv->pScanner); prot = getProtonAverage(priv); + /* + They rather wanted fMF in place of the proton average which fell victim to the + monitor assignement chaos anyway. + */ if(extra == NULL){ fprintf(priv->profFile, "%3d %7.4f %9.0f %7.3f %12f %s\n", iNP, fStep, - fPreset, fTemp, prot, pBueffel); + fPreset, fTemp, fMF, pBueffel); } else { fprintf(priv->profFile, "%3d %7.4f %9.0f %7.3f %12f %s %s\n", iNP, fStep, - fPreset, fTemp, prot, pBueffel,extra); + fPreset, fTemp, fMF, pBueffel,extra); } for (i = 0; i < iNP; i++) { for (ii = 0; ii < 10 && i < iNP; ii++) { diff --git a/hipadaba.c b/hipadaba.c index b713b6cc..5eb6666d 100644 --- a/hipadaba.c +++ b/hipadaba.c @@ -1194,7 +1194,7 @@ int GetHdbProperty(pHdb node, char *key, char *value, int len) /*---------------------------------------------------------------------------*/ char *GetHdbProp(pHdb node, char *key) { - if (node != NULL && node->properties != NULL) { + if (node != NULL && isHdbNodeValid(node) && node->properties != NULL) { return StringDictGetShort(node->properties, key); } else { return NULL; diff --git a/scriptcontext.c b/scriptcontext.c index b63e565b..753dc1b1 100644 --- a/scriptcontext.c +++ b/scriptcontext.c @@ -1620,8 +1620,19 @@ static int SctProcessCmd(pSICSOBJ ccmd, SConnection * con, startTime = time(NULL); DevQueue(c->devser, data, WritePRIO, SctWriteHandler, SctTransactMatch, NULL, SctDataInfo); - while (data->busy == 1 && time(NULL) < startTime + 20) { + + while (data->busy == 1){ TaskYield(pServ->pTasker); + if(time(NULL) >= startTime + 20) { + /* + if data would still come after such a long timeout, it + might end up in the next action: see comment in devser.c + */ + SCPrintf(con,eError,"ERROR: timeout processing node %s", par[0]->value.v.text); + DevRemoveAction(c->devser,data); + SctKillData(data); + return 0; + } } SctKillData(data); diff --git a/sicsget.c b/sicsget.c index 2924a2a6..b1dcd638 100644 --- a/sicsget.c +++ b/sicsget.c @@ -153,6 +153,7 @@ static int InvokeSICSFunc(void *ms, void *userData) SCsetMacro(pCon,0); if(!status){ self->success = 0; + SCDeleteConnection(pCon); return MPSTOP; } self->response = strdup(Tcl_GetStringResult(InterpGetTcl(pServ->pSics)));