diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-04-07 14:26:22 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-04-07 14:26:22 +0000 |
commit | b2c1cbced91182493581960cd5440cc10b651c4a (patch) | |
tree | fc11c78e646455724dda102b4a2832e48f40e243 | |
parent | 1ec2bfb6f3dfa0a3b5f1fa347d7318d7f21a2037 (diff) |
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@
-rw-r--r-- | usr.sbin/rpki-client/http.c | 12 |
1 files changed, 9 insertions, 3 deletions
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 <nils_fisher@hotmail.com> * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org> @@ -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) { |