Browse Source

utils: add subdaemon_shutdown() to consolidate subdaemon cleanup.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
20bbd92564
  1. 2
      channeld/channel.c
  2. 2
      closingd/closing.c
  3. 6
      common/subdaemon.c
  4. 3
      common/subdaemon.h
  5. 1
      gossipd/gossip.c
  6. 2
      hsmd/hsm.c
  7. 2
      onchaind/onchain.c
  8. 2
      openingd/opening.c

2
channeld/channel.c

@ -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;
}

2
closingd/closing.c

@ -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;
}

6
common/subdaemon.c

@ -101,3 +101,9 @@ void subdaemon_setup(int argc, char *argv[])
}
#endif
}
void subdaemon_shutdown(void)
{
tal_free(tmpctx);
secp256k1_context_destroy(secp256k1_ctx);
}

3
common/subdaemon.h

@ -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 */

1
gossipd/gossip.c

@ -2147,6 +2147,7 @@ int main(int argc, char *argv[])
timer_expired(daemon, expired);
}
}
subdaemon_shutdown();
return 0;
}
#endif

2
hsmd/hsm.c

@ -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

2
onchaind/onchain.c

@ -2315,7 +2315,7 @@ int main(int argc, char *argv[])
/* We're done! */
tal_free(ctx);
tal_free(tmpctx);
subdaemon_shutdown();
return 0;
}

2
openingd/opening.c

@ -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 */

Loading…
Cancel
Save