Torrent example: Convert some timeouts from int to chrono
Using seconds because then they all have the same type, even if all-but-one could use minutes. Delete one unused interval value. Task-number: QTBUG-110622 Change-Id: I66b456de8a4b867859e9e2b13ce72e8ec691c79a Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 3fc26dbb2cfe07d1ae0acf4e18b6c94b64e56662) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
a2511182f5
commit
815e4f57c7
@ -7,11 +7,13 @@
|
|||||||
#include <QTimerEvent>
|
#include <QTimerEvent>
|
||||||
#include <QtEndian>
|
#include <QtEndian>
|
||||||
|
|
||||||
static const int PendingRequestTimeout = 60 * 1000;
|
#include <chrono>
|
||||||
static const int ClientTimeout = 120 * 1000;
|
|
||||||
static const int ConnectTimeout = 60 * 1000;
|
static constexpr std::chrono::seconds PendingRequestTimeout(60);
|
||||||
static const int KeepAliveInterval = 30 * 1000;
|
static constexpr std::chrono::seconds ClientTimeout(120);
|
||||||
static const int PeerRateControlTimerDelay = 2000;
|
static constexpr std::chrono::seconds ConnectTimeout(60);
|
||||||
|
static constexpr std::chrono::seconds KeepAliveInterval(30);
|
||||||
|
static constexpr std::chrono::seconds PeerRateControlTimerDelay(2);
|
||||||
static const int MinimalHeaderSize = 48;
|
static const int MinimalHeaderSize = 48;
|
||||||
static const char ProtocolId[] = "BitTorrent protocol";
|
static const char ProtocolId[] = "BitTorrent protocol";
|
||||||
static const char ProtocolIdSize = 19;
|
static const char ProtocolIdSize = 19;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <QNetworkInterface>
|
#include <QNetworkInterface>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
// These constants could also be configurable by the user.
|
// These constants could also be configurable by the user.
|
||||||
static const int ServerMinPort = 6881;
|
static const int ServerMinPort = 6881;
|
||||||
@ -23,10 +24,10 @@ static const int MaxBlocksInProgress = 5;
|
|||||||
static const int MaxBlocksInMultiMode = 2;
|
static const int MaxBlocksInMultiMode = 2;
|
||||||
static const int MaxConnectionPerPeer = 1;
|
static const int MaxConnectionPerPeer = 1;
|
||||||
static const int RateControlWindowLength = 10;
|
static const int RateControlWindowLength = 10;
|
||||||
static const int RateControlTimerDelay = 1000;
|
static const std::chrono::seconds RateControlTimerDelay(1);
|
||||||
static const int MinimumTimeBeforeRevisit = 30;
|
static const int MinimumTimeBeforeRevisit = 30;
|
||||||
static const int MaxUploads = 4;
|
static const int MaxUploads = 4;
|
||||||
static const int UploadScheduleInterval = 10000;
|
static const std::chrono::seconds UploadScheduleInterval(10);
|
||||||
|
|
||||||
struct TorrentPiece {
|
struct TorrentPiece {
|
||||||
QBitArray completedBlocks;
|
QBitArray completedBlocks;
|
||||||
|
@ -153,7 +153,7 @@ void TrackerClient::httpRequestDone(QNetworkReply *reply)
|
|||||||
// Mandatory item
|
// Mandatory item
|
||||||
if (requestIntervalTimer != -1)
|
if (requestIntervalTimer != -1)
|
||||||
killTimer(requestIntervalTimer);
|
killTimer(requestIntervalTimer);
|
||||||
requestIntervalTimer = startTimer(dict.value("interval").toInt() * 1000);
|
requestIntervalTimer = startTimer(std::chrono::seconds(dict.value("interval").toInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dict.contains("peers")) {
|
if (dict.contains("peers")) {
|
||||||
|
@ -51,7 +51,6 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
TorrentClient *torrentDownloader;
|
TorrentClient *torrentDownloader;
|
||||||
|
|
||||||
int requestInterval = 5 * 60;
|
|
||||||
int requestIntervalTimer = -1;
|
int requestIntervalTimer = -1;
|
||||||
QNetworkAccessManager http;
|
QNetworkAccessManager http;
|
||||||
MetaInfo metaInfo;
|
MetaInfo metaInfo;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user