summaryrefslogtreecommitdiff
path: root/src/DHTRoutingTable.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-03-11 14:19:10 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-03-11 14:19:10 +0000
commit852315bf1110e053a3082847fa5351ece436db48 (patch)
treeb5fbf8ca33d98f5d6fa3464b9e6f72a8e2c12571 /src/DHTRoutingTable.cc
parentddb00a944561eabd378785e77f8b05ac58d23d36 (diff)
2008-03-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed high memory footprint when DHT is enabled. This is not a memory leak, but DHTReplaceNodeTask is more frequently queued than it is processed and the queue is getting longer. As a consequence, momory usage is increased. As for a fix, instead of issuing DHTReplaceNodeTask, I've implemented replacement cache in DHTBucket which is described in Kademlia paper. * src/DHTRoutingTable.cc (addNode): Removed the issuing of DHTReplaceNodeTask. * src/DHTBucket.{h, cc} (cacheNode): New function. (getCachedNodes): New function. (dropNode): Push back cached node to _nodes. * test/DHTBucketTest.cc (testCacheNode): New test (testDropNode): New test
Diffstat (limited to 'src/DHTRoutingTable.cc')
-rw-r--r--src/DHTRoutingTable.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/DHTRoutingTable.cc b/src/DHTRoutingTable.cc
index 82386f4e..c811c805 100644
--- a/src/DHTRoutingTable.cc
+++ b/src/DHTRoutingTable.cc
@@ -98,9 +98,9 @@ bool DHTRoutingTable::addNode(const SharedHandle<DHTNode>& node, bool good)
bnode = lbnode;
}
} else {
- if(good && bucket->containsQuestionableNode()) {
- _logger->debug("Issuing ReplaceNodeTask: new node=%s", node->toString().c_str());
- _taskQueue->addImmediateTask(_taskFactory->createReplaceNodeTask(bucket, node));
+ if(good) {
+ bucket->cacheNode(node);
+ _logger->debug("Cached node=%s", node->toString().c_str());
}
return false;
}