From 8739b4cbe8df292598cbcb8319bc716c388e1710 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 17 May 2018 14:16:22 +0930 Subject: [PATCH] lighningd: Remove --debug-subdaemon-io. We can use SIGUSR1, even in non-developer builds. Signed-off-by: Rusty Russell --- lightningd/lightningd.c | 1 - lightningd/lightningd.h | 3 --- lightningd/options.c | 3 --- lightningd/subd.c | 9 +++------ tests/test_lightningd.py | 8 +++++--- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 448cd805f..8e7f8c7a1 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -78,7 +78,6 @@ static struct lightningd *new_lightningd(const tal_t *ctx) ld->reconnect = true; timers_init(&ld->timers, time_mono()); ld->topology = new_topology(ld, ld->log); - ld->debug_subdaemon_io = NULL; ld->daemon = false; ld->pidfile = NULL; ld->ini_autocleaninvoice_cycle = 0; diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index d3f9b0682..741b35cfd 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -156,9 +156,6 @@ struct lightningd { /* PID file */ char *pidfile; - /* May be useful for non-developers debugging in the field */ - char *debug_subdaemon_io; - /* Initial autocleaninvoice settings. */ u64 ini_autocleaninvoice_cycle; u64 ini_autocleaninvoice_expiredby; diff --git a/lightningd/options.c b/lightningd/options.c index 3dc6d4161..75240d52f 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -368,9 +368,6 @@ static void config_register_opts(struct lightningd *ld) opt_set_bool_arg, opt_show_bool, &deprecated_apis, "Enable deprecated options, JSONRPC commands, fields, etc."); - opt_register_arg("--debug-subdaemon-io", - opt_set_charp, NULL, &ld->debug_subdaemon_io, - "Enable full peer IO logging in subdaemons ending in this string (can also send SIGUSR1 to toggle)"); opt_register_arg("--autocleaninvoice-cycle", opt_set_u64, opt_show_u64, &ld->ini_autocleaninvoice_cycle, diff --git a/lightningd/subd.c b/lightningd/subd.c index f4c69cb92..1a521dcb8 100644 --- a/lightningd/subd.c +++ b/lightningd/subd.c @@ -135,7 +135,6 @@ static void close_taken_fds(va_list *ap) /* We use sockets, not pipes, because fds are bidir. */ static int subd(const char *dir, const char *name, const char *debug_subdaemon, - const char *debug_subdaemon_io, int *msgfd, int dev_disconnect_fd, va_list *ap) { int childmsg[2], execfail[2]; @@ -160,7 +159,7 @@ static int subd(const char *dir, const char *name, int fdnum = 3, i, stdin_is_now = STDIN_FILENO; long max; size_t num_args; - char *args[] = { NULL, NULL, NULL, NULL, NULL }; + char *args[] = { NULL, NULL, NULL, NULL }; close(childmsg[0]); close(execfail[0]); @@ -207,8 +206,6 @@ static int subd(const char *dir, const char *name, if (debug_subdaemon && strends(name, debug_subdaemon)) args[num_args++] = "--debugger"; #endif - if (debug_subdaemon_io && strends(name, debug_subdaemon_io)) - args[num_args++] = "--log-io"; execv(args[0], args); child_errno_fail: @@ -261,7 +258,7 @@ int subd_raw(struct lightningd *ld, const char *name) disconnect_fd = ld->dev_disconnect_fd; #endif /* DEVELOPER */ - pid = subd(ld->daemon_dir, name, debug_subd, ld->debug_subdaemon_io, + pid = subd(ld->daemon_dir, name, debug_subd, &msg_fd, disconnect_fd, NULL); if (pid == (pid_t)-1) { @@ -658,7 +655,7 @@ static struct subd *new_subd(struct lightningd *ld, disconnect_fd = ld->dev_disconnect_fd; #endif /* DEVELOPER */ - sd->pid = subd(ld->daemon_dir, name, debug_subd, ld->debug_subdaemon_io, + sd->pid = subd(ld->daemon_dir, name, debug_subd, &msg_fd, disconnect_fd, ap); if (sd->pid == (pid_t)-1) { log_unusual(ld->log, "subd %s failed: %s", diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index d654e70de..8fbc9a7b7 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -4230,8 +4230,7 @@ class LightningDTests(BaseLightningDTests): l2.daemon.wait_for_log('onchaind complete, forgetting peer') def test_io_logging(self): - l1 = self.node_factory.get_node(options={'debug-subdaemon-io': 'channeld', - 'log-level': 'io'}) + l1 = self.node_factory.get_node(options={'log-level': 'io'}) l2 = self.node_factory.get_node() l1.rpc.connect(l2.info['id'], 'localhost', l2.port) @@ -4250,6 +4249,9 @@ class LightningDTests(BaseLightningDTests): pid2 = re.search(r'pid ([0-9]*),', pidline).group(1) l2.daemon.wait_for_log(' to CHANNELD_NORMAL') + # Send it sigusr1: should turn on logging. + subprocess.run(['kill', '-USR1', pid1]) + fut = self.pay(l1, l2, 200000000, async=True) # WIRE_UPDATE_ADD_HTLC = 128 = 0x0080 @@ -4268,7 +4270,7 @@ class LightningDTests(BaseLightningDTests): assert not l1.daemon.is_in_log(r'channeld.*:\[IN\] 0082', start=l1.daemon.logsearch_start) - # IO logs should appear in peer logs. + # IO logs should not appear in peer logs. peerlog = l2.rpc.listpeers(l1.info['id'], "io")['peers'][0]['log'] assert not any(l['type'] == 'IO_OUT' or l['type'] == 'IO_IN' for l in peerlog)