Skip to content

Commit

Permalink
XrdApps::JCache: fix memory leaks found with valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
apeters1971 committed Jun 14, 2024
1 parent 3811a38 commit ae53d20
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/XrdApps/XrdClJCachePlugin/file/CacheStats.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct CacheStats {
struct timeval now;
gettimeofday(&now, nullptr);
startTime = now.tv_sec + now.tv_usec / 1000000.0;
dumperInterval=0;
}

~CacheStats() {
Expand Down
8 changes: 5 additions & 3 deletions src/XrdApps/XrdClJCachePlugin/file/XrdClJCacheFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ XRootDStatus JCacheFile::Stat(bool force, ResponseHandler *handler,

if (pFile) {
if (!force && mOpenAsync) {
// let's create a stat response using the cache
AnyObject *obj = new AnyObject();
std::string id = pUrl;
if (sEnableJournalCache && AttachForRead() && mOpenAsync) {
// let's create a stat response using the cache
AnyObject *obj = new AnyObject();
std::string id = pUrl;
auto statInfo = new StatInfo(id, pJournal->getHeaderFileSize(), 0, pJournal->getHeaderMtime());
obj->Set(statInfo);
XRootDStatus *ret_st = new XRootDStatus(XRootDStatus(stOK, 0));
Expand Down Expand Up @@ -577,10 +577,12 @@ bool JCacheFile::AttachForRead() {
mLog->Error(1, "JCache : failed to attach to cache file: %s",
pJournalPath.c_str());
mAttachedForRead = true;
delete sinfo;
return false;
} else {
mLog->Info(1, "JCache : attached to cache file: %s",
pJournalPath.c_str());
delete sinfo;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public:
}
}
handler->HandleResponse(pStatus, pResponse);
delete this;
}

XrdCl::ResponseHandler *handler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public:
}
}
handler->HandleResponse(pStatus, pResponse);
delete this;
}

XrdCl::ResponseHandler *handler;
Expand Down

0 comments on commit ae53d20

Please sign in to comment.