From f83ee6d5ea0ca800662144aac903d04146b85cc3 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 12 Oct 2017 10:55:28 +1030 Subject: [PATCH] dev_disconnect: don't permfail more than once. The coming tests trigger this latent bug under travis. Signed-off-by: Rusty Russell --- lightningd/subd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lightningd/subd.c b/lightningd/subd.c index 666adb695..872888d88 100644 --- a/lightningd/subd.c +++ b/lightningd/subd.c @@ -645,7 +645,11 @@ bool dev_disconnect_permanent(struct lightningd *ld) r = read(ld->dev_disconnect_fd, permfail, sizeof(permfail)); if (r < 0) fatal("Reading dev_disconnect file: %s", strerror(errno)); - lseek(ld->dev_disconnect_fd, -r, SEEK_CUR); - return memeq(permfail, r, "permfail", strlen("permfail")); + if (memeq(permfail, r, "permfail", strlen("permfail"))) + return true; + + /* Nope, restore. */ + lseek(ld->dev_disconnect_fd, -r, SEEK_CUR); + return false; }