- fixed problems deallocation sicsobjects
This commit is contained in:
@@ -43,6 +43,7 @@ typedef struct SctData {
|
||||
SctController *controller;
|
||||
SConnection *conCtx;
|
||||
int answered;
|
||||
int inMacro;
|
||||
Hdb *node;
|
||||
} SctData;
|
||||
|
||||
@@ -151,7 +152,8 @@ int SctCommand(SConnection * con, SicsInterp * sics, void *object,
|
||||
Hdb *cNode = NULL;
|
||||
hdbValue v;
|
||||
double dtime;
|
||||
|
||||
int iMacro;
|
||||
|
||||
assert(sct == object);
|
||||
if (sct->nodes != NULL) {
|
||||
node = sct->nodes->node;
|
||||
@@ -188,11 +190,14 @@ int SctCommand(SConnection * con, SicsInterp * sics, void *object,
|
||||
* print
|
||||
*/
|
||||
if (strcmp(argv[1], "print") == 0) {
|
||||
iMacro = con->iMacro;
|
||||
if (queueData != NULL) {
|
||||
queueData->answered = 1;
|
||||
con->iMacro = queueData->inMacro; /* take macro flag stored at set callback */
|
||||
}
|
||||
Arg2Text(argc - 2, argv + 2, value, sizeof value);
|
||||
SCWrite(con, value, eLog);
|
||||
SCWrite(con, value, eWarning);
|
||||
con->iMacro = iMacro;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -205,7 +210,7 @@ int SctCommand(SConnection * con, SicsInterp * sics, void *object,
|
||||
}
|
||||
|
||||
/*
|
||||
* time stamping (obsolete ? -> see SctActionHandler: timeKey, timeVal)
|
||||
* time stamping
|
||||
*/
|
||||
if (strcmp(argv[1], "utime") == 0) {
|
||||
if (argc < 3) {
|
||||
@@ -334,13 +339,13 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
commError = 0;
|
||||
}
|
||||
script = strdup(script);
|
||||
if (!SctCallInContext(con, script, node, data->controller, &result)) {
|
||||
if (!SctCallInContext(con, script, node, controller, &result)) {
|
||||
snprintf(eprop, sizeof eprop, "error_during_%s", data->name);
|
||||
if (strncmp(result, "ERROR: ", 7) == 0) {
|
||||
result += 7;
|
||||
}
|
||||
emsg = GetHdbProp(node, eprop);
|
||||
if (emsg == NULL) {
|
||||
if (emsg == NULL || con != controller->conn) {
|
||||
GetHdbPath(node, path, sizeof path);
|
||||
SCPrintf(con, eError,
|
||||
"ERROR: action <%s> in {%s} node %s:\nERROR: %s",
|
||||
@@ -364,6 +369,7 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
snprintf(msg, sizeof msg, "%dx {%s} %s", cnt, origScript, result);
|
||||
SetHdbProperty(node, eprop, msg);
|
||||
send = NULL;
|
||||
free(script);
|
||||
goto finish;
|
||||
}
|
||||
state = result;
|
||||
@@ -384,6 +390,7 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
snprintf(timeVal, sizeof timeVal, "%.3f", DoubleTime());
|
||||
SetHdbProperty(node, timeKey, timeVal);
|
||||
send = NULL;
|
||||
free(script);
|
||||
goto finish;
|
||||
}
|
||||
SetProp(node, controller->node, "state", state);
|
||||
@@ -568,13 +575,15 @@ static hdbCallbackReturn SctActionCallback(Hdb * node, void *userData,
|
||||
|
||||
if (data->conCtx != NULL) {
|
||||
GetHdbPath(node, path, sizeof path);
|
||||
SCPrintf(data->conCtx, eLog,
|
||||
SCPrintf(data->conCtx, eWarning,
|
||||
"%s target changed to %s before completion", path,
|
||||
GetCharArray(text));
|
||||
SCDeleteConnection(data->conCtx);
|
||||
}
|
||||
DeleteDynString(text);
|
||||
data->conCtx = SCCopyConnection(con);
|
||||
data->answered = 0;
|
||||
data->inMacro = con->iMacro;
|
||||
DevQueue(data->controller->devser, data, prio,
|
||||
SctWriteHandler, SctMatch, NULL);
|
||||
/* no kill function in DevQueue: data is owned by the node (callback list) */
|
||||
@@ -585,13 +594,11 @@ static hdbCallbackReturn SctActionCallback(Hdb * node, void *userData,
|
||||
if (mm != NULL) {
|
||||
if (queueData != NULL && queueData->conCtx != NULL && !data->answered) {
|
||||
/* update called from a write action */
|
||||
/*
|
||||
data->answered = 1;
|
||||
GetHdbPath(node, path, sizeof path);
|
||||
text = formatValue(*(mm->v), node);
|
||||
SCPrintf(queueData->conCtx, eWarning, "OK: %s set to: %s", path, GetCharArray(text));
|
||||
DeleteDynString(text);
|
||||
*/
|
||||
}
|
||||
return hdbContinue;
|
||||
}
|
||||
@@ -1050,9 +1057,14 @@ static hdbCallbackReturn SctDebugCallback(Hdb * node, void *userData,
|
||||
return hdbContinue;
|
||||
}
|
||||
|
||||
static int SctDeferredFree(void *data)
|
||||
static void SctDeferredFree(void *data)
|
||||
{
|
||||
free(data);
|
||||
return;
|
||||
}
|
||||
|
||||
static int SctDeferredTask(void *data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1069,8 +1081,8 @@ static void SctKillController(void *c)
|
||||
DevKill(controller->devser);
|
||||
controller->devser = NULL;
|
||||
if (pServ->pTasker) {
|
||||
TaskRegister(pServ->pTasker, SctDeferredFree, NULL, NULL, controller,
|
||||
0);
|
||||
TaskRegister(pServ->pTasker, SctDeferredTask, NULL, SctDeferredFree,
|
||||
controller, 0);
|
||||
} else {
|
||||
free(controller);
|
||||
}
|
||||
@@ -1124,6 +1136,8 @@ static int SctMakeController(SConnection * con, SicsInterp * sics,
|
||||
if (!controller->devser)
|
||||
return 0;
|
||||
|
||||
SetHdbProperty(controller->node, "controllerName", objName);
|
||||
|
||||
AddCommand(pServ->pSics, objName, InterInvokeSICSOBJ, KillSICSOBJ, ccmd);
|
||||
RegisterSICSOBJKillCmd(ccmd, objName);
|
||||
SetDescriptorKey(ccmd->pDes, "creationCommand", "0");
|
||||
|
||||
Reference in New Issue
Block a user