From 5cb376d490160a2146f470ce28e404c307f7e8a5 Mon Sep 17 00:00:00 2001 From: Cedric CAFFY <cedric.caffy@cern.ch> Date: Wed, 6 Nov 2019 13:53:44 +0100 Subject: [PATCH] Corrected cta-objectstore-initialize program. The agent needed to initialize the objectstore was not locked so could not be deleted. If this program fails for whatever reason, it will return EXIT_FAILURE and not EXIT_SUCCESS --- objectstore/cta-objectstore-initialize.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/objectstore/cta-objectstore-initialize.cpp b/objectstore/cta-objectstore-initialize.cpp index 1ad3f10416..ee9e6193b2 100644 --- a/objectstore/cta-objectstore-initialize.cpp +++ b/objectstore/cta-objectstore-initialize.cpp @@ -34,10 +34,10 @@ #include <stdexcept> int main(int argc, char ** argv) { + std::unique_ptr<cta::objectstore::Backend> be; try { cta::log::StdoutLogger logger(cta::utils::getShortHostname(), "cta-objectstore-initialize"); cta::log::LogContext lc(logger); - std::unique_ptr<cta::objectstore::Backend> be; if (1 == argc) { be.reset(new cta::objectstore::BackendVFS); } else if (2 == argc) { @@ -66,11 +66,17 @@ int main(int argc, char ** argv) { re.fetch(); re.addOrGetDriveRegisterPointerAndCommit(agr, el); re.addOrGetSchedulerGlobalLockAndCommit(agr,el); - ag.removeAndUnregisterSelf(lc); + { + cta::objectstore::ScopedExclusiveLock agentLock(ag); + ag.fetch(); + ag.removeAndUnregisterSelf(lc); + } rel.release(); std::cout << "New object store path: " << be->getParams()->toURL() << std::endl; + return EXIT_SUCCESS; } catch (std::exception & e) { - std::cerr << "Failed to initialise the root entry in a new VFS backend store" + std::cerr << "Failed to initialise the root entry in a new " << be->typeName() << " objectstore" << std::endl << e.what() << std::endl; + return EXIT_FAILURE; } } -- GitLab