Commit 86d0a53c by Rafal Nowosielski Committed by Rafal Nowosielski

Set timeout on remote (WinHTTP) should return error in case of failure.…

Set timeout on remote (WinHTTP) should return error in case of failure. Connection timeout set to 1 minute. Read/Write timeout remains set to infinite #2147
parent 2db71194
......@@ -35,7 +35,8 @@
#define WINHTTP_OPTION_PEERDIST_EXTENSION_STATE 109
#define CACHED_POST_BODY_BUF_SIZE 4096
#define UUID_LENGTH_CCH 32
#define TIMEOUT_INFINITE -1
#define DEFAULT_CONNECT_TIMEOUT 60000
#ifndef WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH
#define WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH 0
#endif
......@@ -212,8 +213,8 @@ static int winhttp_stream_connect(winhttp_stream *s)
BOOL peerdist = FALSE;
int error = -1;
unsigned long disable_redirects = WINHTTP_DISABLE_REDIRECTS;
int default_timeout = -1;
int default_timeout = TIMEOUT_INFINITE;
int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
/* Prepare URL */
git_buf_printf(&buf, "%s%s", t->connection_data.path, s->service_url);
......@@ -242,8 +243,11 @@ static int winhttp_stream_connect(winhttp_stream *s)
goto on_error;
}
WinHttpSetTimeouts(s->request, default_timeout, default_timeout, default_timeout, default_timeout);
if (!WinHttpSetTimeouts(s->request, default_timeout, default_connect_timeout, default_timeout, default_timeout)) {
giterr_set(GITERR_OS, "Failed to set timeouts for WinHTTP");
goto on_error;
}
/* Set proxy if necessary */
if (git_remote__get_http_proxy(t->owner->owner, !!t->connection_data.use_ssl, &proxy_url) < 0)
goto on_error;
......@@ -471,7 +475,8 @@ static int winhttp_connect(
int32_t port;
const char *default_port = "80";
int error = -1;
int default_timeout = -1;
int default_timeout = TIMEOUT_INFINITE;
int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
/* Prepare port */
if (git__strtol32(&port, t->connection_data.port, NULL, 10) < 0)
......@@ -496,7 +501,10 @@ static int winhttp_connect(
goto on_error;
}
WinHttpSetTimeouts(t->session, default_timeout, default_timeout, default_timeout, default_timeout);
if (!WinHttpSetTimeouts(t->session, default_timeout, default_connect_timeout, default_timeout, default_timeout)) {
giterr_set(GITERR_OS, "Failed to set timeouts for WinHTTP");
goto on_error;
}
/* Establish connection */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment