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

Function timers_expire

ccan/ccan/timer/timer.c:347–384  ·  view source on GitHub ↗

Returns an expired timer. */

Source from the content-addressed store, hash-verified

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

Callers 15

mainFunction · 0.85
mainFunction · 0.85
io_loopFunction · 0.85
mainFunction · 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

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 13

mainFunction · 0.68
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