From: claudio Date: Wed, 7 Apr 2021 14:26:21 +0000 (+0000) Subject: Handle bind() failure like connect() or socket() failure and try next X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=dc8fd1cb3801c6f64cbc1e25722d9ed9676627eb;p=openbsd Handle bind() failure like connect() or socket() failure and try next address if available. No other tools consider bind() errors as non-fatal warnings so rpki-client should not behave different. OK tb@ --- diff --git a/usr.sbin/rpki-client/http.c b/usr.sbin/rpki-client/http.c index 284c00bc5bd..58067ee2bb4 100644 --- a/usr.sbin/rpki-client/http.c +++ b/usr.sbin/rpki-client/http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: http.c,v 1.18 2021/04/06 12:35:24 claudio Exp $ */ +/* $OpenBSD: http.c,v 1.19 2021/04/07 14:26:21 claudio Exp $ */ /* * Copyright (c) 2020 Nils Fisher * Copyright (c) 2020 Claudio Jeker @@ -493,8 +493,14 @@ http_connect(struct http_connection *conn) if (http_bindaddr.ss_family == res->ai_family) { if (bind(conn->fd, (struct sockaddr *)&http_bindaddr, - res->ai_addrlen) == -1) - warn("%s: bind", http_info(conn->url)); + res->ai_addrlen) == -1) { + save_errno = errno; + close(conn->fd); + conn->fd = -1; + errno = save_errno; + cause = "bind"; + continue; + } } if (connect(conn->fd, res->ai_addr, res->ai_addrlen) == -1) {