Remove improper assertion use from beagle cache handling code

This commit is contained in:
Jean-Francois Dockes
2012-09-13 09:44:47 +02:00
parent 3dfaa7525b
commit c030a15780
3 changed files with 84 additions and 24 deletions
+20 -5
View File
@@ -40,8 +40,17 @@ BeagleQueueCache::BeagleQueueCache(RclConfig *cnf)
int maxmbs = 40;
cnf->getConfParam("webcachemaxmbs", &maxmbs);
m_cache = new CirCache(ccdir);
m_cache->create(off_t(maxmbs)*1000*1024, CirCache::CC_CRUNIQUE);
if ((m_cache = new CirCache(ccdir)) == 0) {
LOGERR(("BeagleQueueCache: cant create CirCache object\n"));
return;
}
if (!m_cache->create(off_t(maxmbs)*1000*1024, CirCache::CC_CRUNIQUE)) {
LOGERR(("BeagleQueueCache: cache file creation failed: %s\n",
m_cache->getReason().c_str()));
delete m_cache;
m_cache = 0;
return;
}
}
BeagleQueueCache::~BeagleQueueCache()
@@ -52,12 +61,18 @@ BeagleQueueCache::~BeagleQueueCache()
// Read document from cache. Return the metadata as an Rcl::Doc
// @param htt Beagle Hit Type
bool BeagleQueueCache::getFromCache(const string& udi, Rcl::Doc &dotdoc,
string& data, string *htt)
string& data, string *htt)
{
string dict;
if (!m_cache->get(udi, dict, data))
return false;
if (m_cache == 0) {
LOGERR(("BeagleQueueCache::getFromCache: cache is null\n"));
return false;
}
if (!m_cache->get(udi, dict, data)) {
LOGDEB(("BeagleQueueCache::getFromCache: get failed\n"));
return false;
}
ConfSimple cf(dict, 1);