summaryrefslogtreecommitdiff
path: root/src/DownloadEngine.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-05-08 13:18:25 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-05-08 13:18:25 +0000
commit2c54667beb2b05fe20a51f5e89fa3cb5e7d515f6 (patch)
treed2dbb73c27ba90ffc94a1d23497ec9dc8e8a5c22 /src/DownloadEngine.h
parent8fab8859b124926138d26562c2b525e4a938cb23 (diff)
2008-05-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added timeout to socket pool. The default timeout is 15 seconds, which is the same value Apache uses. * src/DownloadEngine.cc * src/DownloadEngine.h
Diffstat (limited to 'src/DownloadEngine.h')
-rw-r--r--src/DownloadEngine.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/DownloadEngine.h b/src/DownloadEngine.h
index 70bd1f90..746b68a6 100644
--- a/src/DownloadEngine.h
+++ b/src/DownloadEngine.h
@@ -39,6 +39,7 @@
#include "SharedHandle.h"
#include "Command.h"
#include "a2netcompat.h"
+#include "TimeA2.h"
#include <deque>
#include <map>
@@ -107,8 +108,26 @@ private:
bool _haltRequested;
- // key = IP address:port, value = Socket
- std::multimap<std::string, SharedHandle<SocketCore> > _socketPool;
+ class SocketPoolEntry {
+ private:
+ SharedHandle<SocketCore> _socket;
+
+ time_t _timeout;
+
+ Time _registeredTime;
+ public:
+ SocketPoolEntry(const SharedHandle<SocketCore>& socket,
+ time_t timeout);
+
+ ~SocketPoolEntry();
+
+ bool isTimeout() const;
+
+ SharedHandle<SocketCore> getSocket() const;
+ };
+
+ // key = IP address:port, value = SocketPoolEntry
+ std::multimap<std::string, SocketPoolEntry> _socketPool;
void shortSleep() const;
bool addSocket(const SocketEntry& socketEntry);
@@ -178,7 +197,7 @@ public:
void addRoutineCommand(Command* command);
void poolSocket(const std::string& ipaddr, uint16_t port,
- const SharedHandle<SocketCore>& sock);
+ const SharedHandle<SocketCore>& sock, time_t timeout = 15);
SharedHandle<SocketCore> popPooledSocket(const std::string& ipaddr,
uint16_t port);