-/* $OpenBSD: extern.h,v 1.145 2022/08/08 15:22:31 job Exp $ */
+/* $OpenBSD: extern.h,v 1.146 2022/08/09 09:02:26 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
#define MAX_RSYNC_REQUESTS 16
/* How many seconds to wait for a connection to succeed. */
-#define MAX_CONTIMEOUT 15
+#define MAX_CONN_TIMEOUT 15
/* How long to wait for IO from a remote server. */
#define MAX_IO_TIMEOUT 180
-/* $OpenBSD: http.c,v 1.63 2022/08/08 15:22:31 job Exp $ */
+/* $OpenBSD: http.c,v 1.64 2022/08/09 09:02:26 claudio Exp $ */
/*
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
return DONE;
}
+/*
+ * Called in case of connect timeout, try an alternate connection.
+ */
+static enum res
+http_connect_failed(struct http_connection *conn)
+{
+ assert(conn->state == STATE_CONNECT);
+ close(conn->fd);
+ conn->fd = -1;
+
+ return http_connect(conn);
+}
+
/*
* Call the function f and update the connection events based
* on the return value.
if (i >= NPFDS)
errx(1, "too many connections");
- if (conn->io_time == 0)
- conn->io_time = now + MAX_IO_TIMEOUT;
+ if (conn->io_time == 0) {
+ if (conn->state == STATE_CONNECT)
+ conn->io_time = now + MAX_CONN_TIMEOUT;
+ else
+ conn->io_time = now + MAX_IO_TIMEOUT;
+ }
if (conn->io_time <= now)
timeout = 0;
if (conn->pfd != NULL && conn->pfd->revents != 0)
http_do(conn, http_handle);
else if (conn->io_time <= now) {
- warnx("%s: timeout, connection closed",
- http_info(conn->host));
- http_do(conn, http_failed);
+ if (conn->state == STATE_CONNECT) {
+ warnx("%s: connect timeout",
+ http_info(conn->host));
+ http_do(conn, http_connect_failed);
+ } else {
+ warnx("%s: timeout, connection closed",
+ http_info(conn->host));
+ http_do(conn, http_failed);
+ }
}
if (conn->state == STATE_FREE)
-/* $OpenBSD: rsync.c,v 1.40 2022/08/08 15:22:31 job Exp $ */
+/* $OpenBSD: rsync.c,v 1.41 2022/08/09 09:02:26 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
args[i++] = "-rt";
args[i++] = "--no-motd";
args[i++] = "--max-size=" STRINGIFY(MAX_FILE_SIZE);
- args[i++] = "--contimeout=" STRINGIFY(MAX_CONTIMEOUT);
+ args[i++] = "--contimeout=" STRINGIFY(MAX_CONN_TIMEOUT);
args[i++] = "--timeout=" STRINGIFY(MAX_IO_TIMEOUT);
args[i++] = "--include=*/";
args[i++] = "--include=*.cer";