| 6 | #include <lightningd/lightningd.h> |
| 7 | |
| 8 | void *io_loop_with_timers(struct lightningd *ld) |
| 9 | { |
| 10 | void *retval = NULL; |
| 11 | struct timer *expired; |
| 12 | |
| 13 | while (!retval) { |
| 14 | /* ~ccan/io's io_loop() continuously calls |
| 15 | * io_poll_lightningd() for all file descriptors registered |
| 16 | * with it, then calls their callbacks or closes them if they |
| 17 | * fail, as appropriate. |
| 18 | * |
| 19 | * It will only exit if there's an expired timer, *or* someone |
| 20 | * calls io_break, or if there are no more file descriptors |
| 21 | * (which never happens in our code). */ |
| 22 | retval = io_loop(ld->timers, &expired); |
| 23 | |
| 24 | /*~ Notice that timers are called here in the event loop like |
| 25 | * anything else, so there are no weird concurrency issues. */ |
| 26 | if (expired) { |
| 27 | /* This routine is legal in early startup, too. */ |
| 28 | if (ld->wallet) |
| 29 | db_begin_transaction(ld->wallet->db); |
| 30 | timer_expired(expired); |
| 31 | if (ld->wallet) |
| 32 | db_commit_transaction(ld->wallet->db); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | return retval; |
| 37 | } |
no test coverage detected