summaryrefslogtreecommitdiff
path: root/src/DownloadEngineFactory.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-11-11 22:31:00 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-11-11 22:31:00 +0900
commitaf98861aff50737f87d9c251ee9a68280bba3e64 (patch)
treeefcac3dff10dde209b83ded6ef798f83a90fc684 /src/DownloadEngineFactory.cc
parent269520ee69e2306eaf792ccff916ba5486d2bb5f (diff)
Evict timed out pooled socket periodically
Previously we only scanned pool socket to check they are timed out when we pooled another socket. This means that pooled socket is not closed long time (stays in CLOSE-WAIT state) if we don't pool any more socket. In this commit, we now check pooled socket periodically (30 seconds) to avoid the sockets hanging in CLOSE-WAIT state long time. See GH-477
Diffstat (limited to 'src/DownloadEngineFactory.cc')
-rw-r--r--src/DownloadEngineFactory.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/DownloadEngineFactory.cc b/src/DownloadEngineFactory.cc
index 6f07c2f6..8bc96e19 100644
--- a/src/DownloadEngineFactory.cc
+++ b/src/DownloadEngineFactory.cc
@@ -57,6 +57,7 @@
#include "a2io.h"
#include "DownloadContext.h"
#include "array_fun.h"
+#include "EvictSocketPoolCommand.h"
#ifdef HAVE_LIBUV
# include "LibuvEventPoll.h"
#endif // HAVE_LIBUV
@@ -164,6 +165,8 @@ DownloadEngineFactory::newDownloadEngine
e->addRoutineCommand(make_unique<CheckIntegrityDispatcherCommand>
(e->newCUID(), e->getCheckIntegrityMan().get(),
e.get()));
+ e->addRoutineCommand(make_unique<EvictSocketPoolCommand>
+ (e->newCUID(), e.get(), 30_s));
if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
e->addRoutineCommand(make_unique<AutoSaveCommand>(