Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add slow-speed timeout when downloading mod #611

Merged
merged 7 commits into from
Jan 20, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion NorthstarDLL/mods/autodownload/moddownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,13 @@ void FetchModSync(std::promise<std::optional<fs::path>>&& p, std::string_view ur
CURL* easyhandle;
easyhandle = curl_easy_init();

curl_easy_setopt(easyhandle, CURLOPT_TIMEOUT, 30L);
curl_easy_setopt(easyhandle, CURLOPT_URL, url.data());
curl_easy_setopt(easyhandle, CURLOPT_FAILONERROR, 1L);

/* abort if slower than 30 bytes/sec during 10 seconds */
GeckoEidechse marked this conversation as resolved.
Show resolved Hide resolved
curl_easy_setopt(easyhandle, CURLOPT_LOW_SPEED_TIME, 10L);
curl_easy_setopt(easyhandle, CURLOPT_LOW_SPEED_LIMIT, 30L);

curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, WriteData);
result = curl_easy_perform(easyhandle);
Expand Down