From 5ac857eb1905191ffea2ee55faadb5b841ba3e8e Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Thu, 16 May 2024 00:44:42 +0200 Subject: [PATCH] Avoid XRootD dependency in public headers This means that we won't have to install any headers from xrootd when using `builtin_xrootd=ON`. This makes systems that have both XRootD standalone and ROOT with builtin XRootD installed more stable. --- net/netxng/inc/TNetXNGFile.h | 19 ++----------------- net/netxng/src/TNetXNGFile.cxx | 34 +++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/net/netxng/inc/TNetXNGFile.h b/net/netxng/inc/TNetXNGFile.h index 902c305a5928e..c461423ebaef5 100644 --- a/net/netxng/inc/TNetXNGFile.h +++ b/net/netxng/inc/TNetXNGFile.h @@ -23,9 +23,6 @@ #include "TFile.h" #include "TSemaphore.h" -#ifndef __CLING__ -#include -#endif namespace XrdCl { class File; @@ -33,19 +30,11 @@ namespace XrdCl { } class XrdSysCondVar; -#ifdef __CLING__ -namespace XrdCl { - struct OpenFlags { - enum Flags {None = 0}; - }; -} -#endif - class TNetXNGFile: public TFile { private: XrdCl::File *fFile; // Underlying XRootD file XrdCl::URL *fUrl; // URL of the current file - XrdCl::OpenFlags::Flags fMode; // Open mode of the current file + int fMode; // Open mode of the current file XrdSysCondVar *fInitCondVar; // Used to block an async open request // if requested Int_t fReadvIorMax; // Max size of a single readv chunk @@ -54,9 +43,7 @@ class TNetXNGFile: public TFile { TString fNewUrl; public: - TNetXNGFile() : TFile(), - fFile(nullptr), fUrl(nullptr), fMode(XrdCl::OpenFlags::None), fInitCondVar(nullptr), - fReadvIorMax(0), fReadvIovMax(0) {} + TNetXNGFile(); TNetXNGFile(const char *url, const char *lurl, Option_t *mode, const char *title, Int_t compress, Int_t netopt, Bool_t parallelopen); TNetXNGFile(const char *url, Option_t *mode = "", const char *title = "", @@ -83,8 +70,6 @@ class TNetXNGFile: public TFile { virtual Bool_t IsUseable() const; virtual Bool_t GetVectorReadLimits(); virtual void SetEnv(); - Int_t ParseOpenMode(Option_t *in, TString &modestr, - XrdCl::OpenFlags::Flags &mode, Bool_t assumeRead); TNetXNGFile(const TNetXNGFile &other); // Not implemented TNetXNGFile &operator =(const TNetXNGFile &other); // Not implemented diff --git a/net/netxng/src/TNetXNGFile.cxx b/net/netxng/src/TNetXNGFile.cxx index e447ec1471718..e0ea0826b6376 100644 --- a/net/netxng/src/TNetXNGFile.cxx +++ b/net/netxng/src/TNetXNGFile.cxx @@ -29,9 +29,16 @@ #include #include #include +#include #include #include +namespace { + +Int_t ParseOpenMode(Option_t *in, TString &modestr, int &mode, Bool_t assumeRead); + +} // namepsace + //------------------------------------------------------------------------------ // Open handler for async open requests //////////////////////////////////////////////////////////////////////////////// @@ -113,6 +120,17 @@ class TAsyncReadvHandler: public XrdCl::ResponseHandler ClassImp(TNetXNGFile); +TNetXNGFile::TNetXNGFile() + : TFile(), + fFile(nullptr), + fUrl(nullptr), + fMode(XrdCl::OpenFlags::None), + fInitCondVar(nullptr), + fReadvIorMax(0), + fReadvIovMax(0) +{ +} + //////////////////////////////////////////////////////////////////////////////// /// Constructor /// @@ -183,7 +201,7 @@ TNetXNGFile::TNetXNGFile(const char *url, const char *lurl, Option_t *mode, cons if (parallelopen) { // Open the file asynchronously TAsyncOpenHandler *handler = new TAsyncOpenHandler(this); - status = fFile->Open(fUrl->GetURL(), fMode, Access::None, handler); + status = fFile->Open(fUrl->GetURL(), static_cast(fMode), Access::None, handler); if (!status.IsOK()) { Error("Open", "%s", status.ToStr().c_str()); MakeZombie(); @@ -192,7 +210,7 @@ TNetXNGFile::TNetXNGFile(const char *url, const char *lurl, Option_t *mode, cons } // Open the file synchronously - status = fFile->Open(fUrl->GetURL(), fMode); + status = fFile->Open(fUrl->GetURL(), static_cast(fMode)); if (!status.IsOK()) { #if XrdVNUMBER >= 40000 if( status.code == errRedirect ) @@ -346,7 +364,7 @@ Int_t TNetXNGFile::ReOpen(Option_t *modestr) { using namespace XrdCl; TString newOpt; - OpenFlags::Flags mode; + int mode; Int_t parseres = ParseOpenMode(modestr, newOpt, mode, kFALSE); @@ -370,7 +388,7 @@ Int_t TNetXNGFile::ReOpen(Option_t *modestr) fOption = newOpt; fMode = mode; - st = fFile->Open(fUrl->GetURL(), fMode); + st = fFile->Open(fUrl->GetURL(), static_cast(fMode)); if (!st.IsOK()) { Error("ReOpen", "%s", st.ToStr().c_str()); return 1; @@ -673,6 +691,8 @@ void TNetXNGFile::Seek(Long64_t offset, ERelativeTo position) SetOffset(offset, position); } +namespace { + //////////////////////////////////////////////////////////////////////////////// /// Parse a file open mode given as a string into a canonically formatted /// output mode string and an integer code that the xroot client can use @@ -684,9 +704,7 @@ void TNetXNGFile::Seek(Long64_t offset, ERelativeTo position) /// returns: 0 in case the mode was successfully parsed, /// -1 in case of failure -Int_t TNetXNGFile::ParseOpenMode(Option_t *in, TString &modestr, - XrdCl::OpenFlags::Flags &mode, - Bool_t assumeRead) +Int_t ParseOpenMode(Option_t *in, TString &modestr, int &mode, Bool_t assumeRead) { using namespace XrdCl; modestr = ToUpper(TString(in)); @@ -706,6 +724,8 @@ Int_t TNetXNGFile::ParseOpenMode(Option_t *in, TString &modestr, return 0; } +} // namespace + //////////////////////////////////////////////////////////////////////////////// /// Check the file is open and isn't a zombie