Skip to content

Commit

Permalink
XrdAdaptor: Fix race condition leading to a crash when doing Prepare …
Browse files Browse the repository at this point in the history
…operation
  • Loading branch information
esindril committed Jan 28, 2021
1 parent cd0fab1 commit 1b23289
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@
#include <atomic>
#include <mutex>

class MakerResponseHandler : public XrdCl::ResponseHandler {
public:
void HandleResponse(XrdCl::XRootDStatus *status, XrdCl::AnyObject *response) override {
// Note: Prepare call has a response object.
delete response;
delete status;
}
};

class XrdStorageMaker final : public StorageMaker {
public:
static const unsigned int XRD_DEFAULT_TIMEOUT = 3 * 60;
Expand Down Expand Up @@ -77,11 +68,14 @@ class XrdStorageMaker final : public StorageMaker {
XrdCl::FileSystem fs(url);
std::vector<std::string> fileList;
fileList.push_back(url.GetPath());
auto status = fs.Prepare(fileList, XrdCl::PrepareFlags::Stage, 0, &m_null_handler);
XrdCl::Buffer *buffer = nullptr;
auto status = fs.Prepare(fileList, XrdCl::PrepareFlags::Stage, 0, buffer);
if (!status.IsOK()) {
edm::LogWarning("StageInError") << "XrdCl::FileSystem::Prepare failed with error '" << status.ToStr()
<< "' (errNo = " << status.errNo << ")";
}

delete buffer;
}

bool check(const std::string &proto,
Expand Down Expand Up @@ -173,7 +167,6 @@ class XrdStorageMaker final : public StorageMaker {
}

private:
CMS_THREAD_SAFE mutable MakerResponseHandler m_null_handler;
mutable std::mutex m_envMutex;
mutable std::atomic<unsigned int> m_lastDebugLevel;
mutable std::atomic<unsigned int> m_lastTimeout;
Expand Down

0 comments on commit 1b23289

Please sign in to comment.