mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
6c335dfcc6
I mean, we still crash, but we give an error now :) lightningd: FATAL SIGNAL 11 (version v0.7.1-82-g92c38a0) 0x5592e75e19c8 send_backtrace common/daemon.c:40 0x5592e75e1a6e crashdump common/daemon.c:53 0x7fad1514ef5f ??? ???:0 0x5592e75b2f3a io_loop_with_timers lightningd/io_loop_with_timers.c:29 0x5592e75d8a54 plugins_init lightningd/plugin.c:1018 0x5592e75b8e22 main lightningd/lightningd.c:671 0x7fad15131b6a ??? ???:0 0x5592e75a10f9 ??? ???:0 0xffffffffffffffff ??? ???:0 Segmentation fault (core dumped) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
40 lines
1.1 KiB
C
40 lines
1.1 KiB
C
#include "lightningd/io_loop_with_timers.h"
|
|
|
|
#include <ccan/io/io.h>
|
|
#include <ccan/timer/timer.h>
|
|
#include <common/timeout.h>
|
|
#include <lightningd/lightningd.h>
|
|
#include <wallet/db.h>
|
|
#include <wallet/wallet.h>
|
|
|
|
void *io_loop_with_timers(struct lightningd *ld)
|
|
{
|
|
void *retval = NULL;
|
|
struct timer *expired;
|
|
|
|
while (!retval) {
|
|
/* ~ccan/io's io_loop() continuously calls
|
|
* io_poll_lightningd() for all file descriptors registered
|
|
* with it, then calls their callbacks or closes them if they
|
|
* fail, as appropriate.
|
|
*
|
|
* It will only exit if there's an expired timer, *or* someone
|
|
* calls io_break, or if there are no more file descriptors
|
|
* (which never happens in our code). */
|
|
retval = io_loop(ld->timers, &expired);
|
|
|
|
/*~ Notice that timers are called here in the event loop like
|
|
* anything else, so there are no weird concurrency issues. */
|
|
if (expired) {
|
|
/* This routine is legal in early startup, too. */
|
|
if (ld->wallet)
|
|
db_begin_transaction(ld->wallet->db);
|
|
timer_expired(ld, expired);
|
|
if (ld->wallet)
|
|
db_commit_transaction(ld->wallet->db);
|
|
}
|
|
}
|
|
|
|
return retval;
|
|
}
|