From f72a08c80261296f2649bb04c2f3b2552636d404 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Fri, 11 Mar 2022 12:08:59 -0800 Subject: [PATCH] websocketd: fix random failures by blocking stdin reads Example request that is dying: NEW REQUEST! lightning_websocketd:main [1955685] <-- bad request from safari read 507 write_all 1 -> websocket_to_lightningd -> read_payload_header read 2 read_all 1 read -11 <--- This tried to read a part of the header, is this -EAGAIN? read_all 0 should we be blocking on these reads? *dies* Fixes #5089 Changelog-Fixed: `experimental-websocket` intermittent read errors fixed Signed-off-by: William Casarin --- connectd/websocketd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/connectd/websocketd.c b/connectd/websocketd.c index 324a17f79..9dc65bec2 100644 --- a/connectd/websocketd.c +++ b/connectd/websocketd.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -326,6 +327,7 @@ int main(int argc, char *argv[]) errx(1, "Usage: %s", argv[0]); /* Do HTTP-style negotiation to get into websocket frames. */ + io_fd_block(STDIN_FILENO, true); http_upgrade(STDIN_FILENO); pfds[0].fd = STDIN_FILENO;