Add a timeout for http download

Download profile from AS or URL use blocking network calls
in the main thread. Set reasonable timeouts for connect
and receive.

TODO: This is not perfect as the download can still stall
in erratic links, and we have no way to abort. Ideally
we should either use Async calls and/or threads.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/449/head
Selva Nair 3 years ago
parent 4e223916ae
commit 69195ee6b1

@ -328,6 +328,11 @@ DownloadProfile(HANDLE hWnd, const struct UrlComponents *comps, const char *user
goto done;
}
/* Calls to connect and receive block: set timeouts that are not too long */
unsigned long timeout = 30000; /* 30 seconds */
InternetSetOption(hInternet, INTERNET_OPTION_CONNECT_TIMEOUT, &timeout, sizeof(timeout));
InternetSetOption(hInternet, INTERNET_OPTION_RECEIVE_TIMEOUT, &timeout, sizeof(timeout));
/* wait cursor will be automatically reverted later */
SetCursor(LoadCursorW(0, IDC_WAIT));

Loading…
Cancel
Save