Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XrdAdaptor: Fix race condition leading to a crash when doing Prepare … #32763

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 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,7 +68,11 @@ 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 *raw_buffer = nullptr;
auto status = fs.Prepare(fileList, XrdCl::PrepareFlags::Stage, 0, raw_buffer);
std::unique_ptr<XrdCl::Buffer> smart_buffer(raw_buffer);
raw_buffer = nullptr;

if (!status.IsOK()) {
edm::LogWarning("StageInError") << "XrdCl::FileSystem::Prepare failed with error '" << status.ToStr()
<< "' (errNo = " << status.errNo << ")";
Expand Down Expand Up @@ -173,7 +168,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