lnsocket

A minimal C library for connecting to the lightning network
git clone git://jb55.com/lnsocket
Log | Files | Refs | Submodules | README | LICENSE

commit fc325ab8ed2782f8e59e25a09331178ef72a413c
parent 72da9c2eac543d4c07f78df9b9a98d028c6b33b0
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 28 Feb 2022 14:14:32 -0800

fix timeout bug

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mlnsocket.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lnsocket.c b/lnsocket.c @@ -492,16 +492,16 @@ int lnsocket_connect_with(struct lnsocket *ln, const char *node_id, const char * // connect to the node! connect(ln->socket, addrs->ai_addr, addrs->ai_addrlen); - ret = select(ln->socket + 1, &set, NULL, NULL, &timeout); + if (!io_fd_block(ln->socket, 1)) + return note_error(&ln->errs, "failed setting socket to blocking"); + + ret = select(ln->socket + 1, NULL, &set, NULL, &timeout); if (ret == -1) { return note_error(&ln->errs, "select error"); } else if (ret == 0) { return note_error(&ln->errs, "connection timeout"); } - if (!io_fd_block(ln->socket, 1)) - return note_error(&ln->errs, "failed setting socket to blocking"); - // prepare some data for ACT1 new_handshake(ln->secp, &h, &their_id);