Browse Source

lightningd: require explicit LIGHTNINGD_DEV_MEMLEAK env var to do memleak.

Otherwise every allocation and free is slowed down.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
e695e5db09
  1. 3
      lightningd/lightningd.c
  2. 4
      lightningd/memdump.c
  3. 1
      tests/test_lightningd.py

3
lightningd/lightningd.c

@ -74,7 +74,8 @@ static struct lightningd *new_lightningd(const tal_t *ctx,
ld->dev_disconnect_fd = -1;
ld->dev_hsm_seed = NULL;
ld->dev_subdaemon_fail = false;
memleak_init(ld, backtrace_state);
if (getenv("LIGHTNINGD_DEV_MEMLEAK"))
memleak_init(ld, backtrace_state);
#endif
list_head_init(&ld->peers);

4
lightningd/memdump.c

@ -144,6 +144,10 @@ static void json_memleak(struct command *cmd,
{
struct json_result *response = new_json_result(cmd);
if (!getenv("LIGHTNINGD_DEV_MEMLEAK"))
command_fail(cmd,
"Leak detection needs $LIGHTNINGD_DEV_MEMLEAK");
json_object_start(response, NULL);
scan_mem(cmd, response, cmd->ld);
json_object_end(response);

1
tests/test_lightningd.py

@ -108,6 +108,7 @@ class NodeFactory(object):
daemon.cmd_line.append("--dev-disconnect=dev_disconnect")
if DEVELOPER:
daemon.cmd_line.append("--dev-fail-on-subdaemon-fail")
daemon.env["LIGHTNINGD_DEV_MEMLEAK"] = "1"
if VALGRIND:
daemon.env["LIGHTNINGD_DEV_NO_BACKTRACE"] = "1"
opts = [] if options is None else options

Loading…
Cancel
Save