diff --git a/connectd/connectd.c b/connectd/connectd.c index 7f8f763b6..cc71b6254 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -1523,8 +1523,12 @@ static void connect_init(struct daemon *daemon, const u8 *msg) tal_free(announceable); #if DEVELOPER - if (dev_disconnect) + if (dev_disconnect) { + daemon->dev_disconnect_fd = 5; dev_disconnect_init(5); + } else { + daemon->dev_disconnect_fd = -1; + } #endif } diff --git a/connectd/connectd.h b/connectd/connectd.h index 763846adc..8605155fc 100644 --- a/connectd/connectd.h +++ b/connectd/connectd.h @@ -201,6 +201,8 @@ struct daemon { bool dev_no_ping_timer; /* Hack to no longer send gossip */ bool dev_suppress_gossip; + /* dev_disconnect file */ + int dev_disconnect_fd; #endif }; diff --git a/connectd/multiplex.c b/connectd/multiplex.c index 6ead62fa9..f8eeb31b7 100644 --- a/connectd/multiplex.c +++ b/connectd/multiplex.c @@ -315,7 +315,6 @@ static void set_urgent_flag(struct peer *peer, bool urgent) int val; int opt; const char *optname; - static bool complained = false; if (urgent == peer->urgent) return; @@ -337,14 +336,12 @@ static void set_urgent_flag(struct peer *peer, bool urgent) val = urgent; if (setsockopt(io_conn_fd(peer->to_peer), - IPPROTO_TCP, opt, &val, sizeof(val)) != 0) { - /* This actually happens in testing, where we blackhole the fd */ - if (!complained) { - status_unusual("setsockopt %s=1: %s", - optname, - strerror(errno)); - complained = true; - } + IPPROTO_TCP, opt, &val, sizeof(val)) != 0 + /* This actually happens in testing, where we blackhole the fd */ + && IFDEV(peer->daemon->dev_disconnect_fd == -1, true)) { + status_broken("setsockopt %s=1 fd=%u: %s", + optname, io_conn_fd(peer->to_peer), + strerror(errno)); } peer->urgent = urgent; }