Skip to content

Commit

Permalink
[fix/ISSUE-39] Increase curl timeout and catch sigpipe (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
azihassan authored Dec 1, 2023
1 parent 5e36023 commit ae483a0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ import cache : Cache;

pragma(lib, "curl");

version(linux)
{
import core.sys.posix.signal;
import core.stdc.stdio;

extern(C) void signalHandler(int signal) nothrow @nogc
{
printf("Caught signal %d\n", signal);
}
}

void main(string[] args)
{
int itag = 18;
Expand All @@ -27,6 +38,11 @@ void main(string[] args)
bool noProgress;
bool noCache;

version(linux)
{
signal(SIGPIPE, &signalHandler);
}

auto help = args.getopt(
std.getopt.config.passThrough,
std.getopt.config.caseSensitive,
Expand Down
3 changes: 3 additions & 0 deletions source/downloaders.d
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class RegularDownloader : Downloader
http.set(CurlOption.referer, referer);
http.set(CurlOption.followlocation, true);
http.set(CurlOption.failonerror, true);
http.set(CurlOption.timeout, 60 * 3);
http.set(CurlOption.connecttimeout, 60 * 3);
http.set(CurlOption.nosignal, true);

http.onReceiveHeader = (in char[] header) {
logger.displayVerbose(header);
Expand Down

0 comments on commit ae483a0

Please sign in to comment.