From 7586f3ed54c171cd063de8f2b7439b5500d0e9d8 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 1 Nov 2017 11:40:48 +1030 Subject: [PATCH] timers: wrap all calls in transactions. Signed-off-by: Rusty Russell --- lightningd/lightningd.c | 5 ++++- lightningd/test/run-find_my_path.c | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 71268a826..d237b9adf 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -309,8 +309,11 @@ int main(int argc, char *argv[]) if (v == ld) break; - if (expired) + if (expired) { + db_begin_transaction(ld->wallet->db); timer_expired(ld, expired); + db_commit_transaction(ld->wallet->db); + } } shutdown_subdaemons(ld); diff --git a/lightningd/test/run-find_my_path.c b/lightningd/test/run-find_my_path.c index 8372232e2..8700b06d3 100644 --- a/lightningd/test/run-find_my_path.c +++ b/lightningd/test/run-find_my_path.c @@ -7,9 +7,18 @@ int unused_main(int argc, char *argv[]); /* Generated stub for crashlog_activate */ void crashlog_activate(const char *argv0 UNNEEDED, struct log *log UNNEEDED) { fprintf(stderr, "crashlog_activate called!\n"); abort(); } +/* Generated stub for db_begin_transaction */ +bool db_begin_transaction(struct db *db UNNEEDED) +{ fprintf(stderr, "db_begin_transaction called!\n"); abort(); } +/* Generated stub for db_commit_transaction */ +bool db_commit_transaction(struct db *db UNNEEDED) +{ fprintf(stderr, "db_commit_transaction called!\n"); abort(); } /* Generated stub for debug_poll */ int debug_poll(struct pollfd *fds UNNEEDED, nfds_t nfds UNNEEDED, int timeout UNNEEDED) { fprintf(stderr, "debug_poll called!\n"); abort(); } +/* Generated stub for fatal */ +void fatal(const char *fmt UNNEEDED, ...) +{ fprintf(stderr, "fatal called!\n"); abort(); } /* Generated stub for gossip_init */ void gossip_init(struct lightningd *ld UNNEEDED) { fprintf(stderr, "gossip_init called!\n"); abort(); }