MCPcopy Create free account
hub / github.com/ElementsProject/lightning / timers_expire

Function timers_expire

ccan/ccan/timer/timer.c:340–374  ·  view source on GitHub ↗

Returns an expired timer. */

Source from the content-addressed store, hash-verified

338
339/* Returns an expired timer. */
340struct timer *timers_expire(struct timers *timers, struct timemono expire)
341{
342 uint64_t now = time_to_grains(expire);
343 unsigned int off;
344 struct timer *t;
345
346 /* This can happen without TIME_HAVE_MONOTONIC, but I also have
347 * a report of OpenBSD 6.8 under virtualbox doing this. */
348 if (now < timers->base) {
349 return NULL;
350 }
351
352 if (!timers->level[0]) {
353 if (list_empty(&timers->far))
354 return NULL;
355 add_level(timers, 0);
356 }
357
358 do {
359 if (timers->first > now) {
360 timer_fast_forward(timers, now);
361 return NULL;
362 }
363
364 timer_fast_forward(timers, timers->first);
365 off = timers->base % PER_LEVEL;
366
367 /* This *may* be NULL, if we deleted the first timer */
368 t = list_pop(&timers->level[0]->list[off], struct timer, list);
369 if (t)
370 list_node_init(&t->list);
371 } while (!t && update_first(timers));
372
373 return t;
374}
375
376static bool timer_list_check(const struct list_head *l,
377 uint64_t min, uint64_t max, uint64_t first,

Callers 14

mainFunction · 0.85
mainFunction · 0.85
io_loopFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
update_and_expireFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 5

time_to_grainsFunction · 0.85
add_levelFunction · 0.85
timer_fast_forwardFunction · 0.85
list_node_initFunction · 0.85
update_firstFunction · 0.85

Tested by 11

mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
update_and_expireFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68