mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
Fix - make sure we don't lose track of scheduled alarms
This commit is contained in:
parent
a82c8f2f41
commit
2bef619723
@ -102,6 +102,7 @@ static void directory_update(struct sched_ent *alarm){
|
||||
if (subscriber_is_reachable(directory_service) != REACHABLE_NONE){
|
||||
directory_send_keyring(directory_service);
|
||||
|
||||
unschedule(alarm);
|
||||
alarm->alarm = gettime_ms() + DIRECTORY_UPDATE_INTERVAL;
|
||||
alarm->deadline = alarm->alarm + 10000;
|
||||
schedule(alarm);
|
||||
|
18
fdqueue.c
18
fdqueue.c
@ -34,8 +34,17 @@ void list_alarms() {
|
||||
DEBUG("Alarms;");
|
||||
time_ms_t now = gettime_ms();
|
||||
struct sched_ent *alarm;
|
||||
|
||||
for (alarm = next_deadline; alarm; alarm = alarm->_next)
|
||||
DEBUGF("%p %s deadline in %lldms",
|
||||
alarm->function, (alarm->stats ? alarm->stats->name : "Unnamed"),
|
||||
alarm->deadline - now);
|
||||
|
||||
for (alarm = next_alarm; alarm; alarm = alarm->_next)
|
||||
DEBUGF("%s in %lldms", (alarm->stats ? alarm->stats->name : "Unnamed"), alarm->alarm - now);
|
||||
DEBUGF("%p %s in %lldms, deadline in %lldms",
|
||||
alarm->function, (alarm->stats ? alarm->stats->name : "Unnamed"),
|
||||
alarm->alarm - now, alarm->deadline - now);
|
||||
|
||||
DEBUG("File handles;");
|
||||
int i;
|
||||
for (i = 0; i < fdcount; ++i)
|
||||
@ -48,7 +57,7 @@ int deadline(struct sched_ent *alarm){
|
||||
alarm->deadline = alarm->alarm;
|
||||
|
||||
while(node!=NULL){
|
||||
if (node->alarm > alarm->alarm)
|
||||
if (node->deadline > alarm->deadline)
|
||||
break;
|
||||
last = node;
|
||||
node = node->_next;
|
||||
@ -56,7 +65,7 @@ int deadline(struct sched_ent *alarm){
|
||||
if (last == NULL){
|
||||
next_deadline = alarm;
|
||||
}else{
|
||||
last->_next=alarm;
|
||||
last->_next = alarm;
|
||||
}
|
||||
alarm->_prev = last;
|
||||
if(node!=NULL)
|
||||
@ -72,6 +81,9 @@ int deadline(struct sched_ent *alarm){
|
||||
int schedule(struct sched_ent *alarm){
|
||||
struct sched_ent *node = next_alarm, *last = NULL;
|
||||
|
||||
if (alarm->_next || alarm->_prev || alarm==next_alarm || alarm==next_deadline)
|
||||
FATAL("Attempted to schedule an alarm that is still scheduled.");
|
||||
|
||||
if (!alarm->function)
|
||||
return WHY("Can't schedule if you haven't set the function pointer");
|
||||
|
||||
|
18
overlay.c
18
overlay.c
@ -128,16 +128,16 @@ int overlayServerMode()
|
||||
of wifi latency anyway, so we'll live with it. Larger values will affect voice transport,
|
||||
and smaller values would affect CPU and energy use, and make the simulation less realistic. */
|
||||
|
||||
time_ms_t now = gettime_ms();
|
||||
|
||||
#define SCHEDULE(X, Y, D) { \
|
||||
static struct sched_ent _sched_##X; \
|
||||
static struct profile_total _stats_##X; \
|
||||
bzero(&_sched_##X, sizeof(struct sched_ent)); \
|
||||
bzero(&_stats_##X, sizeof(struct profile_total)); \
|
||||
_sched_##X.stats = &_stats_##X; \
|
||||
_sched_##X.function=X;\
|
||||
_stats_##X.name="" #X "";\
|
||||
_sched_##X.alarm=gettime_ms()+Y;\
|
||||
_sched_##X.deadline=_sched_##X.alarm+D;\
|
||||
static struct profile_total _stats_##X={.name="" #X "",}; \
|
||||
static struct sched_ent _sched_##X={\
|
||||
.stats = &_stats_##X, \
|
||||
.function=X,\
|
||||
}; \
|
||||
_sched_##X.alarm=(now+Y);\
|
||||
_sched_##X.deadline=(now+Y+D);\
|
||||
schedule(&_sched_##X); }
|
||||
|
||||
/* Periodically check for server shut down */
|
||||
|
Loading…
x
Reference in New Issue
Block a user