mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 14:54:26 +01:00
utils: add subdaemon_shutdown() to consolidate subdaemon cleanup.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
26f7014813
commit
20bbd92564
@@ -2753,6 +2753,6 @@ int main(int argc, char *argv[])
|
||||
/* We only exit when shutdown is complete. */
|
||||
assert(shutdown_complete(peer));
|
||||
send_shutdown_complete(peer);
|
||||
tal_free(tmpctx);
|
||||
subdaemon_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ int main(int argc, char *argv[])
|
||||
wire_sync_write(REQ_FD,
|
||||
take(towire_closing_complete(NULL, gossip_index)));
|
||||
tal_free(ctx);
|
||||
tal_free(tmpctx);
|
||||
subdaemon_shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -101,3 +101,9 @@ void subdaemon_setup(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void subdaemon_shutdown(void)
|
||||
{
|
||||
tal_free(tmpctx);
|
||||
secp256k1_context_destroy(secp256k1_ctx);
|
||||
}
|
||||
|
||||
@@ -4,4 +4,7 @@
|
||||
|
||||
void subdaemon_setup(int argc, char *argv[]);
|
||||
|
||||
/* Shutdown for a valgrind-clean exit (frees everything) */
|
||||
void subdaemon_shutdown(void);
|
||||
|
||||
#endif /* LIGHTNING_COMMON_SUBDAEMON_H */
|
||||
|
||||
@@ -2147,6 +2147,7 @@ int main(int argc, char *argv[])
|
||||
timer_expired(daemon, expired);
|
||||
}
|
||||
}
|
||||
subdaemon_shutdown();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -842,6 +842,8 @@ int main(int argc, char *argv[])
|
||||
/* When conn closes, everything is freed. */
|
||||
tal_steal(client->dc.conn, client);
|
||||
io_loop(NULL, NULL);
|
||||
subdaemon_shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2315,7 +2315,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* We're done! */
|
||||
tal_free(ctx);
|
||||
tal_free(tmpctx);
|
||||
subdaemon_shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -776,7 +776,7 @@ int main(int argc, char *argv[])
|
||||
status_trace("Sent %s with fd",
|
||||
opening_wire_type_name(fromwire_peektype(msg)));
|
||||
tal_free(state);
|
||||
tal_free(tmpctx);
|
||||
subdaemon_shutdown();
|
||||
return 0;
|
||||
}
|
||||
#endif /* TESTING */
|
||||
|
||||
Reference in New Issue
Block a user