Skip to content

Commit

Permalink
Merge pull request #23 from stfc/master
Browse files Browse the repository at this point in the history
null ptr fix
  • Loading branch information
Jo-stfc authored Feb 3, 2025
2 parents 4019669 + 582009a commit ffed5a7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/XrdPfc/XrdPfc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,13 @@ int Cache::ConsiderCached(const char *curl)
auto it = m_active.find(f_name);
if (it != m_active.end()) {
file = it->second;
inc_ref_cnt(file, false, false);
// If the file-open is in progress, `file` is a nullptr
// so we cannot increase the reference count. For now,
// simply treat it as if the file open doesn't exist instead
// of trying to wait and see if it succeeds.
if (file) {
inc_ref_cnt(file, false, false);
}
}
}
if (file) {
Expand Down Expand Up @@ -1123,7 +1129,12 @@ int Cache::Stat(const char *curl, struct stat &sbuff)
auto it = m_active.find(f_name);
if (it != m_active.end()) {
file = it->second;
inc_ref_cnt(file, false, false);
// If `file` is nullptr, the file-open is in progress; instead
// of waiting for the file-open to finish, simply treat it as if
// the file-open doesn't exist.
if (file) {
inc_ref_cnt(file, false, false);
}
}
}
if (file) {
Expand Down

0 comments on commit ffed5a7

Please sign in to comment.