35
35
#define WINHTTP_OPTION_PEERDIST_EXTENSION_STATE 109
36
36
#define CACHED_POST_BODY_BUF_SIZE 4096
37
37
#define UUID_LENGTH_CCH 32
38
-
38
+ #define TIMEOUT_INFINITE -1
39
+ #define DEFAULT_CONNECT_TIMEOUT 60000
39
40
#ifndef WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH
40
41
#define WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH 0
41
42
#endif
@@ -212,8 +213,8 @@ static int winhttp_stream_connect(winhttp_stream *s)
212
213
BOOL peerdist = FALSE;
213
214
int error = -1 ;
214
215
unsigned long disable_redirects = WINHTTP_DISABLE_REDIRECTS ;
215
- int default_timeout = -1 ;
216
-
216
+ int default_timeout = TIMEOUT_INFINITE ;
217
+ int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT ;
217
218
218
219
/* Prepare URL */
219
220
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)
242
243
goto on_error ;
243
244
}
244
245
245
- WinHttpSetTimeouts (s -> request , default_timeout , default_timeout , default_timeout , default_timeout );
246
-
246
+ if (!WinHttpSetTimeouts (s -> request , default_timeout , default_connect_timeout , default_timeout , default_timeout )) {
247
+ giterr_set (GITERR_OS , "Failed to set timeouts for WinHTTP" );
248
+ goto on_error ;
249
+ }
250
+
247
251
/* Set proxy if necessary */
248
252
if (git_remote__get_http_proxy (t -> owner -> owner , !!t -> connection_data .use_ssl , & proxy_url ) < 0 )
249
253
goto on_error ;
@@ -471,7 +475,8 @@ static int winhttp_connect(
471
475
int32_t port ;
472
476
const char * default_port = "80" ;
473
477
int error = -1 ;
474
- int default_timeout = -1 ;
478
+ int default_timeout = TIMEOUT_INFINITE ;
479
+ int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT ;
475
480
476
481
/* Prepare port */
477
482
if (git__strtol32 (& port , t -> connection_data .port , NULL , 10 ) < 0 )
@@ -496,7 +501,10 @@ static int winhttp_connect(
496
501
goto on_error ;
497
502
}
498
503
499
- WinHttpSetTimeouts (t -> session , default_timeout , default_timeout , default_timeout , default_timeout );
504
+ if (!WinHttpSetTimeouts (t -> session , default_timeout , default_connect_timeout , default_timeout , default_timeout )) {
505
+ giterr_set (GITERR_OS , "Failed to set timeouts for WinHTTP" );
506
+ goto on_error ;
507
+ }
500
508
501
509
502
510
/* Establish connection */
0 commit comments