libfetch: Fix handling of connection failures

After commit 848f360c8f, if one tries to connect to a closed port,
fetch reports "Operation now in progress", which is rather confusing.
Return a more useful error message, restoring the old behaviour.

Fixes:		848f360c8f ("libfetch: Apply timeout to connection attempts")
Reviewed by:	des
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D58481
This commit is contained in:
Mark Johnston committed 2026-07-27 23:03:16 +00:00
1 parent d93d235291
commit b02e02958d
1 file changed
+4
+4
View File
@@ -681,6 +681,10 @@ fetch_connect(const char *host, int port, int af, int verbose)
delta.tv_usec / 1000;
}
}
if (pfd.revents & POLLHUP) {
errno = ECONNREFUSED;
break;
}
if (pfd.revents == POLLOUT) {
/* connection established */
err = 0;