--- a/src/common/beaglequeuecache.cpp
+++ b/src/common/beaglequeuecache.cpp
@@ -40,8 +40,17 @@
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 @@
// 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);