summarylogtreecommitdiffstats
path: root/0002-download-retry-on-slow-speed-and-conection-close.patch
blob: 9eee210771ccdfa6b613c5885649917bf73e8af9 (plain)
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
62
From ff4bfdc97c5e3c85e6851f9ef47647600bcee516 Mon Sep 17 00:00:00 2001
From: myfreeer <myfreeer@users.noreply.github.com>
Date: Sat, 18 Nov 2017 11:55:04 +0800
Subject: [PATCH 2/3] 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 2db41e46..f49eb807 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 62862fff..19061732 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 4e7421bc..9f24da88 100644
--- a/src/SocketCore.cc
+++ b/src/SocketCore.cc
@@ -1016,7 +1016,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.43.0