summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-06-24 17:26:07 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-06-24 17:26:07 +0000
commit003a47435758a976a57c483c37859989105e204e (patch)
treef1b0c17a1e791701f9414c5a1e853857a34112f1
parent722b3f8957e884b759e63366a541b3b61f0bd535 (diff)
2006-06-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/Util.cc (difftv): Added a cast to (long long int). * src/TorrentMan.cc (advertisePiece): Use push_front. (getAdvertisedPieceIndexes): A performance improvement was made. * src/Time.h (getTimeInMicros): Added a cast to (long long int). (getTimeInMillis): Added a cast to (long long int).
-rw-r--r--ChangeLog11
-rw-r--r--src/Time.h4
-rw-r--r--src/TorrentMan.cc7
-rw-r--r--src/Util.cc2
4 files changed, 18 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index f4beecfb..8d6f6b68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,7 +5,12 @@
* src/Time.cc
(isNewer): Use Util::difftv().
-
+ * src/Util.cc
+ (difftv): Added a cast to (long long int).
+ * src/TorrentMan.cc
+ (advertisePiece): Use push_front.
+ (getAdvertisedPieceIndexes): A performance improvement was made.
+
To fix the bug that sends tracker requests without a sleep interval
when the number of connections is less than 15.
@@ -30,6 +35,10 @@
* src/TorrentMan.cc
(getAdvertisedPieceIndexes): Updated the method signature.
+ * src/Time.h
+ (getTimeInMicros): Added a cast to (long long int).
+ (getTimeInMillis): Added a cast to (long long int).
+
* Release 0.5.2
2006-06-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
diff --git a/src/Time.h b/src/Time.h
index 254864f5..84d12332 100644
--- a/src/Time.h
+++ b/src/Time.h
@@ -53,11 +53,11 @@ public:
bool isZero() const { return tv.tv_sec == 0 && tv.tv_usec == 0; }
long long int getTimeInMicros() const {
- return tv.tv_sec*1000*1000+tv.tv_usec;
+ return (long long int)tv.tv_sec*1000*1000+tv.tv_usec;
}
long long int getTimeInMillis() const {
- return tv.tv_sec*1000+tv.tv_usec/1000;
+ return (long long int)tv.tv_sec*1000+tv.tv_usec/1000;
}
// Returns this object's time value in seconds.
diff --git a/src/TorrentMan.cc b/src/TorrentMan.cc
index 1e607dc1..ebdd9f80 100644
--- a/src/TorrentMan.cc
+++ b/src/TorrentMan.cc
@@ -651,7 +651,7 @@ void TorrentMan::onDownloadComplete() {
void TorrentMan::advertisePiece(int cuid, int index) {
HaveEntry entry(cuid, index);
- haves.push_back(entry);
+ haves.push_front(entry);
};
PieceIndexes TorrentMan::getAdvertisedPieceIndexes(int myCuid,
@@ -659,9 +659,12 @@ PieceIndexes TorrentMan::getAdvertisedPieceIndexes(int myCuid,
PieceIndexes indexes;
for(Haves::const_iterator itr = haves.begin(); itr != haves.end(); itr++) {
const Haves::value_type& have = *itr;
- if(have.cuid == myCuid || lastCheckTime.isNewer(have.registeredTime)) {
+ if(have.cuid == myCuid) {
continue;
}
+ if(lastCheckTime.isNewer(have.registeredTime)) {
+ break;
+ }
indexes.push_back(have.index);
}
return indexes;
diff --git a/src/Util.cc b/src/Util.cc
index 7bdfcac8..c48dfc3d 100644
--- a/src/Util.cc
+++ b/src/Util.cc
@@ -94,7 +94,7 @@ long long int Util::difftv(struct timeval tv1, struct timeval tv2) {
if(tv1.tv_sec < tv2.tv_sec || tv1.tv_sec == tv2.tv_sec && tv1.tv_usec < tv2.tv_usec) {
return 0;
}
- return ((tv1.tv_sec-tv2.tv_sec)*1000000+
+ return ((long long int)(tv1.tv_sec-tv2.tv_sec)*1000000+
tv1.tv_usec-tv2.tv_usec);
}