-
Notifications
You must be signed in to change notification settings - Fork 33
/
aria2-0003-download-retry-on-slow-speed-and-reset.patch
62 lines (57 loc) · 2.44 KB
/
aria2-0003-download-retry-on-slow-speed-and-reset.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From 66524bee738e98742c908d93c993d0a78a2d9891 Mon Sep 17 00:00:00 2001
From: myfreeer <[email protected]>
Date: Sat, 18 Nov 2017 11:55:04 +0800
Subject: [PATCH 3/4] download: retry on slow speed and conection close
This would provide better speed on bad network conditions
---
src/DownloadCommand.cc | 2 +-
src/SocketBuffer.cc | 3 ++-
src/SocketCore.cc | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc
index 2db41e4..f49eb80 100644
--- a/src/DownloadCommand.cc
+++ b/src/DownloadCommand.cc
@@ -306,7 +306,7 @@ void DownloadCommand::checkLowestDownloadSpeed() const
startupIdleTime_) {
int nowSpeed = peerStat_->calculateDownloadSpeed();
if (nowSpeed <= lowestDownloadSpeedLimit_) {
- throw DL_ABORT_EX2(fmt(EX_TOO_SLOW_DOWNLOAD_SPEED, nowSpeed,
+ throw DL_RETRY_EX2(fmt(EX_TOO_SLOW_DOWNLOAD_SPEED, nowSpeed,
lowestDownloadSpeedLimit_,
getRequest()->getHost().c_str()),
error_code::TOO_SLOW_DOWNLOAD_SPEED);
diff --git a/src/SocketBuffer.cc b/src/SocketBuffer.cc
index 62862ff..1906173 100644
--- a/src/SocketBuffer.cc
+++ b/src/SocketBuffer.cc
@@ -39,6 +39,7 @@
#include "SocketCore.h"
#include "DlAbortEx.h"
+#include "DlRetryEx.h"
#include "message.h"
#include "fmt.h"
#include "LogFactory.h"
@@ -158,7 +159,7 @@ ssize_t SocketBuffer::send()
}
ssize_t slen = socket_->writeVector(iov, num);
if (slen == 0 && !socket_->wantRead() && !socket_->wantWrite()) {
- throw DL_ABORT_EX(fmt(EX_SOCKET_SEND, "Connection closed."));
+ throw DL_RETRY_EX(fmt(EX_SOCKET_SEND, "Connection closed."));
}
// A2_LOG_NOTICE(fmt("num=%zu, amount=%d, bufq.size()=%zu, SEND=%d",
// num, amount, bufq_.size(), slen));
diff --git a/src/SocketCore.cc b/src/SocketCore.cc
index 77dc30c..537375a 100644
--- a/src/SocketCore.cc
+++ b/src/SocketCore.cc
@@ -1009,7 +1009,7 @@ bool SocketCore::tlsHandshake(TLSContext* tlsctx, const std::string& hostname)
if (rv == TLS_ERR_ERROR) {
// Damn those error.
- throw DL_ABORT_EX(fmt("SSL/TLS handshake failure: %s",
+ throw DL_RETRY_EX(fmt("SSL/TLS handshake failure: %s",
handshakeError.empty()
? tlsSession_->getLastErrorString().c_str()
: handshakeError.c_str()));
--
2.17.1