table: allow setting CS capacity limit to zero
refs #3503
Change-Id: I6e1bfb64ea3a1f31070a7290c250fbcec46623fb
diff --git a/daemon/table/cs-policy.cpp b/daemon/table/cs-policy.cpp
index 9726269..3d22c1e 100644
--- a/daemon/table/cs-policy.cpp
+++ b/daemon/table/cs-policy.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -41,9 +41,7 @@
void
Policy::setLimit(size_t nMaxEntries)
{
- BOOST_ASSERT(nMaxEntries > 0);
m_limit = nMaxEntries;
-
this->evictEntries();
}
diff --git a/daemon/table/cs.cpp b/daemon/table/cs.cpp
index 4550361..19df21a 100644
--- a/daemon/table/cs.cpp
+++ b/daemon/table/cs.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -78,17 +78,22 @@
m_policy->setLimit(limit);
}
-bool
+void
Cs::insert(const Data& data, bool isUnsolicited)
{
NFD_LOG_DEBUG("insert " << data.getName());
+ if (m_policy->getLimit() == 0) {
+ // shortcut for disabled CS
+ return;
+ }
+
// recognize CachePolicy
shared_ptr<lp::CachePolicyTag> tag = data.getTag<lp::CachePolicyTag>();
if (tag != nullptr) {
lp::CachePolicyType policy = tag->get().getPolicy();
if (policy == lp::CachePolicyType::NO_CACHE) {
- return false;
+ return;
}
}
@@ -111,8 +116,6 @@
else {
m_policy->afterInsert(it);
}
-
- return true;
}
void
diff --git a/daemon/table/cs.hpp b/daemon/table/cs.hpp
index 5a24bde..3a9b1ca 100644
--- a/daemon/table/cs.hpp
+++ b/daemon/table/cs.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -69,9 +69,8 @@
Cs(size_t nMaxPackets = 10, unique_ptr<Policy> policy = makeDefaultPolicy());
/** \brief inserts a Data packet
- * \return true
*/
- bool
+ void
insert(const Data& data, bool isUnsolicited = false);
typedef std::function<void(const Interest&, const Data& data)> HitCallback;