mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-25 12:04:47 +00:00
Fix #2768 - remove completed timers
This commit is contained in:
1 parent
40a2a8822f
commit
0539cf1023
7 files changed
+56
-32
No files matched your search
+8
-4
@@ -1,11 +1,9 @@
|
||||
#include "timer.h"
|
||||
#include "arch.h"
|
||||
|
||||
#define MG_TIMER_CALLED 4
|
||||
#include "timer.h"
|
||||
|
||||
void mg_timer_init(struct mg_timer **head, struct mg_timer *t, uint64_t ms,
|
||||
unsigned flags, void (*fn)(void *), void *arg) {
|
||||
t->id = 0, t->period_ms = ms, t->expire = 0;
|
||||
t->period_ms = ms, t->expire = 0;
|
||||
t->flags = flags, t->fn = fn, t->arg = arg, t->next = *head;
|
||||
*head = t;
|
||||
}
|
||||
@@ -36,5 +34,11 @@ void mg_timer_poll(struct mg_timer **head, uint64_t now_ms) {
|
||||
t->fn(t->arg);
|
||||
}
|
||||
t->flags |= MG_TIMER_CALLED;
|
||||
|
||||
// If this timer is not repeating and marked AUTODELETE, remove it
|
||||
if (!(t->flags & MG_TIMER_REPEAT) && (t->flags & MG_TIMER_AUTODELETE)) {
|
||||
mg_timer_free(head, t);
|
||||
free(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user