- bug fixes
SKIPPED: psi/haakedriv.c
This commit is contained in:
2
ascon.c
2
ascon.c
@ -180,7 +180,7 @@ int AsconReadGarbage(int fd)
|
||||
if (l > 0) {
|
||||
/* swallow */
|
||||
garbage[l] = '\0';
|
||||
printf("(((%s)))\n", garbage);
|
||||
/* printf("(((%s)))\n", garbage); */
|
||||
result += l;
|
||||
} else if (l == 0) {
|
||||
errno = ECONNRESET;
|
||||
|
30
devser.c
30
devser.c
@ -1,3 +1,4 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "ascon.h"
|
||||
#include "devser.h"
|
||||
@ -57,7 +58,7 @@ static void DevFreeActionList(DevAction * actions)
|
||||
}
|
||||
}
|
||||
|
||||
static double nextTime(double last,
|
||||
static double nextTime(double due,
|
||||
double lastInterval,
|
||||
double now,
|
||||
double interval) {
|
||||
@ -66,12 +67,12 @@ static double nextTime(double last,
|
||||
* following rules:
|
||||
* (1) result > now
|
||||
* (2) result is a multiple of interval
|
||||
* (3) result > last + min(lastInterval,interval) * 0.99
|
||||
* (3) result >= due OR result >= due - lastInterval + interval
|
||||
*/
|
||||
if (interval > lastInterval) {
|
||||
base = last + lastInterval * 0.99;
|
||||
base = due - lastInterval * 0.01;
|
||||
} else {
|
||||
base = last + interval * 0.99;
|
||||
base = due - lastInterval + interval * 0.99;
|
||||
}
|
||||
if (now > base) {
|
||||
base = now;
|
||||
@ -79,6 +80,7 @@ static double nextTime(double last,
|
||||
return (floor(base / interval) + 1) * interval;
|
||||
}
|
||||
|
||||
|
||||
static DevAction *DevNextAction(DevSer * devser)
|
||||
{
|
||||
/* the action queue is primarily ordered by priority (high prioirty first),
|
||||
@ -104,8 +106,7 @@ static DevAction *DevNextAction(DevSer * devser)
|
||||
action->timeDue = now;
|
||||
} else {
|
||||
/* increase timeDue according to interval */
|
||||
action->timeDue = nextTime(action->timeDue, action->interval,
|
||||
now, action->interval);
|
||||
action->timeDue = nextTime(0, 0, now, action->interval);
|
||||
}
|
||||
prio = action->prio;
|
||||
|
||||
@ -280,7 +281,7 @@ int DevSchedule(DevSer * devser, void *actionData,
|
||||
|
||||
for (ptr2prev = &devser->actions, action = devser->actions;
|
||||
action != NULL;
|
||||
ptr2prev = &action->next, action = action->next) {
|
||||
action = action->next) {
|
||||
if (action->prio < prio && ptr2insertPos == NULL) {
|
||||
ptr2insertPos = ptr2prev;
|
||||
}
|
||||
@ -292,21 +293,28 @@ int DevSchedule(DevSer * devser, void *actionData,
|
||||
&& matchFunc(actionData, action->data)) {
|
||||
if (prio == action->prio && interval < 0) {
|
||||
/* do not move an action with equal prio */
|
||||
if (killFunc) {
|
||||
killFunc(actionData);
|
||||
return 0;
|
||||
}
|
||||
return 0; /* not queued */
|
||||
}
|
||||
/* remove action from list */
|
||||
*ptr2prev = action->next;
|
||||
foundAction = action;
|
||||
} else {
|
||||
ptr2prev = &action->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* create if needed */
|
||||
if (foundAction != NULL) {
|
||||
/* a similar action was found */
|
||||
action = foundAction;
|
||||
ret = 0;
|
||||
if (killFunc) {
|
||||
killFunc(actionData);
|
||||
}
|
||||
ret = 0;
|
||||
} else {
|
||||
/* create if needed */
|
||||
action = calloc(1, sizeof(*action));
|
||||
assert(action);
|
||||
action->data = actionData;
|
||||
@ -335,7 +343,7 @@ int DevSchedule(DevSer * devser, void *actionData,
|
||||
}
|
||||
action->interval = interval;
|
||||
}
|
||||
return ret;
|
||||
return ret; /* when 0, actionData was killed */
|
||||
}
|
||||
|
||||
int DevQueue(DevSer * devser, void *actionData, DevPrio prio,
|
||||
|
4
devser.h
4
devser.h
@ -77,7 +77,7 @@ void DevDisconnect(DevSer * devser);
|
||||
* after the action has finished, i.e. when hdl returned NULL)
|
||||
* or NULL if no kill function is needed.
|
||||
* \return 1 when this was a new action, 0 when an action was overwritten
|
||||
* in the second case the actionData's kill Function is called
|
||||
* in the second case the actionData's kill Function is immediately called
|
||||
*/
|
||||
int DevQueue(DevSer * devser, void *actionData, DevPrio prio,
|
||||
DevActionHandler * hdl, DevActionMatch * matchFunc,
|
||||
@ -95,7 +95,7 @@ int DevQueue(DevSer * devser, void *actionData, DevPrio prio,
|
||||
* \param matchFunc a match function with two arguments of the same type
|
||||
* \param killFunc the action data kill function or NULL if no kill function is needed.
|
||||
* \return 1 when this was a new action, 0 when an action was overwritten
|
||||
* in the second case the actionData's kill Function is called
|
||||
* in the second case the actionData's kill Function is immediately called
|
||||
*/
|
||||
int DevSchedule(DevSer * devser, void *actionData,
|
||||
DevPrio prio, double interval,
|
||||
|
@ -1008,13 +1008,8 @@ void SctQueueNode(SctController * controller, Hdb * node,
|
||||
data->conCtx = NULL;
|
||||
data->answered = 1;
|
||||
|
||||
if (!DevQueue(data->controller->devser, data, prio,
|
||||
if (DevQueue(data->controller->devser, data, prio,
|
||||
SctWriteHandler, SctMatch, SctKillData)) {
|
||||
if (data->name != NULL) {
|
||||
free(data->name);
|
||||
}
|
||||
free(data);
|
||||
} else {
|
||||
if (con != NULL) {
|
||||
data->conCtx = SCCopyConnection(con);
|
||||
}
|
||||
|
Reference in New Issue
Block a user