diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a9864dd552d..d19862af11d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -93,7 +93,6 @@ jobs: run: | tests/post-install.sh tests/check-headers.sh - alma8: name: Alma 8 runs-on: ubuntu-latest diff --git a/VERSION b/VERSION index f4034a5d279..568db048912 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -$Format:%(describe)$ +v5.7.3 diff --git a/bindings/python/src/PyXRootDCopyProcess.cc b/bindings/python/src/PyXRootDCopyProcess.cc index d7f532c33b8..69d0ecd0090 100644 --- a/bindings/python/src/PyXRootDCopyProcess.cc +++ b/bindings/python/src/PyXRootDCopyProcess.cc @@ -101,15 +101,15 @@ namespace PyXRootD val = XrdCl::DefaultCPInitTimeout; env->GetInt( "CPInitTimeout", val ); - uint16_t initTimeout = val; + time_t initTimeout = val; val = XrdCl::DefaultCPTPCTimeout; env->GetInt( "CPTPCTimeout", val ); - uint16_t tpcTimeout = val; + time_t tpcTimeout = val; val = XrdCl::DefaultCPTimeout; env->GetInt( "CPTimeout", val ); - uint16_t cpTimeout = val; + time_t cpTimeout = val; if ( !PyArg_ParseTupleAndKeywords( args, kwds, "ss|HbbbbssssbIHHHbHLLLbs:add_job", (char**) kwlist, diff --git a/bindings/python/src/PyXRootDCopyProgressHandler.cc b/bindings/python/src/PyXRootDCopyProgressHandler.cc index 9b35c5d8bbe..1a973c7a63c 100644 --- a/bindings/python/src/PyXRootDCopyProgressHandler.cc +++ b/bindings/python/src/PyXRootDCopyProgressHandler.cc @@ -32,8 +32,8 @@ namespace PyXRootD //---------------------------------------------------------------------------- // Notify when a new job is about to start //---------------------------------------------------------------------------- - void CopyProgressHandler::BeginJob( uint16_t jobNum, - uint16_t jobTotal, + void CopyProgressHandler::BeginJob( uint32_t jobNum, + uint32_t jobTotal, const XrdCl::URL *source, const XrdCl::URL *target ) { @@ -54,7 +54,7 @@ namespace PyXRootD //---------------------------------------------------------------------------- // Notify when the previous job has finished //---------------------------------------------------------------------------- - void CopyProgressHandler::EndJob( uint16_t jobNum, + void CopyProgressHandler::EndJob( uint32_t jobNum, const XrdCl::PropertyList *result ) { PyGILState_STATE state = PyGILState_Ensure(); @@ -74,7 +74,7 @@ namespace PyXRootD //---------------------------------------------------------------------------- // Notify about the progress of the current job //---------------------------------------------------------------------------- - void CopyProgressHandler::JobProgress( uint16_t jobNum, + void CopyProgressHandler::JobProgress( uint32_t jobNum, uint64_t bytesProcessed, uint64_t bytesTotal ) { @@ -93,7 +93,7 @@ namespace PyXRootD //---------------------------------------------------------------------------- // Check if the job should be canceled //---------------------------------------------------------------------------- - bool CopyProgressHandler::ShouldCancel( uint16_t jobNum ) + bool CopyProgressHandler::ShouldCancel( uint32_t jobNum ) { PyGILState_STATE state = PyGILState_Ensure(); bool ret = false; diff --git a/bindings/python/src/PyXRootDCopyProgressHandler.hh b/bindings/python/src/PyXRootDCopyProgressHandler.hh index 04ca6fb0c18..5361be0dc1e 100644 --- a/bindings/python/src/PyXRootDCopyProgressHandler.hh +++ b/bindings/python/src/PyXRootDCopyProgressHandler.hh @@ -46,28 +46,28 @@ namespace PyXRootD //------------------------------------------------------------------------ //! Notify when a new job is about to start //------------------------------------------------------------------------ - virtual void BeginJob( uint16_t jobNum, - uint16_t jobTotal, + virtual void BeginJob( uint32_t jobNum, + uint32_t jobTotal, const XrdCl::URL *source, const XrdCl::URL *target ); //------------------------------------------------------------------------ //! Notify when the previous job has finished //------------------------------------------------------------------------ - virtual void EndJob( uint16_t jobNum, + virtual void EndJob( uint32_t jobNum, const XrdCl::PropertyList *result ); //------------------------------------------------------------------------ //! Notify about the progress of the current job //------------------------------------------------------------------------ - virtual void JobProgress( uint16_t jobNum, + virtual void JobProgress( uint32_t jobNum, uint64_t bytesProcessed, uint64_t bytesTotal ); //------------------------------------------------------------------------ //! Determine whether the job should be canceled //------------------------------------------------------------------------ - virtual bool ShouldCancel(uint16_t jobNum); + virtual bool ShouldCancel(uint32_t jobNum); public: PyObject *handler; diff --git a/bindings/python/src/PyXRootDFile.cc b/bindings/python/src/PyXRootDFile.cc index 74faea96ad9..85e559c3ec2 100644 --- a/bindings/python/src/PyXRootDFile.cc +++ b/bindings/python/src/PyXRootDFile.cc @@ -43,7 +43,7 @@ namespace PyXRootD const char *url; XrdCl::OpenFlags::Flags flags = XrdCl::OpenFlags::None; XrdCl::Access::Mode mode = XrdCl::Access::None; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -75,7 +75,7 @@ namespace PyXRootD PyObject* File::Close( File *self, PyObject *args, PyObject *kwds ) { static const char *kwlist[] = { "timeout", "callback", NULL }; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -107,7 +107,7 @@ namespace PyXRootD { static const char *kwlist[] = { "force", "timeout", "callback", NULL }; int force = 0; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pyresponse = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -146,7 +146,7 @@ namespace PyXRootD NULL }; uint64_t offset = 0; uint32_t size = 0; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL, *pyresponse = NULL; PyObject *py_offset = NULL, *py_size = NULL, *py_timeout = NULL; char *buffer = 0; @@ -159,7 +159,7 @@ namespace PyXRootD unsigned long long tmp_offset = 0; unsigned int tmp_size = 0; - unsigned short int tmp_timeout = 0; + unsigned long long tmp_timeout = 0; if ( py_offset && PyObjToUllong( py_offset, &tmp_offset, "offset" ) ) return NULL; @@ -167,12 +167,12 @@ namespace PyXRootD if ( py_size && PyObjToUint(py_size, &tmp_size, "size" ) ) return NULL; - if ( py_timeout && PyObjToUshrt(py_timeout, &tmp_timeout, "timeout" ) ) + if ( py_timeout && PyObjToUllong(py_timeout, &tmp_timeout, "timeout" ) ) return NULL; offset = (uint64_t)tmp_offset; size = (uint32_t)tmp_size; - timeout = (uint16_t)tmp_timeout; + timeout = (time_t)tmp_timeout; if (!size) { XrdCl::StatInfo *info = 0; @@ -426,7 +426,7 @@ namespace PyXRootD Py_ssize_t buffsize; uint64_t offset = 0; uint32_t size = 0; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; PyObject *py_offset = NULL, *py_size = NULL, *py_timeout = NULL; XrdCl::XRootDStatus status; @@ -439,7 +439,7 @@ namespace PyXRootD unsigned long long tmp_offset = 0; unsigned int tmp_size = 0; - unsigned short int tmp_timeout = 0; + unsigned long long tmp_timeout = 0; if (py_offset && PyObjToUllong(py_offset, &tmp_offset, "offset")) return NULL; @@ -447,12 +447,12 @@ namespace PyXRootD if (py_size && PyObjToUint(py_size, &tmp_size, "size")) return NULL; - if (py_timeout && PyObjToUshrt(py_timeout, &tmp_timeout, "timeout")) + if (py_timeout && PyObjToUllong(py_timeout, &tmp_timeout, "timeout")) return NULL; offset = (uint64_t)tmp_offset; size = (uint32_t)tmp_size; - timeout = (uint16_t)tmp_timeout; + timeout = (time_t)tmp_timeout; if (!size) { size = buffsize; @@ -482,7 +482,7 @@ namespace PyXRootD PyObject* File::Sync( File *self, PyObject *args, PyObject *kwds ) { static const char *kwlist[] = { "timeout", "callback", NULL }; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -515,7 +515,7 @@ namespace PyXRootD { static const char *kwlist[] = { "size", "timeout", "callback", NULL }; uint64_t size; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; PyObject *py_size = NULL, *py_timeout = NULL; XrdCl::XRootDStatus status; @@ -526,16 +526,16 @@ namespace PyXRootD (char**) kwlist, &py_size, &py_timeout, &callback ) ) return NULL; unsigned long long tmp_size = 0; - unsigned short int tmp_timeout = 0; + unsigned long long tmp_timeout = 0; if ( py_size && PyObjToUllong( py_size, &tmp_size, "size" ) ) return NULL; - if ( py_timeout && PyObjToUshrt( py_timeout, &tmp_timeout, "timeout" ) ) + if ( py_timeout && PyObjToUllong( py_timeout, &tmp_timeout, "timeout" ) ) return NULL; size = (uint64_t)tmp_size; - timeout = (uint16_t)tmp_timeout; + timeout = (time_t)tmp_timeout; if ( callback && callback != Py_None ) { XrdCl::ResponseHandler *handler = GetHandler( callback ); @@ -561,7 +561,7 @@ namespace PyXRootD PyObject* File::VectorRead( File *self, PyObject *args, PyObject *kwds ) { static const char *kwlist[] = { "chunks", "timeout", "callback", NULL }; - uint16_t timeout = 0; + time_t timeout = 0; uint64_t offset = 0; uint32_t length = 0; PyObject *pychunks = NULL, *callback = NULL; @@ -574,12 +574,12 @@ namespace PyXRootD if ( !PyArg_ParseTupleAndKeywords( args, kwds, "O|OO:vector_read", (char**) kwlist, &pychunks, &py_timeout, &callback ) ) return NULL; - unsigned short int tmp_timeout = 0; + unsigned long long tmp_timeout = 0; - if ( py_timeout && PyObjToUshrt( py_timeout, &tmp_timeout, "timeout" ) ) + if ( py_timeout && PyObjToUllong( py_timeout, &tmp_timeout, "timeout" ) ) return NULL; - timeout = (uint16_t)tmp_timeout; + timeout = (time_t)tmp_timeout; if ( !PyList_Check( pychunks ) ) { PyErr_SetString( PyExc_TypeError, "chunks parameter must be a list" ); @@ -654,7 +654,7 @@ namespace PyXRootD static const char *kwlist[] = { "arg", "timeout", "callback", NULL }; const char *buffer = 0; Py_ssize_t buffSize = 0; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL, *pyresponse = NULL; XrdCl::XRootDStatus status; @@ -696,7 +696,7 @@ namespace PyXRootD PyObject* File::Visa( File *self, PyObject *args, PyObject *kwds ) { static const char *kwlist[] = { "timeout", "callback", NULL }; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL, *pyresponse = NULL; XrdCl::XRootDStatus status; @@ -782,7 +782,7 @@ namespace PyXRootD static const char *kwlist[] = { "attrs", "timeout", "callback", NULL }; std::vector attrs; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; PyObject *pyattrs = NULL, *pyresponse = NULL; @@ -853,7 +853,7 @@ namespace PyXRootD static const char *kwlist[] = { "attrs", "timeout", "callback", NULL }; std::vector attrs; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; PyObject *pyattrs = NULL, *pyresponse = NULL; @@ -912,7 +912,7 @@ namespace PyXRootD static const char *kwlist[] = { "attrs", "timeout", "callback", NULL }; std::vector attrs; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; PyObject *pyattrs = NULL, *pyresponse = NULL; @@ -970,7 +970,7 @@ namespace PyXRootD { static const char *kwlist[] = { "timeout", "callback", NULL }; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; PyObject *pyresponse = NULL; diff --git a/bindings/python/src/PyXRootDFileSystem.cc b/bindings/python/src/PyXRootDFileSystem.cc index a21148328f4..d3240c05d2f 100644 --- a/bindings/python/src/PyXRootDFileSystem.cc +++ b/bindings/python/src/PyXRootDFileSystem.cc @@ -84,7 +84,7 @@ namespace PyXRootD NULL }; const char *path; XrdCl::OpenFlags::Flags flags = XrdCl::OpenFlags::None; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pyresponse = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -122,7 +122,7 @@ namespace PyXRootD NULL }; const char *path; XrdCl::OpenFlags::Flags flags = XrdCl::OpenFlags::PrefName; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pyresponse = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -160,7 +160,7 @@ namespace PyXRootD NULL }; const char *source; const char *dest; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -193,7 +193,7 @@ namespace PyXRootD static const char *kwlist[] = { "querycode", "arg", "timeout", "callback", NULL }; const char *arg; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pyresponse = NULL, *pystatus = NULL; XrdCl::QueryCode::Code queryCode; XrdCl::XRootDStatus status; @@ -234,7 +234,7 @@ namespace PyXRootD static const char *kwlist[] = { "path", "size", "timeout", "callback", NULL }; const char *path; uint64_t size = 0; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -266,7 +266,7 @@ namespace PyXRootD { static const char *kwlist[] = { "path", "timeout", "callback", NULL }; const char *path; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -301,7 +301,7 @@ namespace PyXRootD const char *path; XrdCl::MkDirFlags::Flags flags = XrdCl::MkDirFlags::None; XrdCl::Access::Mode mode = XrdCl::Access::None; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -333,7 +333,7 @@ namespace PyXRootD { static const char *kwlist[] = { "path", "timeout", "callback", NULL }; const char *path; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -366,7 +366,7 @@ namespace PyXRootD static const char *kwlist[] = { "path", "mode", "timeout", "callback", NULL }; const char *path; XrdCl::Access::Mode mode = XrdCl::Access::None; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -397,7 +397,7 @@ namespace PyXRootD PyObject* FileSystem::Ping( FileSystem *self, PyObject *args, PyObject *kwds ) { static const char *kwlist[] = { "timeout", "callback", NULL }; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -429,7 +429,7 @@ namespace PyXRootD { static const char *kwlist[] = { "path", "timeout", "callback", NULL }; const char *path; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pyresponse = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -465,7 +465,7 @@ namespace PyXRootD { static const char *kwlist[] = { "path", "timeout", "callback", NULL }; const char *path; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pyresponse = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -500,7 +500,7 @@ namespace PyXRootD PyObject* FileSystem::Protocol( FileSystem *self, PyObject *args, PyObject *kwds ) { static const char *kwlist[] = { "timeout", "callback", NULL }; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pyresponse = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -538,7 +538,7 @@ namespace PyXRootD "callback", NULL }; const char *path; XrdCl::DirListFlags::Flags flags = XrdCl::DirListFlags::None; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pyresponse = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -574,7 +574,7 @@ namespace PyXRootD { static const char *kwlist[] = { "info", "timeout", "callback", NULL }; const char *info; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pyresponse = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -612,7 +612,7 @@ namespace PyXRootD "timeout", "callback", NULL }; uint16_t flagval = 0; uint8_t priority = 0; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *pyfiles = NULL, *callback = NULL; PyObject *pyresponse = NULL, *pystatus = NULL; XrdCl::XRootDStatus status; @@ -745,7 +745,7 @@ namespace PyXRootD char *path = 0; std::vector attrs; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; PyObject *pyattrs = NULL, *pyresponse = NULL; XrdCl::XRootDStatus status; @@ -814,7 +814,7 @@ namespace PyXRootD char *path = 0; std::vector attrs; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; PyObject *pyattrs = NULL, *pyresponse = NULL; XrdCl::XRootDStatus status; @@ -871,7 +871,7 @@ namespace PyXRootD char *path = 0; std::vector attrs; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL; PyObject *pyattrs = NULL, *pyresponse = NULL; XrdCl::XRootDStatus status; @@ -927,7 +927,7 @@ namespace PyXRootD static const char *kwlist[] = { "path", "timeout", "callback", NULL }; char *path = 0; - uint16_t timeout = 0; + time_t timeout = 0; PyObject *callback = NULL, *pystatus = NULL, *pyresponse = NULL; XrdCl::XRootDStatus status; diff --git a/bindings/python/tests/test_file.py b/bindings/python/tests/test_file.py index e74554789c0..6d30b405cd5 100644 --- a/bindings/python/tests/test_file.py +++ b/bindings/python/tests/test_file.py @@ -100,7 +100,7 @@ def test_io_limits(): pytest.raises(OverflowError, f.read, -1, 1) pytest.raises(OverflowError, f.read, 0, 1, -1) pytest.raises(OverflowError, f.read, 0, 10**11) - pytest.raises(OverflowError, f.read, 0, 10, 10**6) + pytest.raises(OverflowError, f.read, 0, 10, 2**65) # Test readline limits pytest.raises(TypeError, f.readline, [0, 1], 1) @@ -121,7 +121,7 @@ def test_io_limits(): pytest.raises(OverflowError, f.write, data, -1, 1) pytest.raises(OverflowError, f.write, data, 0, 1, -1) pytest.raises(OverflowError, f.write, data, 0, 10**11) - pytest.raises(OverflowError, f.write, data, 0, 10, 10**6) + pytest.raises(OverflowError, f.write, data, 0, 10, 2**65) # Test vector_read limits pytest.raises(TypeError, f.vector_read, chunks=100) @@ -137,7 +137,7 @@ def test_io_limits(): pytest.raises(TypeError, f.truncate, [1, 2], 0) pytest.raises(OverflowError, f.truncate, -1) pytest.raises(OverflowError, f.truncate, 100, -10) - pytest.raises(OverflowError, f.truncate, 0, 10**6) + pytest.raises(OverflowError, f.truncate, 0, 2**65) status, __ = f.close() assert status.ok diff --git a/packaging/makesrpm.sh b/packaging/makesrpm.sh index 208f7f5c6ec..a2e2e59a366 100755 --- a/packaging/makesrpm.sh +++ b/packaging/makesrpm.sh @@ -125,6 +125,11 @@ echo "[i] Working with version: $VERSION" # Sanitize version to work with RPMs # https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/ #------------------------------------------------------------------------------- +RELEASE=4 +if test x`echo $VERSION | grep -E $RCEXP` != x; then + RELEASE=0.`echo $VERSION | sed 's/.*-rc/rc/'` + VERSION=`echo $VERSION | sed 's/-rc.*//'` +fi VERSION=${VERSION#v} # remove "v" prefix VERSION=${VERSION/-rc/~rc} # release candidates use ~ in RPMs diff --git a/src/XrdApps/XrdClProxyPlugin/ProxyPrefixFile.cc b/src/XrdApps/XrdClProxyPlugin/ProxyPrefixFile.cc index 57e653dcfb6..d044cb67c1a 100644 --- a/src/XrdApps/XrdClProxyPlugin/ProxyPrefixFile.cc +++ b/src/XrdApps/XrdClProxyPlugin/ProxyPrefixFile.cc @@ -60,7 +60,7 @@ ProxyPrefixFile::Open(const std::string& url, OpenFlags::Flags flags, Access::Mode mode, ResponseHandler* handler, - uint16_t timeout) + time_t timeout) { XRootDStatus st; diff --git a/src/XrdApps/XrdClProxyPlugin/ProxyPrefixFile.hh b/src/XrdApps/XrdClProxyPlugin/ProxyPrefixFile.hh index ae000e82f57..73e86ba987b 100644 --- a/src/XrdApps/XrdClProxyPlugin/ProxyPrefixFile.hh +++ b/src/XrdApps/XrdClProxyPlugin/ProxyPrefixFile.hh @@ -58,13 +58,13 @@ public: OpenFlags::Flags flags, Access::Mode mode, ResponseHandler* handler, - uint16_t timeout) override; + time_t timeout) override; //---------------------------------------------------------------------------- //! Close //---------------------------------------------------------------------------- virtual XRootDStatus Close(ResponseHandler* handler, - uint16_t timeout) override + time_t timeout) override { return pFile->Close(handler, timeout); } @@ -74,7 +74,7 @@ public: //---------------------------------------------------------------------------- virtual XRootDStatus Stat(bool force, ResponseHandler* handler, - uint16_t timeout) override + time_t timeout) override { return pFile->Stat(force, handler, timeout); } @@ -87,7 +87,7 @@ public: uint32_t size, void* buffer, ResponseHandler* handler, - uint16_t timeout) override + time_t timeout) override { return pFile->Read(offset, size, buffer, handler, timeout); } @@ -99,7 +99,7 @@ public: uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) override + time_t timeout ) override { return pFile->PgRead(offset, size, buffer, handler, timeout); } @@ -111,7 +111,7 @@ public: uint32_t size, const void* buffer, ResponseHandler* handler, - uint16_t timeout) override + time_t timeout) override { return pFile->Write(offset, size, buffer, handler, timeout); } @@ -122,7 +122,7 @@ public: virtual XRootDStatus Write( uint64_t offset, Buffer &&buffer, ResponseHandler *handler, - uint16_t timeout = 0 ) override + time_t timeout = 0 ) override { return pFile->Write(offset, std::move(buffer), handler, timeout); } @@ -135,7 +135,7 @@ public: Optional fdoff, int fd, ResponseHandler *handler, - uint16_t timeout = 0 ) override + time_t timeout = 0 ) override { return pFile->Write(offset, size, fdoff, fd, handler, timeout); } @@ -148,7 +148,7 @@ public: const void *buffer, std::vector &cksums, ResponseHandler *handler, - uint16_t timeout ) override + time_t timeout ) override { return pFile->PgWrite(offset, nbpgs, buffer, cksums, handler, timeout); } @@ -157,7 +157,7 @@ public: //! Sync //---------------------------------------------------------------------------- virtual XRootDStatus Sync(ResponseHandler* handler, - uint16_t timeout) override + time_t timeout) override { return pFile->Sync(handler, timeout); } @@ -167,7 +167,7 @@ public: //---------------------------------------------------------------------------- virtual XRootDStatus Truncate(uint64_t size, ResponseHandler* handler, - uint16_t timeout) override + time_t timeout) override { return pFile->Truncate(size, handler, timeout); } @@ -178,7 +178,7 @@ public: virtual XRootDStatus VectorRead(const ChunkList& chunks, void* buffer, ResponseHandler* handler, - uint16_t timeout) override + time_t timeout) override { return pFile->VectorRead(chunks, buffer, handler, timeout); } @@ -188,7 +188,7 @@ public: //------------------------------------------------------------------------ virtual XRootDStatus VectorWrite( const ChunkList &chunks, ResponseHandler *handler, - uint16_t timeout = 0 ) override + time_t timeout = 0 ) override { return pFile->VectorWrite(chunks, handler, timeout); } @@ -200,7 +200,7 @@ public: const struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout = 0 ) override + time_t timeout = 0 ) override { return pFile->WriteV(offset, iov, iovcnt, handler, timeout); } @@ -210,7 +210,7 @@ public: //---------------------------------------------------------------------------- virtual XRootDStatus Fcntl(const Buffer& arg, ResponseHandler* handler, - uint16_t timeout) override + time_t timeout) override { return pFile->Fcntl(arg, handler, timeout); } @@ -219,7 +219,7 @@ public: //! Visa //---------------------------------------------------------------------------- virtual XRootDStatus Visa(ResponseHandler* handler, - uint16_t timeout) override + time_t timeout) override { return pFile->Visa(handler, timeout); } diff --git a/src/XrdApps/XrdClRecordPlugin/XrdClAction.hh b/src/XrdApps/XrdClRecordPlugin/XrdClAction.hh index a37da7b2b0e..733192d1568 100644 --- a/src/XrdApps/XrdClRecordPlugin/XrdClAction.hh +++ b/src/XrdApps/XrdClRecordPlugin/XrdClAction.hh @@ -43,7 +43,7 @@ struct Action // (to be used as an ID) // @param timeout : operation timeout (common for every operation) //-------------------------------------------------------------------------- - Action(void* file, uint16_t timeout) + Action(void* file, time_t timeout) : id(reinterpret_cast(file)) , timeout(timeout) , start(std::chrono::system_clock::now()) // register the action start time @@ -128,7 +128,7 @@ struct Action virtual void Serialize(AnyObject* response) {} uint64_t id; //> File object ID - uint16_t timeout; //> operation timeout + time_t timeout; //> operation timeout std::chrono::system_clock::time_point start; //> start time XRootDStatus status; //> operation status std::string serialrsp; //> serialized response @@ -141,7 +141,7 @@ struct Action struct OpenAction : public Action { OpenAction( - void* file, const std::string& url, OpenFlags::Flags flags, Access::Mode mode, uint16_t timeout) + void* file, const std::string& url, OpenFlags::Flags flags, Access::Mode mode, time_t timeout) : Action(file, timeout) , url(url) , flags(flags) @@ -170,7 +170,7 @@ struct OpenAction : public Action //---------------------------------------------------------------------------- struct CloseAction : public Action { - CloseAction(void* file, uint16_t timeout) + CloseAction(void* file, time_t timeout) : Action(file, timeout) { } @@ -185,7 +185,7 @@ struct CloseAction : public Action //---------------------------------------------------------------------------- struct StatAction : public Action { - StatAction(void* file, bool force, uint16_t timeout) + StatAction(void* file, bool force, time_t timeout) : Action(file, timeout) , force(force) { @@ -224,7 +224,7 @@ struct StatAction : public Action //---------------------------------------------------------------------------- struct ReadAction : public Action { - ReadAction(void* file, uint64_t offset, uint32_t size, uint16_t timeout) + ReadAction(void* file, uint64_t offset, uint32_t size, time_t timeout) : Action(file, timeout) , offset(offset) , size(size) @@ -250,7 +250,7 @@ struct ReadAction : public Action struct PgReadAction : public Action { - PgReadAction(void* file, uint64_t offset, uint32_t size, uint16_t timeout) + PgReadAction(void* file, uint64_t offset, uint32_t size, time_t timeout) : Action(file, timeout) , offset(offset) , size(size) @@ -282,7 +282,7 @@ struct PgReadAction : public Action //---------------------------------------------------------------------------- struct WriteAction : public Action { - WriteAction(void* file, uint64_t offset, uint32_t size, uint16_t timeout) + WriteAction(void* file, uint64_t offset, uint32_t size, time_t timeout) : Action(file, timeout) , offset(offset) , size(size) @@ -299,7 +299,7 @@ struct WriteAction : public Action struct PgWriteAction : public Action { - PgWriteAction(void* file, uint64_t offset, uint32_t size, uint16_t timeout) + PgWriteAction(void* file, uint64_t offset, uint32_t size, time_t timeout) : Action(file, timeout) , offset(offset) , size(size) @@ -324,7 +324,7 @@ struct PgWriteAction : public Action //---------------------------------------------------------------------------- struct SyncAction : public Action { - SyncAction(void* file, uint16_t timeout) + SyncAction(void* file, time_t timeout) : Action(file, timeout) { } @@ -339,7 +339,7 @@ struct SyncAction : public Action //---------------------------------------------------------------------------- struct TruncateAction : public Action { - TruncateAction(void* file, uint64_t size, uint16_t timeout) + TruncateAction(void* file, uint64_t size, time_t timeout) : Action(file, timeout) , size(size) { @@ -357,7 +357,7 @@ struct TruncateAction : public Action //---------------------------------------------------------------------------- struct VectorReadAction : public Action { - VectorReadAction(void* file, const ChunkList& chunks, uint16_t timeout) + VectorReadAction(void* file, const ChunkList& chunks, time_t timeout) : Action(file, timeout) , req(chunks) { @@ -400,7 +400,7 @@ struct VectorReadAction : public Action //---------------------------------------------------------------------------- struct VectorWriteAction : public Action { - VectorWriteAction(void* file, const ChunkList& chunks, uint16_t timeout) + VectorWriteAction(void* file, const ChunkList& chunks, time_t timeout) : Action(file, timeout) , req(chunks) { @@ -427,7 +427,7 @@ struct VectorWriteAction : public Action //---------------------------------------------------------------------------- struct FcntlAction : Action { - FcntlAction(void* file, const Buffer& arg, uint16_t timeout) + FcntlAction(void* file, const Buffer& arg, time_t timeout) : Action(file, timeout) , req(arg.GetSize()) { diff --git a/src/XrdApps/XrdClRecordPlugin/XrdClRecorder.hh b/src/XrdApps/XrdClRecordPlugin/XrdClRecorder.hh index 821a0631f0c..93ccdc0db65 100644 --- a/src/XrdApps/XrdClRecordPlugin/XrdClRecorder.hh +++ b/src/XrdApps/XrdClRecordPlugin/XrdClRecorder.hh @@ -265,7 +265,7 @@ public: OpenFlags::Flags flags, Access::Mode mode, ResponseHandler* handler, - uint16_t timeout) + time_t timeout) { std::unique_ptr ptr( new OpenAction( this, url, flags, mode, timeout ) ); RecordHandler *recHandler = new RecordHandler( output, std::move( ptr ), handler ); @@ -276,7 +276,7 @@ public: //! Close //---------------------------------------------------------------------------- virtual XRootDStatus Close(ResponseHandler* handler, - uint16_t timeout) + time_t timeout) { std::unique_ptr ptr( new CloseAction( this, timeout ) ); RecordHandler *recHandler = new RecordHandler( output, std::move( ptr ), handler ); @@ -288,7 +288,7 @@ public: //---------------------------------------------------------------------------- virtual XRootDStatus Stat(bool force, ResponseHandler* handler, - uint16_t timeout) + time_t timeout) { std::unique_ptr ptr( new StatAction( this, force, timeout ) ); RecordHandler *recHandler = new RecordHandler( output, std::move( ptr ), handler ); @@ -303,7 +303,7 @@ public: uint32_t size, void* buffer, ResponseHandler* handler, - uint16_t timeout) + time_t timeout) { std::unique_ptr ptr( new ReadAction( this, offset, size, timeout ) ); RecordHandler *recHandler = new RecordHandler( output, std::move( ptr ), handler ); @@ -317,7 +317,7 @@ public: uint32_t size, const void* buffer, ResponseHandler* handler, - uint16_t timeout) + time_t timeout) { std::unique_ptr ptr( new WriteAction( this, offset, size, timeout ) ); RecordHandler *recHandler = new RecordHandler( output, std::move( ptr ), handler ); @@ -331,7 +331,7 @@ public: uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { std::unique_ptr ptr( new PgReadAction( this, offset, size, timeout ) ); RecordHandler *recHandler = new RecordHandler( output, std::move( ptr ), handler ); @@ -346,7 +346,7 @@ public: const void *buffer, std::vector &cksums, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { std::unique_ptr ptr( new PgWriteAction( this, offset, size, timeout ) ); RecordHandler *recHandler = new RecordHandler( output, std::move( ptr ), handler ); @@ -357,7 +357,7 @@ public: //! Sync //---------------------------------------------------------------------------- virtual XRootDStatus Sync(ResponseHandler* handler, - uint16_t timeout) + time_t timeout) { std::unique_ptr ptr( new SyncAction( this, timeout ) ); RecordHandler *recHandler = new RecordHandler( output, std::move( ptr ), handler ); @@ -369,7 +369,7 @@ public: //---------------------------------------------------------------------------- virtual XRootDStatus Truncate(uint64_t size, ResponseHandler* handler, - uint16_t timeout) + time_t timeout) { std::unique_ptr ptr( new TruncateAction( this, size, timeout ) ); RecordHandler *recHandler = new RecordHandler( output, std::move( ptr ), handler ); @@ -382,7 +382,7 @@ public: virtual XRootDStatus VectorRead(const ChunkList& chunks, void* buffer, ResponseHandler* handler, - uint16_t timeout) + time_t timeout) { std::unique_ptr ptr( new VectorReadAction( this, chunks, timeout ) ); RecordHandler *recHandler = new RecordHandler( output, std::move( ptr ), handler ); @@ -394,7 +394,7 @@ public: //---------------------------------------------------------------------------- virtual XRootDStatus VectorWrite( const ChunkList &chunks, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { std::unique_ptr ptr( new VectorWriteAction( this, chunks, timeout ) ); RecordHandler *recHandler = new RecordHandler( output, std::move( ptr ), handler ); @@ -406,7 +406,7 @@ public: //---------------------------------------------------------------------------- virtual XRootDStatus Fcntl(const Buffer& arg, ResponseHandler* handler, - uint16_t timeout) + time_t timeout) { std::unique_ptr ptr( new FcntlAction( this, arg, timeout ) ); RecordHandler *recHandler = new RecordHandler( output, std::move( ptr ), handler ); @@ -417,7 +417,7 @@ public: //! Visa //---------------------------------------------------------------------------- virtual XRootDStatus Visa(ResponseHandler* handler, - uint16_t timeout) + time_t timeout) { return file.Visa(handler, timeout); } diff --git a/src/XrdApps/XrdClRecordPlugin/XrdClReplay.cc b/src/XrdApps/XrdClRecordPlugin/XrdClReplay.cc index 3926849c230..d6f7f90b985 100644 --- a/src/XrdApps/XrdClRecordPlugin/XrdClReplay.cc +++ b/src/XrdApps/XrdClRecordPlugin/XrdClReplay.cc @@ -217,7 +217,7 @@ bool AssureFile(const std::string& url, uint64_t size, bool viatruncate, bool ve { OpenFlags::Flags flags = OpenFlags::Read; Access::Mode mode = Access::None; - uint16_t timeout = 60; + time_t timeout = 60; { // deal with existing files @@ -353,7 +353,7 @@ class ActionExecutor std::string url; OpenFlags::Flags flags; Access::Mode mode; - uint16_t timeout; + time_t timeout; std::tie(url, flags, mode, timeout) = GetOpenArgs(); std::string lmetric; @@ -387,7 +387,7 @@ class ActionExecutor } else if (action == "Close") // close action { - uint16_t timeout = GetCloseArgs(); + time_t timeout = GetCloseArgs(); mytimer_t timer; if (closing) @@ -415,7 +415,7 @@ class ActionExecutor else if (action == "Stat") // stat action { bool force; - uint16_t timeout; + time_t timeout; std::tie(force, timeout) = GetStatArgs(); metric.ios["Stat::n"]++; mytimer_t timer; @@ -439,7 +439,7 @@ class ActionExecutor { uint64_t offset; buffer_t buffer; - uint16_t timeout; + time_t timeout; std::tie(offset, buffer, timeout) = GetReadArgs(); metric.ios["Read::n"]++; metric.ios["Read::b"] += buffer->size(); @@ -469,7 +469,7 @@ class ActionExecutor { uint64_t offset; buffer_t buffer; - uint16_t timeout; + time_t timeout; std::tie(offset, buffer, timeout) = GetPgReadArgs(); metric.ios["PgRead::n"]++; metric.ios["PgRead::b"] += buffer->size(); @@ -498,7 +498,7 @@ class ActionExecutor { uint64_t offset; buffer_t buffer; - uint16_t timeout; + time_t timeout; std::tie(offset, buffer, timeout) = GetWriteArgs(); metric.ios["Write::n"]++; metric.ios["Write::b"] += buffer->size(); @@ -528,7 +528,7 @@ class ActionExecutor { uint64_t offset; buffer_t buffer; - uint16_t timeout; + time_t timeout; std::tie(offset, buffer, timeout) = GetPgWriteArgs(); metric.ios["PgWrite::n"]++; metric.ios["PgWrite::b"] += buffer->size(); @@ -555,7 +555,7 @@ class ActionExecutor } else if (action == "Sync") // sync action { - uint16_t timeout = GetSyncArgs(); + time_t timeout = GetSyncArgs(); metric.ios["Sync::n"]++; mytimer_t timer; if (!simulate) @@ -576,7 +576,7 @@ class ActionExecutor else if (action == "Truncate") // truncate action { uint64_t size; - uint16_t timeout; + time_t timeout; std::tie(size, timeout) = GetTruncateArgs(); metric.ios["Truncate::n"]++; if (size > metric.ios["Truncate::o"]) @@ -601,7 +601,7 @@ class ActionExecutor else if (action == "VectorRead") // vector read action { ChunkList chunks; - uint16_t timeout; + time_t timeout; std::vector buffers; std::tie(chunks, timeout, buffers) = GetVectorReadArgs(); metric.ios["VectorRead::n"]++; @@ -634,7 +634,7 @@ class ActionExecutor else if (action == "VectorWrite") // vector write { ChunkList chunks; - uint16_t timeout; + time_t timeout; std::vector buffers; std::tie(chunks, timeout, buffers) = GetVectorWriteArgs(); metric.ios["VectorWrite::n"]++; @@ -715,7 +715,7 @@ class ActionExecutor std::string url = tokens[0]; OpenFlags::Flags flags = static_cast(std::stoul(tokens[1])); Access::Mode mode = static_cast(std::stoul(tokens[2])); - uint16_t timeout = static_cast(std::stoul(tokens[3])); + time_t timeout = static_cast(std::stoul(tokens[3])); return std::make_tuple(url, flags, mode, timeout); } @@ -731,7 +731,7 @@ class ActionExecutor if (tokens.size() != 2) throw std::invalid_argument("Failed to parse stat arguments."); bool force = (tokens[0] == "true"); - uint16_t timeout = static_cast(std::stoul(tokens[1])); + time_t timeout = static_cast(std::stoul(tokens[1])); return std::make_tuple(force, timeout); } @@ -747,7 +747,7 @@ class ActionExecutor uint64_t offset = std::stoull(tokens[0]); uint32_t length = std::stoul(tokens[1]); auto buffer = BufferPool::Instance().Allocate( length ); - uint16_t timeout = static_cast(std::stoul(tokens[2])); + time_t timeout = static_cast(std::stoul(tokens[2])); return std::make_tuple(offset, buffer, timeout); } @@ -781,7 +781,7 @@ class ActionExecutor if (tokens.size() != 2) throw std::invalid_argument("Failed to parse truncate arguments."); uint64_t size = std::stoull(tokens[0]); - uint16_t timeout = static_cast(std::stoul(tokens[1])); + time_t timeout = static_cast(std::stoul(tokens[1])); return std::make_tuple(size, timeout); } @@ -804,7 +804,7 @@ class ActionExecutor chunks.emplace_back(offset, length, buffer->data()); buffers.emplace_back( std::move( buffer ) ); } - uint16_t timeout = static_cast(std::stoul(tokens.back())); + time_t timeout = static_cast(std::stoul(tokens.back())); return std::make_tuple(std::move(chunks), timeout, std::move(buffers)); } diff --git a/src/XrdCeph/CMakeLists.txt b/src/XrdCeph/CMakeLists.txt index 86f62156ff7..3ac9a4c7e9c 100644 --- a/src/XrdCeph/CMakeLists.txt +++ b/src/XrdCeph/CMakeLists.txt @@ -13,12 +13,15 @@ else() endif() endif() +include_directories( ${RADOS_INCLUDE_DIR} ) + set(BUILD_CEPH TRUE CACHE BOOL INTERNAL FORCE) add_library(XrdCephPosix SHARED XrdCephPosix.cc XrdCephPosix.hh XrdCephBulkAioRead.cc XrdCephBulkAioRead.hh) + target_compile_options(XrdCephPosix PRIVATE -Wno-deprecated-declarations) @@ -29,7 +32,7 @@ target_include_directories(XrdCephPosix PUBLIC ${RADOS_INCLUDE_DIR} $) set_target_properties(XrdCephPosix - PROPERTIES VERSION 0.0.1 SOVERSION 0) + PROPERTIES VERSION 5.7.0 SOVERSION 0) set(LIB_XRD_CEPH XrdCeph-${PLUGIN_VERSION}) @@ -50,7 +53,8 @@ add_library(${LIB_XRD_CEPH} MODULE ) target_link_libraries(${LIB_XRD_CEPH} - PRIVATE ${XROOTD_LIBRARIES} XrdCephPosix) + PRIVATE ${XROOTD_LIBRARIES} XrdCephPosix + ) set(LIB_XRD_CEPH_XATTR XrdCephXattr-${PLUGIN_VERSION}) diff --git a/src/XrdCeph/XrdCephOss.cc b/src/XrdCeph/XrdCephOss.cc index 5ff411d33f4..1b5cdb25594 100644 --- a/src/XrdCeph/XrdCephOss.cc +++ b/src/XrdCeph/XrdCephOss.cc @@ -28,14 +28,8 @@ #include #include -#include "XrdVersion.hh" -#include "XrdCeph/XrdCephOss.hh" -#include "XrdCeph/XrdCephOssDir.hh" -#include "XrdCeph/XrdCephOssFile.hh" +#include #include "XrdCeph/XrdCephPosix.hh" -#include "XrdCeph/XrdCephOssBufferedFile.hh" -#include "XrdCeph/XrdCephOssReadVFile.hh" - #include "XrdOuc/XrdOucEnv.hh" #include "XrdSys/XrdSysError.hh" #include "XrdSys/XrdSysPlatform.hh" @@ -43,6 +37,12 @@ #include "XrdOuc/XrdOucStream.hh" #include "XrdOuc/XrdOucName2Name.hh" #include "XrdOuc/XrdOucN2NLoader.hh" +#include "XrdVersion.hh" +#include "XrdCeph/XrdCephOss.hh" +#include "XrdCeph/XrdCephOssDir.hh" +#include "XrdCeph/XrdCephOssFile.hh" +#include "XrdCeph/XrdCephOssBufferedFile.hh" +#include "XrdCeph/XrdCephOssReadVFile.hh" XrdVERSIONINFO(XrdOssGetStorageSystem, XrdCephOss); @@ -115,7 +115,7 @@ ssize_t getNumericAttr(const char* const path, const char* attrName, const int m if (attrLen <= 0) { retval = -EINVAL; } else { - attrValue[attrLen] = '\0'; + attrValue[attrLen] = (char)'\0'; char *endPointer = (char *)NULL; retval = strtoll(attrValue, &endPointer, 10); } @@ -127,6 +127,9 @@ ssize_t getNumericAttr(const char* const path, const char* attrName, const int m return retval; } +char *g_cksLogFileName; + +extern FILE *g_cksLogFile; extern "C" { @@ -165,6 +168,12 @@ XrdCephOss::~XrdCephOss() { extern unsigned int g_maxCephPoolIdx; extern unsigned int g_cephAioWaitThresh; +bool g_calcStreamedAdler32; +bool g_storeStreamedAdler32; +bool g_logStreamedAdler32; + + + int XrdCephOss::Configure(const char *configfn, XrdSysError &Eroute) { int NoGo = 0; XrdOucEnv myEnv; @@ -348,7 +357,7 @@ int XrdCephOss::Configure(const char *configfn, XrdSysError &Eroute) { if (!Config.GetRest(parms, sizeof(parms)) || parms[0]) { Eroute.Emsg("Config", "readvalgname parameters will be ignored"); } - m_configBufferIOmode = var; // allowed values would be aio, io + m_configBufferIOmode = var; // allowed values would be aio, io, write-only-io } else { Eroute.Emsg("Config", "Missing value for ceph.bufferiomode in config file", configfn); return 1; @@ -361,19 +370,78 @@ int XrdCephOss::Configure(const char *configfn, XrdSysError &Eroute) { m_configPoolnames = var; } else { Eroute.Emsg("Config", "Missing value for ceph.reportingpools in config file", configfn); - return 1; + return 1; + } + } + if (!strcmp(var, "ceph.streamed-cks-adler32")) { // Streaming Adler32 checksum + + var = Config.GetWord(); + if (var) { +/* + * Currently, actions are simply additive: + * + * Store implies calculate, log, store + * Log implies calculate, log + * Calc implies calculate + * + * Might want to make e.g. logging optional in the future, + * when storing is more prevalent. + * + * Instead of setting g_* flags in three conditionals, + * can switch to setting values in a single bitfield flag + * + */ + if (strstr(var, "calc")) { + g_calcStreamedAdler32 = true; + g_logStreamedAdler32 = false; + g_storeStreamedAdler32 = false; + } + if (strstr(var, "log")) { + g_calcStreamedAdler32 = true; + g_logStreamedAdler32 = true; + g_storeStreamedAdler32 = false; + } + if (strstr(var, "store")) { + g_calcStreamedAdler32 = true; + g_logStreamedAdler32 = true; + g_storeStreamedAdler32 = true; + } + } - } - } // while + }// "ceph.streamed-cks-adler32" - // Now check if any errors occurred during file i/o + if (!strcmp(var, "ceph.streamed-cks-logfile") ) { + var = Config.GetWord(); + if (var) { + g_cksLogFileName = strdup(var); + } else { + const char *defLogFileName = "/tmp/checksums.log"; // To-DO: Move defLogFileName so it can also be used as fallback + // when attempt to open specified log file below fails + Eroute.Emsg("Config", "Missing value for ceph.streamed-cks-logfile in config file, setting to default = ", defLogFileName); + g_cksLogFileName = strdup(defLogFileName); + return 1; + } + }// "ceph.streamed-cks-logfile" + } + // Now check if any errors occured during file i/o int retc = Config.LastError(); if (retc) { NoGo = Eroute.Emsg("Config", -retc, "read config file", configfn); } Config.Close(); + + if (g_logStreamedAdler32) { + if (NULL == (g_cksLogFile = fopen(g_cksLogFileName, "a"))) { + g_logStreamedAdler32 = false; + Eroute.Emsg("Config: ", "cannot open file for logging checksum values and pathname", g_cksLogFileName); + return 1; + } else { + Eroute.Emsg("Config: ", "Opened file for logging checksum values and pathname: ", g_cksLogFileName); + } + } + } return NoGo; } diff --git a/src/XrdCeph/XrdCephOss.hh b/src/XrdCeph/XrdCephOss.hh index d79743f8a71..a54040cb2cc 100644 --- a/src/XrdCeph/XrdCephOss.hh +++ b/src/XrdCeph/XrdCephOss.hh @@ -26,9 +26,7 @@ #define __CEPH_OSS_HH__ #include - #include -#include //------------------------------------------------------------------------------ //! This class implements XrdOss interface for usage with a CEPH storage. diff --git a/src/XrdCeph/XrdCephOssBufferedFile.cc b/src/XrdCeph/XrdCephOssBufferedFile.cc index 0862d39b4d0..7783ccc481d 100644 --- a/src/XrdCeph/XrdCephOssBufferedFile.cc +++ b/src/XrdCeph/XrdCephOssBufferedFile.cc @@ -151,6 +151,10 @@ ssize_t XrdCephOssBufferedFile::Read(off_t offset, size_t blen) { ssize_t XrdCephOssBufferedFile::Read(void *buff, off_t offset, size_t blen) { size_t thread_id = std::hash{}(std::this_thread::get_id()); + if (m_bufferIOmode == "write-only-io") { + return m_xrdOssDF->Read(buff, offset, blen); + } + IXrdCephBufferAlg * buffer{nullptr}; // check for, and create if needed, a buffer { @@ -326,11 +330,12 @@ std::unique_ptr XrdCephOssBufferedFile::create std::unique_ptr cephio; if (m_bufferIOmode == "aio") { cephio = std::unique_ptr(new CephIOAdapterAIORaw(cephbuffer.get(),m_fd)); - } else if (m_bufferIOmode == "io") { + } else if (m_bufferIOmode == "io" || m_bufferIOmode == "write-only-io") { cephio = std::unique_ptr(new CephIOAdapterRaw(cephbuffer.get(),m_fd, !m_cephoss->m_useDefaultPreadAlg)); } else { - BUFLOG("XrdCephOssBufferedFile: buffer mode needs to be one of aio|io " ); + BUFLOG("XrdCephOssBufferedFile: buffer mode needs to be one of aio|io|write-only-io " ); + m_xrdOssDF->Close(); return bufferAlg; // invalid instance; } diff --git a/src/XrdCeph/XrdCephPosix.cc b/src/XrdCeph/XrdCephPosix.cc index 65ee444a114..89495d7535a 100644 --- a/src/XrdCeph/XrdCephPosix.cc +++ b/src/XrdCeph/XrdCephPosix.cc @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -54,7 +54,49 @@ #include "XrdCeph/XrdCephPosix.hh" #include "XrdCeph/XrdCephBulkAioRead.hh" #include "XrdSfs/XrdSfsFlags.hh" // for the OFFLINE flag status +#include "XrdCks/XrdCksData.hh" +#include + +char *ts_rfc3339() { + + std::time_t now = std::time({}); + char timeString[std::size("yyyy-mm-dd hh:mm:ss")]; + std::strftime(std::data(timeString), std::size(timeString), + "%F %TZ", std::gmtime(&now)); + return strdup(timeString); +} + +constexpr char hex2ascii(char nibble) { return (0<= nibble && nibble<=9) ? nibble+'0' : nibble-10+'a'; } +constexpr char hiNibble(uint8_t hexbyte) { return (hexbyte & 0xf0) >> 4; } +constexpr char loNibble(uint8_t hexbyte) { return (hexbyte & 0x0f); } + +constexpr char *hexbytes2ascii(const char bytes[], const unsigned int length){ + + char asciiVal[9] {}; + for (unsigned int i = 0, j = 0; i < length; i++) { + + const uint8_t hexbyte = bytes[i]; + asciiVal[j++] = hex2ascii(hiNibble(hexbyte)); + asciiVal[j++] = hex2ascii(loNibble(hexbyte)); + + } + return strdup(asciiVal); +} + +using namespace std; + +int setXrdCksAttr(const int fd, const char* cstype, const char* ckSumbuf) { + + int rc = -1; + + std::vector attrData = XrdCksAttrData(cstype, ckSumbuf, time(0)); + + rc = ceph_posix_fsetxattr(fd, XrdCksAttrName(cstype).c_str(), + attrData.data(), attrData.size(), 0); + + return rc; +} /// small struct for directory listing struct DirIterator { @@ -111,6 +153,16 @@ XrdSysMutex g_init_mutex; //JW Counter for number of times a given cluster is resolved. std::map g_idxCntr; +//IJJ: Actions for Adler32 checksum +extern bool g_calcStreamedAdler32; +bool g_calcStreamedAdler32 = false; +extern bool g_logStreamedAdler32; +bool g_logStreamedAdler32 = false; +extern bool g_storeStreamedAdler32; +bool g_storeStreamedAdler32 = false; + +FILE *g_cksLogFile; + /// Accessor to next ceph pool index /// Note that this is not thread safe, but we do not care /// as we only want a rough load balancing @@ -529,6 +581,7 @@ int checkAndCreateStriper(unsigned int cephPoolIdx, std::string &userAtPool, con } int rc = g_cluster[cephPoolIdx]->ioctx_create(file.pool.c_str(), *ioctx); if (rc != 0) { + logwrapper((char*)"checkAndCreateStriper : ioctx_create failed, user@pool = %s", userAtPool.c_str()); logwrapper((char*)"checkAndCreateStriper : ioctx_create failed, rc = %d", rc); cluster->shutdown(); delete cluster; @@ -588,8 +641,9 @@ int checkAndCreateStriper(unsigned int cephPoolIdx, std::string &userAtPool, con return 0; } IOCtxDict & ioDict = g_ioCtx[cephPoolIdx]; - ioDict.emplace(userAtPool, ioctx); - sDict.emplace(userAtPool, striper); + ioDict.insert(std::pair(userAtPool, ioctx)); + sDict.insert(std::pair + (userAtPool, striper)).first; } return 1; } @@ -748,7 +802,13 @@ int ceph_posix_open(XrdOucEnv* env, const char *pathname, int flags, mode_t mode } } } + // At this point, we know either the target file didn't exist, or the ceph_posix_unlink above removed it + if (g_calcStreamedAdler32) { + fr.cksCalcadler32 = new XrdCksCalcadler32(); + fr.cksCalcadler32->Init(); + } + fr.writingData = true; int fd = insertFileRef(fr); logwrapper((char*)"File descriptor %d associated to file %s opened in write mode", fd, pathname); return fd; @@ -757,6 +817,17 @@ int ceph_posix_open(XrdOucEnv* env, const char *pathname, int flags, mode_t mode } + +const char* formatAdler32(unsigned long adler32) { + +#ifndef Xrd_Big_Endian + adler32 = htonl(adler32); +#endif + char adler32Cks[8+1]; + sprintf(adler32Cks, "%08lx", adler32); + return (const char*)strdup(adler32Cks); +} + int ceph_posix_close(int fd) { CephFileRef* fr = getFileRef(fd); if (fr) { @@ -769,6 +840,9 @@ int ceph_posix_close(int fd) { lastAsyncAge = 1.0 * (now.tv_sec - fr->lastAsyncSubmission.tv_sec) + 0.000001 * (now.tv_usec - fr->lastAsyncSubmission.tv_usec); } + if (fr->bytesWritten > 0){ + ceph_posix_fremovexattr(fd,"XrdCks.adler32"); + } logwrapper((char*)"ceph_close: closed fd %d for file %s, read ops count %d, write ops count %d, " "async write ops %d/%d, async pending write bytes %ld, " "async read ops %d/%d, bytes written/max offset %ld/%ld, " @@ -777,6 +851,30 @@ int ceph_posix_close(int fd) { fr->asyncWrCompletionCount, fr->asyncWrStartCount, fr->bytesAsyncWritePending, fr->asyncRdCompletionCount, fr->asyncRdStartCount, fr->bytesWritten, fr->maxOffsetWritten, fr->longestAsyncWriteTime, fr->longestCallbackInvocation, (lastAsyncAge)); + + if (fr->writingData && g_calcStreamedAdler32) { + + unsigned long adlerULong; + memcpy((&adlerULong), fr->cksCalcadler32->Final(), 4); + const char* adler32Cks = formatAdler32(adlerULong); + + logwrapper((char*)"ceph_close: fd: %d, Adler32 streamed checksum = %s", fd, adler32Cks); + + if (g_logStreamedAdler32) { + const char *path = strdup((fr->pool + ":" + fr->name).c_str()); + fprintf(g_cksLogFile, "%s,%s,%s,%s,%s\n", ts_rfc3339(), path, "streamed", "adler32", adler32Cks); + fflush(g_cksLogFile); + } + + if (g_storeStreamedAdler32) { + int rc = setXrdCksAttr(fd, "adler32", adler32Cks); + if (rc != 0) { + logwrapper((char*)"ceph_close: Can't set attribute XrdCks.adler32 for checksum"); + } + } + delete fr->cksCalcadler32; + } + deleteFileRef(fd, *fr); return 0; } else { @@ -838,6 +936,9 @@ ssize_t ceph_posix_write(int fd, const void *buf, size_t count) { fr->wrcount++; fr->bytesWritten+=count; if (fr->offset) fr->maxOffsetWritten = std::max(fr->offset - 1, fr->maxOffsetWritten); + if (g_calcStreamedAdler32) { + fr->cksCalcadler32->Update((const char*)buf, count); + } return count; } else { return -EBADF; @@ -848,6 +949,7 @@ ssize_t ceph_posix_pwrite(int fd, const void *buf, size_t count, off64_t offset) CephFileRef* fr = getFileRef(fd); if (fr) { // TODO implement proper logging level for this plugin - this should be only debug + //logwrapper((char*)"ceph_write: for fd %d, count=%d", fd, count); if ((fr->flags & O_ACCMODE) == O_RDONLY) { return -EBADF; @@ -859,11 +961,15 @@ ssize_t ceph_posix_pwrite(int fd, const void *buf, size_t count, off64_t offset) ceph::bufferlist bl; bl.append((const char*)buf, count); int rc = striper->write(fr->name, bl, count, offset); + if (rc) return rc; XrdSysMutexHelper lock(fr->statsMutex); fr->wrcount++; fr->bytesWritten+=count; - if (offset + count) fr->maxOffsetWritten = std::max(uint64_t(offset + count - 1), fr->maxOffsetWritten); + if (g_calcStreamedAdler32 && ( fr->maxOffsetWritten == offset + count -1 ) ) { + fr->cksCalcadler32->Update((const char*)buf, count); + } + if (offset + count) fr->maxOffsetWritten = std::max(offset + count - 1, fr->maxOffsetWritten); return count; } else { return -EBADF; @@ -882,7 +988,7 @@ static void ceph_aio_write_complete(rados_completion_t c, void *arg) { fr->bytesAsyncWritePending -= awa->nbBytes; fr->bytesWritten += awa->nbBytes; if (awa->aiop->sfsAio.aio_nbytes) - fr->maxOffsetWritten = std::max(fr->maxOffsetWritten, uint64_t(awa->aiop->sfsAio.aio_offset + awa->aiop->sfsAio.aio_nbytes - 1)); + fr->maxOffsetWritten = std::max(fr->maxOffsetWritten, awa->aiop->sfsAio.aio_offset + awa->aiop->sfsAio.aio_nbytes - 1); ::timeval now; ::gettimeofday(&now, nullptr); double writeTime = 0.000001 * (now.tv_usec - awa->startTime.tv_usec) + 1.0 * (now.tv_sec - awa->startTime.tv_sec); @@ -908,6 +1014,7 @@ ssize_t ceph_aio_write(int fd, XrdSfsAio *aiop, AioCB *cb) { const char *buf = (const char*)aiop->sfsAio.aio_buf; size_t offset = aiop->sfsAio.aio_offset; // TODO implement proper logging level for this plugin - this should be only debug + //logwrapper((char*)"ceph_aio_write: for fd %d, count=%d", fd, count); if ((fr->flags & O_ACCMODE) == O_RDONLY) { return -EBADF; @@ -938,6 +1045,10 @@ ssize_t ceph_aio_write(int fd, XrdSfsAio *aiop, AioCB *cb) { fr->asyncWrStartCount++; ::gettimeofday(&fr->lastAsyncSubmission, nullptr); fr->bytesAsyncWritePending+=count; + // disable streamed checksums for aio writes as it's too risky + //if (g_calcStreamedAdler32) { + // fr->cksCalcadler32->Update((const char*)buf, count); + // } return rc; } else { return -EBADF; @@ -1349,8 +1460,23 @@ static ssize_t ceph_posix_internal_setxattr(const CephFile &file, const char* na ssize_t ceph_posix_setxattr(XrdOucEnv* env, const char* path, const char* name, const void* value, size_t size, int flags) { + int rc; + + auto *cks = (XrdCksData*)value; logwrapper((char*)"ceph_setxattr: path %s name=%s value=%s", path, name, value); - return ceph_posix_internal_setxattr(getCephFile(path, env), name, value, size, flags); + rc = ceph_posix_internal_setxattr(getCephFile(path, env), name, value, size, flags); + + if (0 == rc && !strcmp(name, "XrdCks.adler32") && g_logStreamedAdler32) { +// +// We know that streamed checksums use ceph_posix_fsetxattr below, so this must be a readback checksum +// + auto cksAscii = (const char*)hexbytes2ascii(cks->Value, cks->Length); + logwrapper((char*)"readback checksum = %s", cksAscii); + fprintf(g_cksLogFile, "%s,%s,%s,%s,%s\n", ts_rfc3339(), path, "readback", "adler32", cksAscii); + fflush(g_cksLogFile); + + } + return rc; } int ceph_posix_fsetxattr(int fd, @@ -1543,7 +1669,6 @@ int ceph_posix_unlink(XrdOucEnv* env, const char *pathname) { logwrapper((char*)"ceph_posix_unlink : %s", pathname); // start the timer auto timer_start = std::chrono::steady_clock::now(); - // minimal stat : only size and times are filled CephFile file = getCephFile(pathname, env); libradosstriper::RadosStriper *striper = getRadosStriper(file); diff --git a/src/XrdCeph/XrdCephPosix.hh b/src/XrdCeph/XrdCephPosix.hh index 5d01129b6ae..1dfee919527 100644 --- a/src/XrdCeph/XrdCephPosix.hh +++ b/src/XrdCeph/XrdCephPosix.hh @@ -39,6 +39,7 @@ #include "XrdSys/XrdSysPthread.hh" #include "XrdOuc/XrdOucIOVec.hh" +#include // simple logging for XrdCeph buffering code #define XRDCEPHLOGLEVEL 1 @@ -107,6 +108,7 @@ struct CephFile { unsigned int nbStripes; unsigned long long stripeUnit; unsigned long long objectSize; + }; struct CephFileRef : CephFile { @@ -127,6 +129,8 @@ struct CephFileRef : CephFile { ::timeval lastAsyncSubmission; double longestAsyncWriteTime; double longestCallbackInvocation; + bool writingData; + XrdCksCalcadler32 *cksCalcadler32; }; #endif // __XRD_CEPH_POSIX__ diff --git a/src/XrdCeph/XrdCephXAttr.cc b/src/XrdCeph/XrdCephXAttr.cc index 4c2f60a0f96..b56a6fc5b03 100644 --- a/src/XrdCeph/XrdCephXAttr.cc +++ b/src/XrdCeph/XrdCephXAttr.cc @@ -28,6 +28,9 @@ #include "XrdOuc/XrdOucTrace.hh" #include "XrdCeph/XrdCephXAttr.hh" +#include "XrdCks/XrdCksData.hh" +#include + XrdSysError XrdCephXattrEroute(0); XrdOucTrace XrdCephXattrTrace(&XrdCephXattrEroute); @@ -49,6 +52,7 @@ extern "C" XrdCephXattrEroute.Say("CephXattr loading failed with exception. Check the syntax of parameters : ", parms); return 0; } + return new XrdCephXAttr(); } } @@ -99,16 +103,19 @@ int XrdCephXAttr::List(AList **aPL, const char *Path, int fd, int getSz) { int XrdCephXAttr::Set(const char *Aname, const void *Aval, int Avsz, const char *Path, int fd, int isNew) { + int rc = 0; + if (fd >= 0) { - return ceph_posix_fsetxattr(fd, Aname, Aval, Avsz, 0); + rc = ceph_posix_fsetxattr(fd, Aname, Aval, Avsz, 0); } else { try { - return ceph_posix_setxattr(0, Path, Aname, Aval, Avsz, 0); + rc = ceph_posix_setxattr(0, Path, Aname, Aval, Avsz, 0); } catch (std::exception &e) { XrdCephXattrEroute.Say("Set : invalid syntax in file parameters", Path); - return -EINVAL; + rc = -EINVAL; } } + return rc; } XrdVERSIONINFO(XrdSysGetXAttrObject, XrdCephXAttr); diff --git a/src/XrdCeph/XrdCephXAttr.hh b/src/XrdCeph/XrdCephXAttr.hh index ed6f4d39f21..0dfb9f5ec74 100644 --- a/src/XrdCeph/XrdCephXAttr.hh +++ b/src/XrdCeph/XrdCephXAttr.hh @@ -136,7 +136,7 @@ public: //! attribute value which may contain binary data. //! @param Path -> Path of the file whose attribute is to be set. //! @param fd -> If >=0 is the file descriptor of the opened subject file. - //! @param isNew When !0 then the attribute must not exist (i.e. new). + //! @param isnew When !0 then the attribute must not exist (i.e. new). //! Otherwise, if it does exist, the value is replaced. In //! either case, if it does not exist it should be created. //! diff --git a/src/XrdCks/XrdCksManager.cc b/src/XrdCks/XrdCksManager.cc index 8b18743794c..f373000c460 100644 --- a/src/XrdCks/XrdCksManager.cc +++ b/src/XrdCks/XrdCksManager.cc @@ -463,7 +463,8 @@ int XrdCksManager::Del(const char *Pfn, XrdCksData &Cks) int XrdCksManager::Get(const char *Pfn, XrdCksData &Cks) { XrdOucXAttr xCS; - time_t MTime; + // not checking stale checksums as ceph file modification times constantly refresh on read + //time_t MTime; int rc, nFault; // Determine which checksum to get (we will accept unsupported ones as well) @@ -481,16 +482,14 @@ int XrdCksManager::Get(const char *Pfn, XrdCksData &Cks) nFault = strcmp(xCS.Attr.Cks.Name, Cks.Name); Cks = xCS.Attr.Cks; -// Verify the file. We do this with modification time unless that check -// has been turned off. -// - if (CksOpts & Cks_nomtchk) MTime = Cks.fmTime; - else if ((rc = ModTime(Pfn, MTime))) return rc; +// Verify the file +// not done as ceph mod times are weird +// if ((rc = ModTime(Pfn, MTime))) return rc; + // Return result // - return (Cks.fmTime != MTime || nFault - || Cks.Length > XrdCksData::ValuSize || Cks.Length <= 0 + return ( nFault || Cks.Length > XrdCksData::ValuSize || Cks.Length <= 0 ? -ESTALE : int(Cks.Length)); } diff --git a/src/XrdCl/XrdClAsyncSocketHandler.hh b/src/XrdCl/XrdClAsyncSocketHandler.hh index 8589715a846..7b020c17ffd 100644 --- a/src/XrdCl/XrdClAsyncSocketHandler.hh +++ b/src/XrdCl/XrdClAsyncSocketHandler.hh @@ -275,7 +275,7 @@ namespace XrdCl XrdNetAddr pSockAddr; std::unique_ptr pHandShakeData; bool pHandShakeDone; - uint16_t pTimeoutResolution; + time_t pTimeoutResolution; time_t pConnectionStarted; time_t pConnectionTimeout; time_t pLastActivity; diff --git a/src/XrdCl/XrdClCheckpointOperation.hh b/src/XrdCl/XrdClCheckpointOperation.hh index c80a1f91223..e89c1f8d299 100644 --- a/src/XrdCl/XrdClCheckpointOperation.hh +++ b/src/XrdCl/XrdClCheckpointOperation.hh @@ -57,10 +57,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { ChkPtCode code = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->Checkpoint( code, handler, timeout ); } @@ -69,7 +69,7 @@ namespace XrdCl //---------------------------------------------------------------------------- //! Factory for creating ReadImpl objects //---------------------------------------------------------------------------- - inline CheckpointImpl Checkpoint( Ctx file, Arg code, uint16_t timeout = 0 ) + inline CheckpointImpl Checkpoint( Ctx file, Arg code, time_t timeout = 0 ) { return CheckpointImpl( std::move( file ), std::move( code ) ).Timeout( timeout ); } @@ -112,12 +112,12 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { uint64_t off = std::get( this->args ).Get(); uint32_t len = std::get( this->args ).Get(); const void* buf = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->ChkptWrt( off, len, buf, handler, timeout ); } @@ -128,7 +128,7 @@ namespace XrdCl //---------------------------------------------------------------------------- inline ChkptWrtImpl ChkptWrt( Ctx file, Arg offset, Arg size, Arg buffer, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { return ChkptWrtImpl( std::move( file ), std::move( offset ), std::move( size ), std::move( buffer ) ).Timeout( timeout ); @@ -172,11 +172,11 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { uint64_t off = std::get( this->args ).Get(); std::vector &stdiov = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; int iovcnt = stdiov.size(); @@ -196,7 +196,7 @@ namespace XrdCl //---------------------------------------------------------------------------- inline ChkptWrtVImpl ChkptWrtV( Ctx file, Arg offset, Arg> iov, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { return ChkptWrtVImpl( std::move( file ), std::move( offset ), std::move( iov ) ).Timeout( timeout ); diff --git a/src/XrdCl/XrdClClassicCopyJob.cc b/src/XrdCl/XrdClClassicCopyJob.cc index 66621bea9fd..60a946ee7bf 100644 --- a/src/XrdCl/XrdClClassicCopyJob.cc +++ b/src/XrdCl/XrdClClassicCopyJob.cc @@ -71,13 +71,13 @@ namespace public: mytimer_t() : start( clock_t::now() ){ } void reset(){ start = clock_t::now(); } - uint64_t elapsed() const + time_t elapsed() const { return std::chrono::duration_cast( clock_t::now() - start ).count(); } private: typedef std::chrono::high_resolution_clock clock_t; - typedef std::chrono::duration unit_t; + typedef std::chrono::duration unit_t; std::chrono::time_point start; }; @@ -2413,7 +2413,7 @@ namespace XrdCl //---------------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------------- - ClassicCopyJob::ClassicCopyJob( uint16_t jobId, + ClassicCopyJob::ClassicCopyJob( uint32_t jobId, PropertyList *jobProperties, PropertyList *jobResults ): CopyJob( jobId, jobProperties, jobResults ) @@ -2442,7 +2442,7 @@ namespace XrdCl int32_t nbXcpSources; long long xRate; long long xRateThreshold; - uint16_t cpTimeout; + time_t cpTimeout; std::vector addcksums; pProperties->Get( "checkSumMode", checkSumMode ); diff --git a/src/XrdCl/XrdClClassicCopyJob.hh b/src/XrdCl/XrdClClassicCopyJob.hh index daf7558fe13..314d92a12b7 100644 --- a/src/XrdCl/XrdClClassicCopyJob.hh +++ b/src/XrdCl/XrdClClassicCopyJob.hh @@ -30,7 +30,7 @@ namespace XrdCl //------------------------------------------------------------------------ // Constructor //------------------------------------------------------------------------ - ClassicCopyJob( uint16_t jobId, + ClassicCopyJob( uint32_t jobId, PropertyList *jobProperties, PropertyList *jobResults ); diff --git a/src/XrdCl/XrdClCopy.cc b/src/XrdCl/XrdClCopy.cc index 3fb20f4776f..cbad497bc3a 100644 --- a/src/XrdCl/XrdClCopy.cc +++ b/src/XrdCl/XrdClCopy.cc @@ -58,8 +58,8 @@ class ProgressDisplay: public XrdCl::CopyProgressHandler //-------------------------------------------------------------------------- //! Begin job //-------------------------------------------------------------------------- - virtual void BeginJob( uint16_t jobNum, - uint16_t jobTotal, + virtual void BeginJob( uint32_t jobNum, + uint32_t jobTotal, const XrdCl::URL *source, const XrdCl::URL *destination ) { @@ -85,11 +85,11 @@ class ProgressDisplay: public XrdCl::CopyProgressHandler //-------------------------------------------------------------------------- //! End job //-------------------------------------------------------------------------- - virtual void EndJob( uint16_t jobNum, const XrdCl::PropertyList *results ) + virtual void EndJob( uint32_t jobNum, const XrdCl::PropertyList *results ) { XrdSysMutexHelper scopedLock( pMutex ); - std::map::iterator it = pOngoingJobs.find( jobNum ); + std::map::iterator it = pOngoingJobs.find( jobNum ); if( it == pOngoingJobs.end() ) return; @@ -189,13 +189,13 @@ class ProgressDisplay: public XrdCl::CopyProgressHandler //-------------------------------------------------------------------------- std::string GetSummaryBar( time_t now ) { - std::map::iterator it; + std::map::iterator it; std::ostringstream o; for( it = pOngoingJobs.begin(); it != pOngoingJobs.end(); ++it ) { JobData &d = it->second; - uint16_t jobNum = it->first; + uint32_t jobNum = it->first; uint64_t speed = 0; if( now-d.started ) @@ -218,7 +218,7 @@ class ProgressDisplay: public XrdCl::CopyProgressHandler //-------------------------------------------------------------------------- //! Job progress //-------------------------------------------------------------------------- - virtual void JobProgress( uint16_t jobNum, + virtual void JobProgress( uint32_t jobNum, uint64_t bytesProcessed, uint64_t bytesTotal ) { @@ -231,7 +231,7 @@ class ProgressDisplay: public XrdCl::CopyProgressHandler return; pPrevious = now; - std::map::iterator it = pOngoingJobs.find( jobNum ); + std::map::iterator it = pOngoingJobs.find( jobNum ); if( it == pOngoingJobs.end() ) return; @@ -300,7 +300,7 @@ class ProgressDisplay: public XrdCl::CopyProgressHandler bool pPrintSourceCheckSum; bool pPrintTargetCheckSum; bool pPrintAdditionalCheckSum; - std::map pOngoingJobs; + std::map pOngoingJobs; XrdSysRecMutex pMutex; }; @@ -944,9 +944,9 @@ int main( int argc, char **argv ) else { std::vector::iterator it; - uint16_t i = 1; - uint16_t jobsRun = 0; - uint16_t errors = 0; + uint32_t i = 1; + uint32_t jobsRun = 0; + uint32_t errors = 0; for( it = resultVect.begin(); it != resultVect.end(); ++it, ++i ) { if( !(*it)->HasProperty( "status" ) ) diff --git a/src/XrdCl/XrdClCopyJob.hh b/src/XrdCl/XrdClCopyJob.hh index 2d7f0288aa1..0fed15b8659 100644 --- a/src/XrdCl/XrdClCopyJob.hh +++ b/src/XrdCl/XrdClCopyJob.hh @@ -38,7 +38,7 @@ namespace XrdCl //------------------------------------------------------------------------ //! Constructor //------------------------------------------------------------------------ - CopyJob( uint16_t jobId, + CopyJob( uint32_t jobId, PropertyList *jobProperties, PropertyList *jobResults ): pProperties( jobProperties ), @@ -109,7 +109,7 @@ namespace XrdCl PropertyList *pResults; URL pSource; URL pTarget; - uint16_t pJobId; + uint32_t pJobId; }; } diff --git a/src/XrdCl/XrdClCopyProcess.cc b/src/XrdCl/XrdClCopyProcess.cc index e6c695d4bf8..b4c5dc01bdb 100644 --- a/src/XrdCl/XrdClCopyProcess.cc +++ b/src/XrdCl/XrdClCopyProcess.cc @@ -48,8 +48,8 @@ namespace public: QueuedCopyJob( XrdCl::CopyJob *job, XrdCl::CopyProgressHandler *progress, - uint16_t currentJob, - uint16_t totalJobs, + uint32_t currentJob, + uint32_t totalJobs, XrdSysSemaphore *sem = 0 ): pJob(job), pProgress(progress), pCurrentJob(currentJob), pTotalJobs(totalJobs), pSem(sem), @@ -188,8 +188,8 @@ namespace private: XrdCl::CopyJob *pJob; XrdCl::CopyProgressHandler *pProgress; - uint16_t pCurrentJob; - uint16_t pTotalJobs; + uint32_t pCurrentJob; + uint32_t pTotalJobs; XrdSysSemaphore *pSem; int pWrtRetryCnt; int pRetryCnt; @@ -518,8 +518,8 @@ namespace XrdCl // Run the show //-------------------------------------------------------------------------- std::vector::iterator it; - uint16_t currentJob = 1; - uint16_t totalJobs = pImpl->pJobs.size(); + uint32_t currentJob = 1; + uint32_t totalJobs = pImpl->pJobs.size(); //-------------------------------------------------------------------------- // Single thread @@ -548,8 +548,8 @@ namespace XrdCl //-------------------------------------------------------------------------- else { - uint16_t workers = std::min( (uint16_t)parallelThreads, - (uint16_t)pImpl->pJobs.size() ); + uint32_t workers = std::min( (uint32_t)parallelThreads, + (uint32_t)pImpl->pJobs.size() ); JobManager jm( workers ); jm.Initialize(); if( !jm.Start() ) diff --git a/src/XrdCl/XrdClCopyProcess.hh b/src/XrdCl/XrdClCopyProcess.hh index 64c6f4f1e04..cdb89572c31 100644 --- a/src/XrdCl/XrdClCopyProcess.hh +++ b/src/XrdCl/XrdClCopyProcess.hh @@ -51,8 +51,8 @@ namespace XrdCl //! @param source the source url of the current job //! @param destination the destination url of the current job //------------------------------------------------------------------------ - virtual void BeginJob( uint16_t jobNum, - uint16_t jobTotal, + virtual void BeginJob( uint32_t jobNum, + uint32_t jobTotal, const URL *source, const URL *destination ) { @@ -65,7 +65,7 @@ namespace XrdCl //! @param jobNum job number //! @param result result of the job //------------------------------------------------------------------------ - virtual void EndJob( uint16_t jobNum, + virtual void EndJob( uint32_t jobNum, const PropertyList *result ) { (void)jobNum; (void)result; @@ -79,7 +79,7 @@ namespace XrdCl //! @param bytesTotal total number of bytes to be processed by the //! current job //------------------------------------------------------------------------ - virtual void JobProgress( uint16_t jobNum, + virtual void JobProgress( uint32_t jobNum, uint64_t bytesProcessed, uint64_t bytesTotal ) { @@ -89,7 +89,7 @@ namespace XrdCl //------------------------------------------------------------------------ //! Determine whether the job should be canceled //------------------------------------------------------------------------ - virtual bool ShouldCancel( uint16_t jobNum ) + virtual bool ShouldCancel( uint32_t jobNum ) { (void)jobNum; return false; @@ -126,7 +126,7 @@ namespace XrdCl //! Configuration properties: //! source [string] - original source URL //! target [string] - target directory or file - //! sourceLimit [uint16_t] - maximum number sources + //! sourceLimit [uint32_t] - maximum number sources //! force [bool] - overwrite target if exists //! posc [bool] - persistify only on successful close //! coerce [bool] - ignore locking semantics on destination @@ -144,9 +144,9 @@ namespace XrdCl //! chunkSize [uint32_t] - size of a copy chunks in bytes //! parallelChunks [uint8_t] - number of chunks that should be requested //! in parallel - //! initTimeout [uint16_t] - time limit for successfull initialization + //! initTimeout [time_t] - time limit for successfull initialization //! of the copy job - //! tpcTimeout [uint16_t] - time limit for the actual copy to finish + //! tpcTimeout [time_t] - time limit for the actual copy to finish //! dynamicSource [bool] - support for the case where the size source //! file may change during reading process //! diff --git a/src/XrdCl/XrdClEcHandler.hh b/src/XrdCl/XrdClEcHandler.hh index 724c8595432..b595ab9e1c1 100644 --- a/src/XrdCl/XrdClEcHandler.hh +++ b/src/XrdCl/XrdClEcHandler.hh @@ -144,7 +144,7 @@ namespace XrdCl XRootDStatus Open( uint16_t flags, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( ( flags & OpenFlags::Write ) || ( flags & OpenFlags::Update ) ) { @@ -185,7 +185,7 @@ namespace XrdCl OpenFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)url; (void)mode; return Open( flags, handler, timeout ); @@ -196,7 +196,7 @@ namespace XrdCl //! //------------------------------------------------------------------------ XRootDStatus Close( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( writer ) { @@ -248,7 +248,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus Stat( bool force, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( !objcfg->nomtfile ) @@ -289,7 +289,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( !reader ) return XRootDStatus( stError, errInternal ); @@ -302,7 +302,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus PgRead(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout) + time_t timeout) { ResponseHandler *substitHandler = new EcPgReadResponseHandler( handler ); XRootDStatus st = Read(offset, size, buffer, substitHandler, timeout); @@ -317,7 +317,7 @@ namespace XrdCl uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( cksHelper ) cksHelper->Update( buffer, size ); @@ -337,7 +337,7 @@ namespace XrdCl const void *buffer, std::vector &cksums, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { if(! cksums.empty() ) { diff --git a/src/XrdCl/XrdClEnv.cc b/src/XrdCl/XrdClEnv.cc index 9b8f6e1e858..24bb583ef11 100644 --- a/src/XrdCl/XrdClEnv.cc +++ b/src/XrdCl/XrdClEnv.cc @@ -142,6 +142,43 @@ namespace XrdCl return true; } + //---------------------------------------------------------------------------- + // Get pointer + //---------------------------------------------------------------------------- + bool Env::GetPtr( const std::string &k, void* &value ) + { + std::string key = UnifyKey( k ); + XrdSysRWLockHelper scopedLock( pLock ); + PtrMap::iterator it; + it = pPtrMap.find( key ); + if( it == pPtrMap.end() ) + { + Log *log = DefaultEnv::GetLog(); + log->Debug( UtilityMsg, + "Env: trying to get a non-existent pointer entry: %s", + key.c_str() ); + return false; + } + value = it->second; + return true; + } + + //---------------------------------------------------------------------------- + // Put pointer + //---------------------------------------------------------------------------- + bool Env::PutPtr( const std::string &k, void* value ) + { + std::string key = UnifyKey( k ); + XrdSysRWLockHelper scopedLock( pLock, false ); + + // Pointers cannot be imported from shell environment, we always set it. + bool ret = pPtrMap.find(key) == pPtrMap.end(); + + pPtrMap[key] = value; + + return ret; + } + //---------------------------------------------------------------------------- // Import int //---------------------------------------------------------------------------- diff --git a/src/XrdCl/XrdClEnv.hh b/src/XrdCl/XrdClEnv.hh index 4933eba7ef9..7f9563ba114 100644 --- a/src/XrdCl/XrdClEnv.hh +++ b/src/XrdCl/XrdClEnv.hh @@ -72,6 +72,20 @@ namespace XrdCl //------------------------------------------------------------------------ bool PutInt( const std::string &key, int value ); + //------------------------------------------------------------------------ + //! Get a pointer associated to the given key + //! + //! @return true if the value was found, false otherwise + //------------------------------------------------------------------------ + bool GetPtr( const std::string &key, void* &value ); + + //------------------------------------------------------------------------ + //! Associate an int with the given key + //! + //! @return true if the key was previously unset, false otherwise. + //------------------------------------------------------------------------ + bool PutPtr( const std::string &key, void* value ); + //------------------------------------------------------------------------ //! Import an int from the shell environment. Any imported setting //! takes precedence over the one set by other means. @@ -169,10 +183,12 @@ namespace XrdCl std::string GetEnv( const std::string &key ); typedef std::map > StringMap; typedef std::map > IntMap; + typedef std::map PtrMap; XrdSysRWLock pLock; StringMap pStringMap; IntMap pIntMap; + PtrMap pPtrMap; }; } diff --git a/src/XrdCl/XrdClFS.cc b/src/XrdCl/XrdClFS.cc index f75c77bbc34..c4c12e5e13a 100644 --- a/src/XrdCl/XrdClFS.cc +++ b/src/XrdCl/XrdClFS.cc @@ -1435,7 +1435,7 @@ class ProgressDisplay: public XrdCl::CopyProgressHandler //-------------------------------------------------------------------------- // End job //-------------------------------------------------------------------------- - virtual void EndJob( uint16_t jobNum, const XrdCl::PropertyList *results ) + virtual void EndJob( uint32_t jobNum, const XrdCl::PropertyList *results ) { JobProgress( jobNum, pBytesProcessed, pBytesTotal ); std::cerr << std::endl; @@ -1444,7 +1444,7 @@ class ProgressDisplay: public XrdCl::CopyProgressHandler //-------------------------------------------------------------------------- // Job progress //-------------------------------------------------------------------------- - virtual void JobProgress( uint16_t jobNum, + virtual void JobProgress( uint32_t jobNum, uint64_t bytesProcessed, uint64_t bytesTotal ) { diff --git a/src/XrdCl/XrdClFile.cc b/src/XrdCl/XrdClFile.cc index b879fa1984f..f5b63614894 100644 --- a/src/XrdCl/XrdClFile.cc +++ b/src/XrdCl/XrdClFile.cc @@ -100,7 +100,7 @@ namespace XrdCl OpenFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { //-------------------------------------------------------------------------- // Check if we need to install and run a plug-in for this URL @@ -135,7 +135,7 @@ namespace XrdCl XRootDStatus File::Open( const std::string &url, OpenFlags::Flags flags, Access::Mode mode, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = Open( url, flags, mode, &handler, timeout ); @@ -149,7 +149,7 @@ namespace XrdCl // Close the file - async //---------------------------------------------------------------------------- XRootDStatus File::Close( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Close( handler, timeout ); @@ -161,7 +161,7 @@ namespace XrdCl //---------------------------------------------------------------------------- // Close the file //---------------------------------------------------------------------------- - XRootDStatus File::Close( uint16_t timeout ) + XRootDStatus File::Close( time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = Close( &handler, timeout ); @@ -176,7 +176,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus File::Stat( bool force, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Stat( force, handler, timeout ); @@ -189,7 +189,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus File::Stat( bool force, StatInfo *&response, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = Stat( force, &handler, timeout ); @@ -207,7 +207,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Read( offset, size, buffer, handler, timeout ); @@ -222,7 +222,7 @@ namespace XrdCl uint32_t size, void *buffer, uint32_t &bytesRead, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = Read( offset, size, buffer, &handler, timeout ); @@ -246,7 +246,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->PgRead( offset, size, buffer, handler, timeout ); @@ -262,7 +262,7 @@ namespace XrdCl void *buffer, std::vector &cksums, uint32_t &bytesRead, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = PgRead( offset, size, buffer, &handler, timeout ); @@ -287,7 +287,7 @@ namespace XrdCl uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Write( offset, size, buffer, handler, timeout ); @@ -301,7 +301,7 @@ namespace XrdCl XRootDStatus File::Write( uint64_t offset, uint32_t size, const void *buffer, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = Write( offset, size, buffer, &handler, timeout ); @@ -316,7 +316,7 @@ namespace XrdCl XRootDStatus File::Write( uint64_t offset, Buffer &&buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Write( offset, std::move( buffer ), handler, timeout ); @@ -329,7 +329,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus File::Write( uint64_t offset, Buffer &&buffer, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = Write( offset, std::move( buffer ), &handler, timeout ); @@ -348,7 +348,7 @@ namespace XrdCl Optional fdoff, int fd, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Write( offset, size, fdoff, fd, handler, timeout ); @@ -363,7 +363,7 @@ namespace XrdCl uint32_t size, Optional fdoff, int fd, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = Write( offset, size, fdoff, fd, &handler, timeout ); @@ -382,7 +382,7 @@ namespace XrdCl const void *buffer, std::vector &cksums, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->PgWrite( offset, size, buffer, cksums, handler, timeout ); @@ -397,7 +397,7 @@ namespace XrdCl uint32_t size, const void *buffer, std::vector &cksums, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = PgWrite( offset, size, buffer, cksums, &handler, timeout ); @@ -412,7 +412,7 @@ namespace XrdCl // Commit all pending disk writes - async //---------------------------------------------------------------------------- XRootDStatus File::Sync( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Sync( handler, timeout ); @@ -423,7 +423,7 @@ namespace XrdCl //---------------------------------------------------------------------------- // Commit all pending disk writes - sync //---------------------------------------------------------------------------- - XRootDStatus File::Sync( uint16_t timeout ) + XRootDStatus File::Sync( time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = Sync( &handler, timeout ); @@ -439,7 +439,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus File::Truncate( uint64_t size, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Truncate( size, handler, timeout ); @@ -451,7 +451,7 @@ namespace XrdCl //---------------------------------------------------------------------------- // Truncate the file to a particular size - sync //---------------------------------------------------------------------------- - XRootDStatus File::Truncate( uint64_t size, uint16_t timeout ) + XRootDStatus File::Truncate( uint64_t size, time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = Truncate( size, &handler, timeout ); @@ -468,7 +468,7 @@ namespace XrdCl XRootDStatus File::VectorRead( const ChunkList &chunks, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->VectorRead( chunks, buffer, handler, timeout ); @@ -482,7 +482,7 @@ namespace XrdCl XRootDStatus File::VectorRead( const ChunkList &chunks, void *buffer, VectorReadInfo *&vReadInfo, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = VectorRead( chunks, buffer, &handler, timeout ); @@ -497,7 +497,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus File::VectorWrite( const ChunkList &chunks, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->VectorWrite( chunks, handler, timeout ); @@ -509,7 +509,7 @@ namespace XrdCl // Read scattered data chunks in one operation - sync //------------------------------------------------------------------------ XRootDStatus File::VectorWrite( const ChunkList &chunks, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = VectorWrite( chunks, &handler, timeout ); @@ -526,7 +526,7 @@ namespace XrdCl const struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->WriteV( offset, iov, iovcnt, handler, timeout ); @@ -540,7 +540,7 @@ namespace XrdCl XRootDStatus File::WriteV( uint64_t offset, const struct iovec *iov, int iovcnt, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = WriteV( offset, iov, iovcnt, &handler, timeout ); @@ -566,7 +566,7 @@ namespace XrdCl struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { return FileStateHandler::ReadV( pImpl->pStateHandler, offset, iov, iovcnt, handler, timeout ); } @@ -586,7 +586,7 @@ namespace XrdCl struct iovec *iov, int iovcnt, uint32_t &bytesRead, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = ReadV( offset, iov, iovcnt, &handler, timeout ); @@ -609,7 +609,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus File::Fcntl( const Buffer &arg, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Fcntl( arg, handler, timeout ); @@ -623,7 +623,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus File::Fcntl( const Buffer &arg, Buffer *&response, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = Fcntl( arg, &handler, timeout ); @@ -637,7 +637,7 @@ namespace XrdCl //! Get access token to a file - async //------------------------------------------------------------------------ XRootDStatus File::Visa( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Visa( handler, timeout ); @@ -649,7 +649,7 @@ namespace XrdCl // Get access token to a file - sync //---------------------------------------------------------------------------- XRootDStatus File::Visa( Buffer *&visa, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = Visa( &handler, timeout ); @@ -664,7 +664,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus File::SetXAttr( const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return XRootDStatus( stError, errNotSupported ); @@ -677,7 +677,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus File::SetXAttr( const std::vector &attrs, std::vector &result, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = SetXAttr( attrs, &handler, timeout ); @@ -697,7 +697,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus File::GetXAttr( const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return XRootDStatus( stError, errNotSupported ); @@ -710,7 +710,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus File::GetXAttr( const std::vector &attrs, std::vector &result, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = GetXAttr( attrs, &handler, timeout ); @@ -730,7 +730,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus File::DelXAttr( const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return XRootDStatus( stError, errNotSupported ); @@ -743,7 +743,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus File::DelXAttr( const std::vector &attrs, std::vector &result, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = DelXAttr( attrs, &handler, timeout ); @@ -762,7 +762,7 @@ namespace XrdCl // List extended attributes - async //------------------------------------------------------------------------ XRootDStatus File::ListXAttr( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return XRootDStatus( stError, errNotSupported ); @@ -774,7 +774,7 @@ namespace XrdCl // List extended attributes - sync //------------------------------------------------------------------------ XRootDStatus File::ListXAttr( std::vector &result, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = ListXAttr( &handler, timeout ); @@ -794,7 +794,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus File::Checkpoint( kXR_char code, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return XRootDStatus( stError, errNotSupported ); @@ -809,7 +809,7 @@ namespace XrdCl uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return XRootDStatus( stError, errNotSupported ); @@ -824,7 +824,7 @@ namespace XrdCl const struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return XRootDStatus( stError, errNotSupported ); @@ -835,7 +835,7 @@ namespace XrdCl //------------------------------------------------------------------------ // Try different data server //------------------------------------------------------------------------ - XRootDStatus File::TryOtherServer( uint16_t timeout ) + XRootDStatus File::TryOtherServer( time_t timeout ) { return FileStateHandler::TryOtherServer( pImpl->pStateHandler, timeout ); } diff --git a/src/XrdCl/XrdClFile.hh b/src/XrdCl/XrdClFile.hh index db9fbc0e4a2..f4847314c11 100644 --- a/src/XrdCl/XrdClFile.hh +++ b/src/XrdCl/XrdClFile.hh @@ -82,7 +82,7 @@ namespace XrdCl OpenFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -98,7 +98,7 @@ namespace XrdCl XRootDStatus Open( const std::string &url, OpenFlags::Flags flags, Access::Mode mode = Access::None, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -110,7 +110,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Close( ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -120,7 +120,7 @@ namespace XrdCl //! used //! @return status of the operation //------------------------------------------------------------------------ - XRootDStatus Close( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; + XRootDStatus Close( time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ //! Obtain status information for this file - async @@ -135,7 +135,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus Stat( bool force, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -149,7 +149,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus Stat( bool force, StatInfo *&response, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; @@ -171,7 +171,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -189,7 +189,7 @@ namespace XrdCl uint32_t size, void *buffer, uint32_t &bytesRead, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -209,7 +209,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -229,7 +229,7 @@ namespace XrdCl void *buffer, std::vector &cksums, uint32_t &bytesRead, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -250,7 +250,7 @@ namespace XrdCl uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -270,7 +270,7 @@ namespace XrdCl XRootDStatus Write( uint64_t offset, uint32_t size, const void *buffer, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -287,7 +287,7 @@ namespace XrdCl XRootDStatus Write( uint64_t offset, Buffer &&buffer, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write a data chunk at a given offset - sync @@ -301,7 +301,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus Write( uint64_t offset, Buffer &&buffer, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write a data from a given file descriptor at a given offset - async @@ -322,7 +322,7 @@ namespace XrdCl Optional fdoff, int fd, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write a data from a given file descriptor at a given offset - sync @@ -341,7 +341,7 @@ namespace XrdCl uint32_t size, Optional fdoff, int fd, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write number of pages at a given offset - async @@ -360,7 +360,7 @@ namespace XrdCl const void *buffer, std::vector &cksums, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -378,7 +378,7 @@ namespace XrdCl uint32_t size, const void *buffer, std::vector &cksums, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -390,7 +390,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Sync( ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; @@ -401,7 +401,7 @@ namespace XrdCl //! used //! @return status of the operation //------------------------------------------------------------------------ - XRootDStatus Sync( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; + XRootDStatus Sync( time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ //! Truncate the file to a particular size - async @@ -414,7 +414,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus Truncate( uint64_t size, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; @@ -427,7 +427,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Truncate( uint64_t size, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -450,7 +450,7 @@ namespace XrdCl XRootDStatus VectorRead( const ChunkList &chunks, void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -473,7 +473,7 @@ namespace XrdCl XRootDStatus VectorRead( const ChunkList &chunks, void *buffer, VectorReadInfo *&vReadInfo, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -487,7 +487,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus VectorWrite( const ChunkList &chunks, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -499,7 +499,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus VectorWrite( const ChunkList &chunks, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -517,7 +517,7 @@ namespace XrdCl const struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write scattered buffers in one operation - sync @@ -532,7 +532,7 @@ namespace XrdCl XRootDStatus WriteV( uint64_t offset, const struct iovec *iov, int iovcnt, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Read data into scattered buffers in one operation - async @@ -549,7 +549,7 @@ namespace XrdCl struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Read data into scattered buffers in one operation - sync @@ -566,7 +566,7 @@ namespace XrdCl struct iovec *iov, int iovcnt, uint32_t &bytesRead, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Performs a custom operation on an open file, server implementation @@ -582,7 +582,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus Fcntl( const Buffer &arg, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -597,7 +597,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus Fcntl( const Buffer &arg, Buffer *&response, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -611,7 +611,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Visa( ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -623,7 +623,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Visa( Buffer *&visa, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -640,7 +640,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus SetXAttr( const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Set extended attributes - sync @@ -654,7 +654,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus SetXAttr( const std::vector &attrs, std::vector &result, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Get extended attributes - async @@ -670,7 +670,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus GetXAttr( const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Get extended attributes - sync @@ -684,7 +684,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus GetXAttr( const std::vector &attrs, std::vector &result, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Delete extended attributes - async @@ -700,7 +700,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus DelXAttr( const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Delete extended attributes - sync @@ -714,7 +714,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus DelXAttr( const std::vector &attrs, std::vector &result, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! List extended attributes - async @@ -728,7 +728,7 @@ namespace XrdCl //! @return : status of the operation //------------------------------------------------------------------------ XRootDStatus ListXAttr( ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! List extended attributes - sync @@ -740,7 +740,7 @@ namespace XrdCl //! @return : status of the operation //------------------------------------------------------------------------ XRootDStatus ListXAttr( std::vector &result, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Try different data server @@ -750,7 +750,7 @@ namespace XrdCl //! //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus TryOtherServer( uint16_t timeout = 0 ); + XRootDStatus TryOtherServer( time_t timeout = 0 ); //------------------------------------------------------------------------ //! Check if the file is open @@ -808,7 +808,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus Checkpoint( kXR_char code, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Checkpointed write - async @@ -825,7 +825,7 @@ namespace XrdCl uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Checkpointed WriteV - async @@ -842,7 +842,7 @@ namespace XrdCl const struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); FileImpl *pImpl; FilePlugIn *pPlugIn; diff --git a/src/XrdCl/XrdClFileOperations.hh b/src/XrdCl/XrdClFileOperations.hh index ace6177945a..7ce124a8853 100644 --- a/src/XrdCl/XrdClFileOperations.hh +++ b/src/XrdCl/XrdClFileOperations.hh @@ -198,12 +198,12 @@ namespace XrdCl //! @param pipelineTimeout : pipeline timeout //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { const std::string &url = std::get( this->args ); OpenFlags::Flags flags = std::get( this->args ); Access::Mode mode = std::get( this->args ); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->Open( url, flags, mode, handler, timeout ); } @@ -213,7 +213,7 @@ namespace XrdCl //! Factory for creating ReadImpl objects //---------------------------------------------------------------------------- inline OpenImpl Open( Ctx file, Arg url, Arg flags, - Arg mode = Access::None, uint16_t timeout = 0 ) + Arg mode = Access::None, time_t timeout = 0 ) { return OpenImpl( std::move( file ), std::move( url ), std::move( flags ), std::move( mode ) ).Timeout( timeout ); @@ -256,12 +256,12 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { uint64_t offset = std::get( this->args ).Get(); uint32_t size = std::get( this->args ).Get(); void *buffer = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->Read( offset, size, buffer, handler, timeout ); } @@ -271,7 +271,7 @@ namespace XrdCl //! Factory for creating ReadImpl objects //---------------------------------------------------------------------------- inline ReadImpl Read( Ctx file, Arg offset, Arg size, - Arg buffer, uint16_t timeout = 0 ) + Arg buffer, time_t timeout = 0 ) { return ReadImpl( std::move( file ), std::move( offset ), std::move( size ), std::move( buffer ) ).Timeout( timeout ); @@ -314,12 +314,12 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { uint64_t offset = std::get( this->args ).Get(); uint32_t size = std::get( this->args ).Get(); void *buffer = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->PgRead( offset, size, buffer, handler, timeout ); } @@ -330,7 +330,7 @@ namespace XrdCl //---------------------------------------------------------------------------- inline PgReadImpl PgRead( Ctx file, Arg offset, Arg size, Arg buffer, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { return PgReadImpl( std::move( file ), std::move( offset ), std::move( size ), std::move( buffer ) ).Timeout( timeout ); @@ -347,11 +347,11 @@ namespace XrdCl template inline typename ReadTrait::RET RdWithRsp( Ctx file, Arg offset, Arg size, - Arg buffer, uint16_t timeout = 0 ); + Arg buffer, time_t timeout = 0 ); template<> inline ReadImpl RdWithRsp( Ctx file, Arg offset, Arg size, - Arg buffer, uint16_t timeout ) + Arg buffer, time_t timeout ) { return Read( std::move( file ), std::move( offset ), std::move( size ), std::move( buffer ), timeout ); @@ -359,7 +359,7 @@ namespace XrdCl template<> inline PgReadImpl RdWithRsp( Ctx file, Arg offset, Arg size, - Arg buffer, uint16_t timeout ) + Arg buffer, time_t timeout ) { return PgRead( std::move( file ), std::move( offset ), std::move( size ), std::move( buffer ), timeout ); @@ -402,13 +402,13 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { uint64_t offset = std::get( this->args ).Get(); uint32_t size = std::get( this->args ).Get(); void *buffer = std::get( this->args ).Get(); std::vector cksums = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->PgWrite( offset, size, buffer, cksums, handler, timeout ); } @@ -420,7 +420,7 @@ namespace XrdCl inline PgWriteImpl PgWrite( Ctx file, Arg offset, Arg size, Arg buffer, Arg> cksums, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { return PgWriteImpl( std::move( file ), std::move( offset ), std::move( size ), std::move( buffer ), std::move( cksums ) ).Timeout( timeout ); @@ -431,7 +431,7 @@ namespace XrdCl //---------------------------------------------------------------------------- inline PgWriteImpl PgWrite( Ctx file, Arg offset, Arg size, Arg buffer, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { std::vector cksums; return PgWriteImpl( std::move( file ), std::move( offset ), std::move( size ), @@ -468,9 +468,9 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->Close( handler, timeout ); } @@ -479,7 +479,7 @@ namespace XrdCl //---------------------------------------------------------------------------- //! Factory for creating CloseImpl objects //---------------------------------------------------------------------------- - inline CloseImpl Close( Ctx file, uint16_t timeout = 0 ) + inline CloseImpl Close( Ctx file, time_t timeout = 0 ) { return CloseImpl( std::move( file ) ).Timeout( timeout ); } @@ -519,10 +519,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { bool force = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->Stat( force, handler, timeout ); } @@ -532,7 +532,7 @@ namespace XrdCl //! Factory for creating StatImpl objects (as there is another Stat in //! FileSystem there would be a clash of typenames). //---------------------------------------------------------------------------- - inline StatImpl Stat( Ctx file, Arg force, uint16_t timeout = 0 ) + inline StatImpl Stat( Ctx file, Arg force, time_t timeout = 0 ) { return StatImpl( std::move( file ), std::move( force ) ).Timeout( timeout ); } @@ -574,12 +574,12 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { uint64_t offset = std::get( this->args ).Get(); uint32_t size = std::get( this->args ).Get(); const void *buffer = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->Write( offset, size, buffer, handler, timeout ); } @@ -589,7 +589,7 @@ namespace XrdCl //! Factory for creating WriteImpl objects //---------------------------------------------------------------------------- inline WriteImpl Write( Ctx file, Arg offset, Arg size, - Arg buffer, uint16_t timeout = 0 ) + Arg buffer, time_t timeout = 0 ) { return WriteImpl( std::move( file ), std::move( offset ), std::move( size ), std::move( buffer ) ).Timeout( timeout ); @@ -625,9 +625,9 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->Sync( handler, timeout ); } @@ -636,7 +636,7 @@ namespace XrdCl //---------------------------------------------------------------------------- //! Factory for creating SyncImpl objects //---------------------------------------------------------------------------- - inline SyncImpl Sync( Ctx file, uint16_t timeout = 0 ) + inline SyncImpl Sync( Ctx file, time_t timeout = 0 ) { return SyncImpl( std::move( file ) ).Timeout( timeout ); } @@ -676,10 +676,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { uint64_t size = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->Truncate( size, handler, timeout ); } @@ -689,7 +689,7 @@ namespace XrdCl //! Factory for creating TruncateImpl objects (as there is another Stat in //! FileSystem there would be a clash of typenames). //---------------------------------------------------------------------------- - inline TruncateImpl Truncate( Ctx file, Arg size, uint16_t timeout ) + inline TruncateImpl Truncate( Ctx file, Arg size, time_t timeout ) { return TruncateImpl( std::move( file ), std::move( size ) ).Timeout( timeout ); } @@ -731,11 +731,11 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { ChunkList &chunks = std::get( this->args ).Get(); void *buffer = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->VectorRead( chunks, buffer, handler, timeout ); } @@ -745,13 +745,13 @@ namespace XrdCl //! Factory for creating VectorReadImpl objects //---------------------------------------------------------------------------- inline VectorReadImpl VectorRead( Ctx file, Arg chunks, - Arg buffer, uint16_t timeout = 0 ) + Arg buffer, time_t timeout = 0 ) { return VectorReadImpl( std::move( file ), std::move( chunks ), std::move( buffer ) ).Timeout( timeout ); } inline VectorReadImpl VectorRead( Ctx file, Arg chunks, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { return VectorReadImpl( std::move( file ), std::move( chunks ), nullptr ).Timeout( timeout ); } @@ -792,10 +792,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { const ChunkList &chunks = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->VectorWrite( chunks, handler, timeout ); } @@ -805,7 +805,7 @@ namespace XrdCl //! Factory for creating VectorWriteImpl objects //---------------------------------------------------------------------------- inline VectorWriteImpl VectorWrite( Ctx file, Arg chunks, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { return VectorWriteImpl( std::move( file ), std::move( chunks ) ).Timeout( timeout ); } @@ -847,11 +847,11 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { uint64_t offset = std::get( this->args ).Get(); std::vector &stdiov = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; int iovcnt = stdiov.size(); @@ -870,7 +870,7 @@ namespace XrdCl //! Factory for creating WriteVImpl objects //---------------------------------------------------------------------------- inline WriteVImpl WriteV( Ctx file, Arg offset, - Arg> iov, uint16_t timeout = 0 ) + Arg> iov, time_t timeout = 0 ) { return WriteVImpl( std::move( file ), std::move( offset ), std::move( iov ) ).Timeout( timeout ); @@ -911,10 +911,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { Buffer &arg = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->Fcntl( arg, handler, timeout ); } @@ -951,9 +951,9 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->Visa( handler, timeout ); } @@ -997,7 +997,7 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &name = std::get( this->args ).Get(); std::string &value = std::get( this->args ).Get(); @@ -1006,7 +1006,7 @@ namespace XrdCl attrs.push_back( xattr_t( name, value ) ); // wrap the PipelineHandler so the response gets unpacked properly UnpackXAttrStatus *h = new UnpackXAttrStatus( handler ); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; XRootDStatus st = this->file->SetXAttr( attrs, h, timeout ); if( !st.IsOK() ) delete h; @@ -1061,10 +1061,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::vector &attrs = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->SetXAttr( attrs, handler, timeout ); } @@ -1116,7 +1116,7 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &name = std::get( this->args ).Get(); // wrap the argument with a vector @@ -1124,7 +1124,7 @@ namespace XrdCl attrs.push_back( name ); // wrap the PipelineHandler so the response gets unpacked properly UnpackXAttr *h = new UnpackXAttr( handler ); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; XRootDStatus st = this->file->GetXAttr( attrs, h, timeout ); if( !st.IsOK() ) delete h; @@ -1179,10 +1179,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::vector &attrs = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->GetXAttr( attrs, handler, timeout ); } @@ -1233,7 +1233,7 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &name = std::get( this->args ).Get(); // wrap the argument with a vector @@ -1241,7 +1241,7 @@ namespace XrdCl attrs.push_back( name ); // wrap the PipelineHandler so the response gets unpacked properly UnpackXAttrStatus *h = new UnpackXAttrStatus( handler ); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; XRootDStatus st = this->file->DelXAttr( attrs, h, timeout ); if( !st.IsOK() ) delete h; @@ -1296,10 +1296,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::vector &attrs = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->DelXAttr( attrs, handler, timeout ); } @@ -1346,9 +1346,9 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->file->ListXAttr( handler, timeout ); } diff --git a/src/XrdCl/XrdClFileStateHandler.cc b/src/XrdCl/XrdClFileStateHandler.cc index cb9ed737cb8..1a290472a19 100644 --- a/src/XrdCl/XrdClFileStateHandler.cc +++ b/src/XrdCl/XrdClFileStateHandler.cc @@ -749,7 +749,7 @@ namespace XrdCl uint16_t flags, uint16_t mode, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -873,7 +873,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileStateHandler::Close( std::shared_ptr &self, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -952,7 +952,7 @@ namespace XrdCl XRootDStatus FileStateHandler::Stat( std::shared_ptr &self, bool force, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -1011,7 +1011,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -1057,7 +1057,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { int issupported = true; AnyObject obj; @@ -1096,7 +1096,7 @@ namespace XrdCl size_t pgnb, void *buffer, PgReadHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( size > (uint32_t)XrdSys::PageSize ) return XRootDStatus( stError, errInvalidArgs, EINVAL, @@ -1114,7 +1114,7 @@ namespace XrdCl void *buffer, uint16_t flags, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -1170,7 +1170,7 @@ namespace XrdCl uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -1217,7 +1217,7 @@ namespace XrdCl uint64_t offset, Buffer &&buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { //-------------------------------------------------------------------------- // If the memory is not page (4KB) aligned we cannot use the kernel buffer @@ -1269,7 +1269,7 @@ namespace XrdCl Optional fdoff, int fd, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { //-------------------------------------------------------------------------- // Read the data from the file descriptor into a kernel buffer @@ -1295,7 +1295,7 @@ namespace XrdCl const void *buffer, std::vector &cksums, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { //-------------------------------------------------------------------------- // Resolve timeout value @@ -1384,7 +1384,7 @@ namespace XrdCl } delete s; // first adjust the timeout value - uint16_t elapsed = ::time( nullptr ) - start; + time_t elapsed = ::time( nullptr ) - start; if( elapsed >= timeout ) { pgwrt->SetStatus( new XRootDStatus( stError, errOperationExpired ) ); @@ -1451,7 +1451,7 @@ namespace XrdCl const void *buffer, uint32_t digest, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { std::vector cksums{ digest }; return PgWriteImpl( self, offset, size, buffer, cksums, PgReadFlags::Retry, handler, timeout ); @@ -1467,7 +1467,7 @@ namespace XrdCl std::vector &cksums, kXR_char flags, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -1517,7 +1517,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileStateHandler::Sync( std::shared_ptr &self, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -1556,7 +1556,7 @@ namespace XrdCl XRootDStatus FileStateHandler::Truncate( std::shared_ptr &self, uint64_t size, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -1597,7 +1597,7 @@ namespace XrdCl const ChunkList &chunks, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { //-------------------------------------------------------------------------- // Sanity check @@ -1673,7 +1673,7 @@ namespace XrdCl XRootDStatus FileStateHandler::VectorWrite( std::shared_ptr &self, const ChunkList &chunks, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { //-------------------------------------------------------------------------- // Sanity check @@ -1752,7 +1752,7 @@ namespace XrdCl const struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -1808,7 +1808,7 @@ namespace XrdCl struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -1865,7 +1865,7 @@ namespace XrdCl XRootDStatus FileStateHandler::Fcntl( std::shared_ptr &self, const Buffer &arg, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -1906,7 +1906,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileStateHandler::Visa( std::shared_ptr &self, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -1946,7 +1946,7 @@ namespace XrdCl XRootDStatus FileStateHandler::SetXAttr( std::shared_ptr &self, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -1972,7 +1972,7 @@ namespace XrdCl XRootDStatus FileStateHandler::GetXAttr( std::shared_ptr &self, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -1998,7 +1998,7 @@ namespace XrdCl XRootDStatus FileStateHandler::DelXAttr( std::shared_ptr &self, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -2023,7 +2023,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus FileStateHandler::ListXAttr( std::shared_ptr &self, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -2059,7 +2059,7 @@ namespace XrdCl XRootDStatus FileStateHandler::Checkpoint( std::shared_ptr &self, kXR_char code, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -2110,7 +2110,7 @@ namespace XrdCl uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -2172,7 +2172,7 @@ namespace XrdCl const struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -2764,7 +2764,7 @@ namespace XrdCl //------------------------------------------------------------------------ // Try other data server //------------------------------------------------------------------------ - XRootDStatus FileStateHandler::TryOtherServer( std::shared_ptr &self, uint16_t timeout ) + XRootDStatus FileStateHandler::TryOtherServer( std::shared_ptr &self, time_t timeout ) { XrdSysMutexHelper scopedLock( self->pMutex ); @@ -2805,7 +2805,7 @@ namespace XrdCl kXR_char options, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { //-------------------------------------------------------------------------- // Issue a new fattr request @@ -2976,7 +2976,7 @@ namespace XrdCl // Send a close and ignore the response //---------------------------------------------------------------------------- XRootDStatus FileStateHandler::SendClose( std::shared_ptr &self, - uint16_t timeout ) + time_t timeout ) { Message *msg; ClientCloseRequest *req; @@ -3004,7 +3004,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileStateHandler::ReOpenFileAtServer( std::shared_ptr &self, const URL &url, - uint16_t timeout ) + time_t timeout ) { Log *log = DefaultEnv::GetLog(); log->Dump( FileMsg, "[%p@%s] Sending a recovery open command to %s", @@ -3246,7 +3246,7 @@ namespace XrdCl uint32_t length, std::unique_ptr kbuff, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { //-------------------------------------------------------------------------- // Create the write request diff --git a/src/XrdCl/XrdClFileStateHandler.hh b/src/XrdCl/XrdClFileStateHandler.hh index f8353881950..84c852c5d37 100644 --- a/src/XrdCl/XrdClFileStateHandler.hh +++ b/src/XrdCl/XrdClFileStateHandler.hh @@ -131,7 +131,7 @@ namespace XrdCl uint16_t flags, uint16_t mode, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Close the file object @@ -143,7 +143,7 @@ namespace XrdCl //------------------------------------------------------------------------ static XRootDStatus Close( std::shared_ptr &self, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Obtain status information for this file - async @@ -159,7 +159,7 @@ namespace XrdCl static XRootDStatus Stat( std::shared_ptr &self, bool force, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ @@ -183,7 +183,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Read data pages at a given offset @@ -204,7 +204,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Retry reading one page of data at a given offset @@ -224,7 +224,7 @@ namespace XrdCl size_t pgnb, void *buffer, PgReadHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Read data pages at a given offset (actual implementation) @@ -247,7 +247,7 @@ namespace XrdCl void *buffer, uint16_t flags, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write a data chunk at a given offset - async @@ -265,7 +265,7 @@ namespace XrdCl uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write a data chunk at a given offset - async @@ -282,7 +282,7 @@ namespace XrdCl uint64_t offset, Buffer &&buffer, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write a data from a given file descriptor at a given offset - async @@ -304,7 +304,7 @@ namespace XrdCl Optional fdoff, int fd, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write number of pages at a given offset - async @@ -324,7 +324,7 @@ namespace XrdCl const void *buffer, std::vector &cksums, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write number of pages at a given offset - async @@ -343,7 +343,7 @@ namespace XrdCl const void *buffer, uint32_t digest, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write number of pages at a given offset - async @@ -365,7 +365,7 @@ namespace XrdCl std::vector &cksums, kXR_char flags, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Commit all pending disk writes - async @@ -377,7 +377,7 @@ namespace XrdCl //------------------------------------------------------------------------ static XRootDStatus Sync( std::shared_ptr &self, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Truncate the file to a particular size - async @@ -391,7 +391,7 @@ namespace XrdCl static XRootDStatus Truncate( std::shared_ptr &self, uint64_t size, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Read scattered data chunks in one operation - async @@ -407,7 +407,7 @@ namespace XrdCl const ChunkList &chunks, void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write scattered data chunks in one operation - async @@ -421,7 +421,7 @@ namespace XrdCl static XRootDStatus VectorWrite( std::shared_ptr &self, const ChunkList &chunks, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write scattered buffers in one operation - async @@ -439,7 +439,7 @@ namespace XrdCl const struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Read data into scattered buffers in one operation - async @@ -457,7 +457,7 @@ namespace XrdCl struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Performs a custom operation on an open file, server implementation @@ -474,7 +474,7 @@ namespace XrdCl static XRootDStatus Fcntl( std::shared_ptr &self, const Buffer &arg, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Get access token to a file - async @@ -488,7 +488,7 @@ namespace XrdCl //------------------------------------------------------------------------ static XRootDStatus Visa( std::shared_ptr &self, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Set extended attributes - async @@ -505,7 +505,7 @@ namespace XrdCl static XRootDStatus SetXAttr( std::shared_ptr &self, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Get extended attributes - async @@ -522,7 +522,7 @@ namespace XrdCl static XRootDStatus GetXAttr( std::shared_ptr &self, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Delete extended attributes - async @@ -539,7 +539,7 @@ namespace XrdCl static XRootDStatus DelXAttr( std::shared_ptr &self, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! List extended attributes - async @@ -554,7 +554,7 @@ namespace XrdCl //------------------------------------------------------------------------ static XRootDStatus ListXAttr( std::shared_ptr &self, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Create a checkpoint @@ -570,7 +570,7 @@ namespace XrdCl static XRootDStatus Checkpoint( std::shared_ptr &self, kXR_char code, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Checkpointed write - async @@ -588,7 +588,7 @@ namespace XrdCl uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Checkpointed WriteV - async @@ -606,7 +606,7 @@ namespace XrdCl const struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Process the results of the opening operation @@ -709,7 +709,7 @@ namespace XrdCl //! Try other data server //------------------------------------------------------------------------ static XRootDStatus TryOtherServer( std::shared_ptr &self, - uint16_t timeout ); + time_t timeout ); private: //------------------------------------------------------------------------ @@ -741,7 +741,7 @@ namespace XrdCl kXR_char options, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Send a message to a host or put it in the recovery queue @@ -777,7 +777,7 @@ namespace XrdCl // Send a close and ignore the response //------------------------------------------------------------------------ static XRootDStatus SendClose( std::shared_ptr &self, - uint16_t timeout ); + time_t timeout ); //------------------------------------------------------------------------ //! Check if the file is open for read only @@ -789,7 +789,7 @@ namespace XrdCl //------------------------------------------------------------------------ static XRootDStatus ReOpenFileAtServer( std::shared_ptr &self, const URL &url, - uint16_t timeout ); + time_t timeout ); //------------------------------------------------------------------------ //! Fail a message @@ -852,7 +852,7 @@ namespace XrdCl uint32_t length, std::unique_ptr kbuff, ResponseHandler *handler, - uint16_t timeout ); + time_t timeout ); mutable XrdSysMutex pMutex; FileStatus pFileState; diff --git a/src/XrdCl/XrdClFileSystem.cc b/src/XrdCl/XrdClFileSystem.cc index 1d4f10da511..8d48da62b72 100644 --- a/src/XrdCl/XrdClFileSystem.cc +++ b/src/XrdCl/XrdClFileSystem.cc @@ -54,7 +54,7 @@ namespace XrdCl::XRootDStatus Stat( const std::string &path, XrdCl::ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { using namespace XrdCl; @@ -93,7 +93,7 @@ namespace XrdCl::XRootDStatus Rm( const std::string &path, XrdCl::ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { using namespace XrdCl; @@ -1135,7 +1135,7 @@ namespace XrdCl XRootDStatus FileSystem::Locate( const std::string &path, OpenFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Locate( path, flags, handler, timeout ); @@ -1164,7 +1164,7 @@ namespace XrdCl XRootDStatus FileSystem::Locate( const std::string &path, OpenFlags::Flags flags, LocationInfo *&response, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = Locate( path, flags, &handler, timeout ); @@ -1180,7 +1180,7 @@ namespace XrdCl XRootDStatus FileSystem::DeepLocate( const std::string &path, OpenFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { return Locate( path, flags, new DeepLocateHandler( handler, path, flags, timeout ), timeout ); @@ -1192,7 +1192,7 @@ namespace XrdCl XRootDStatus FileSystem::DeepLocate( const std::string &path, OpenFlags::Flags flags, LocationInfo *&response, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = DeepLocate( path, flags, &handler, timeout ); @@ -1208,7 +1208,7 @@ namespace XrdCl XRootDStatus FileSystem::Mv( const std::string &source, const std::string &dest, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Mv( source, dest, handler, timeout ); @@ -1239,7 +1239,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileSystem::Mv( const std::string &source, const std::string &dest, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = Mv( source, dest, &handler, timeout ); @@ -1255,7 +1255,7 @@ namespace XrdCl XRootDStatus FileSystem::Query( QueryCode::Code queryCode, const Buffer &arg, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Query( queryCode, arg, handler, timeout ); @@ -1281,7 +1281,7 @@ namespace XrdCl XRootDStatus FileSystem::Query( QueryCode::Code queryCode, const Buffer &arg, Buffer *&response, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = Query( queryCode, arg, &handler, timeout ); @@ -1297,7 +1297,7 @@ namespace XrdCl XRootDStatus FileSystem::Truncate( const std::string &path, uint64_t size, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Truncate( path, size, handler, timeout ); @@ -1324,7 +1324,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileSystem::Truncate( const std::string &path, uint64_t size, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = Truncate( path, size, &handler, timeout ); @@ -1339,7 +1339,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileSystem::Rm( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Rm( path, handler, timeout ); @@ -1367,7 +1367,7 @@ namespace XrdCl // Remove a file - sync //---------------------------------------------------------------------------- XRootDStatus FileSystem::Rm( const std::string &path, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = Rm( path, &handler, timeout ); @@ -1384,7 +1384,7 @@ namespace XrdCl MkDirFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->MkDir( path, flags, mode, handler, timeout ); @@ -1413,7 +1413,7 @@ namespace XrdCl XRootDStatus FileSystem::MkDir( const std::string &path, MkDirFlags::Flags flags, Access::Mode mode, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = MkDir( path, flags, mode, &handler, timeout ); @@ -1428,7 +1428,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileSystem::RmDir( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->RmDir( path, handler, timeout ); @@ -1453,7 +1453,7 @@ namespace XrdCl // Remove a directory - sync //---------------------------------------------------------------------------- XRootDStatus FileSystem::RmDir( const std::string &path, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = RmDir( path, &handler, timeout ); @@ -1469,7 +1469,7 @@ namespace XrdCl XRootDStatus FileSystem::ChMod( const std::string &path, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->ChMod( path, mode, handler, timeout ); @@ -1496,7 +1496,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileSystem::ChMod( const std::string &path, Access::Mode mode, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = ChMod( path, mode, &handler, timeout ); @@ -1510,7 +1510,7 @@ namespace XrdCl // Check if the server is alive - async //---------------------------------------------------------------------------- XRootDStatus FileSystem::Ping( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Ping( handler, timeout ); @@ -1530,7 +1530,7 @@ namespace XrdCl //---------------------------------------------------------------------------- // Check if the server is alive - sync //---------------------------------------------------------------------------- - XRootDStatus FileSystem::Ping( uint16_t timeout ) + XRootDStatus FileSystem::Ping( time_t timeout ) { SyncResponseHandler handler; Status st = Ping( &handler, timeout ); @@ -1545,7 +1545,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileSystem::Stat( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Stat( path, handler, timeout ); @@ -1575,7 +1575,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileSystem::Stat( const std::string &path, StatInfo *&response, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = Stat( path, &handler, timeout ); @@ -1590,7 +1590,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileSystem::StatVFS( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->StatVFS( path, handler, timeout ); @@ -1617,7 +1617,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileSystem::StatVFS( const std::string &path, StatInfoVFS *&response, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = StatVFS( path, &handler, timeout ); @@ -1631,7 +1631,7 @@ namespace XrdCl // Obtain server protocol information - async //---------------------------------------------------------------------------- XRootDStatus FileSystem::Protocol( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Protocol( handler, timeout ); @@ -1653,7 +1653,7 @@ namespace XrdCl // Obtain server protocol information - sync //---------------------------------------------------------------------------- XRootDStatus FileSystem::Protocol( ProtocolInfo *&response, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = Protocol( &handler, timeout ); @@ -1669,7 +1669,7 @@ namespace XrdCl XRootDStatus FileSystem::DirList( const std::string &path, DirListFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->DirList( path, flags, handler, timeout ); @@ -1723,7 +1723,7 @@ namespace XrdCl XRootDStatus FileSystem::DirList( const std::string &path, DirListFlags::Flags flags, DirectoryList *&response, - uint16_t timeout ) + time_t timeout ) { //-------------------------------------------------------------------------- // Chunked response is only possible for async DirList call @@ -1896,7 +1896,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileSystem::SendCache( const std::string &info, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { // Note: adding SendCache() to the FileSystemPlugin class breaks ABI! // So, the class is missing this until we do a major release. TODO @@ -1910,7 +1910,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileSystem::SendCache( const std::string &info, Buffer *&response, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = SendCache( info, &handler, timeout ); @@ -1925,7 +1925,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileSystem::SendInfo( const std::string &info, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->SendInfo( info, handler, timeout ); @@ -1937,7 +1937,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus FileSystem::SendInfo( const std::string &info, Buffer *&response, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = SendInfo( info, &handler, timeout ); @@ -1953,7 +1953,7 @@ namespace XrdCl XRootDStatus FileSystem::SendSet( const char *prefix, const std::string &info, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { Message *msg; @@ -1979,7 +1979,7 @@ namespace XrdCl PrepareFlags::Flags flags, uint8_t priority, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return pPlugIn->Prepare( fileList, flags, priority, handler, timeout ); @@ -2019,7 +2019,7 @@ namespace XrdCl PrepareFlags::Flags flags, uint8_t priority, Buffer *&response, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; Status st = Prepare( fileList, flags, priority, &handler, timeout ); @@ -2035,7 +2035,7 @@ namespace XrdCl XRootDStatus FileSystem::SetXAttr( const std::string &path, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return XRootDStatus( stError, errNotSupported ); @@ -2049,7 +2049,7 @@ namespace XrdCl XRootDStatus FileSystem::SetXAttr( const std::string &path, const std::vector &attrs, std::vector &result, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = SetXAttr( path, attrs, &handler, timeout ); @@ -2070,7 +2070,7 @@ namespace XrdCl XRootDStatus FileSystem::GetXAttr( const std::string &path, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return XRootDStatus( stError, errNotSupported ); @@ -2084,7 +2084,7 @@ namespace XrdCl XRootDStatus FileSystem::GetXAttr( const std::string &path, const std::vector &attrs, std::vector &result, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = GetXAttr( path, attrs, &handler, timeout ); @@ -2105,7 +2105,7 @@ namespace XrdCl XRootDStatus FileSystem::DelXAttr( const std::string &path, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return XRootDStatus( stError, errNotSupported ); @@ -2119,7 +2119,7 @@ namespace XrdCl XRootDStatus FileSystem::DelXAttr( const std::string &path, const std::vector &attrs, std::vector &result, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = DelXAttr( path, attrs, &handler, timeout ); @@ -2139,7 +2139,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus FileSystem::ListXAttr( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( pPlugIn ) return XRootDStatus( stError, errNotSupported ); @@ -2154,7 +2154,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus FileSystem::ListXAttr( const std::string &path, std::vector &result, - uint16_t timeout ) + time_t timeout ) { SyncResponseHandler handler; XRootDStatus st = ListXAttr( path, &handler, timeout ); @@ -2224,7 +2224,7 @@ namespace XrdCl const std::string &path, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { Message *msg; ClientFattrRequest *req; diff --git a/src/XrdCl/XrdClFileSystem.hh b/src/XrdCl/XrdClFileSystem.hh index 8229a234c10..fa283232546 100644 --- a/src/XrdCl/XrdClFileSystem.hh +++ b/src/XrdCl/XrdClFileSystem.hh @@ -235,7 +235,7 @@ namespace XrdCl XRootDStatus Locate( const std::string &path, OpenFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -251,7 +251,7 @@ namespace XrdCl XRootDStatus Locate( const std::string &path, OpenFlags::Flags flags, LocationInfo *&response, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -269,7 +269,7 @@ namespace XrdCl XRootDStatus DeepLocate( const std::string &path, OpenFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -285,7 +285,7 @@ namespace XrdCl XRootDStatus DeepLocate( const std::string &path, OpenFlags::Flags flags, LocationInfo *&response, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -301,7 +301,7 @@ namespace XrdCl XRootDStatus Mv( const std::string &source, const std::string &dest, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -315,7 +315,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus Mv( const std::string &source, const std::string &dest, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -333,7 +333,7 @@ namespace XrdCl XRootDStatus Query( QueryCode::Code queryCode, const Buffer &arg, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -349,7 +349,7 @@ namespace XrdCl XRootDStatus Query( QueryCode::Code queryCode, const Buffer &arg, Buffer *&response, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -365,7 +365,7 @@ namespace XrdCl XRootDStatus Truncate( const std::string &path, uint64_t size, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -379,7 +379,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus Truncate( const std::string &path, uint64_t size, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -393,7 +393,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus Rm( const std::string &path, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -405,7 +405,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Rm( const std::string &path, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -423,7 +423,7 @@ namespace XrdCl MkDirFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -439,7 +439,7 @@ namespace XrdCl XRootDStatus MkDir( const std::string &path, MkDirFlags::Flags flags, Access::Mode mode, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -453,7 +453,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus RmDir( const std::string &path, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -465,7 +465,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus RmDir( const std::string &path, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -481,7 +481,7 @@ namespace XrdCl XRootDStatus ChMod( const std::string &path, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -495,7 +495,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus ChMod( const std::string &path, Access::Mode mode, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -507,7 +507,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Ping( ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -517,7 +517,7 @@ namespace XrdCl //! be used //! @return status of the operation //------------------------------------------------------------------------ - XRootDStatus Ping( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; + XRootDStatus Ping( time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ //! Obtain status information for a path - async @@ -532,7 +532,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus Stat( const std::string &path, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -547,7 +547,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus Stat( const std::string &path, StatInfo *&response, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -563,7 +563,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus StatVFS( const std::string &path, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -577,7 +577,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus StatVFS( const std::string &path, StatInfoVFS *&response, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -591,7 +591,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Protocol( ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -603,7 +603,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Protocol( ProtocolInfo *&response, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -621,7 +621,7 @@ namespace XrdCl XRootDStatus DirList( const std::string &path, DirListFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -637,7 +637,7 @@ namespace XrdCl XRootDStatus DirList( const std::string &path, DirListFlags::Flags flags, DirectoryList *&response, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -653,7 +653,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus SendCache( const std::string &info, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -667,7 +667,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus SendCache( const std::string &info, Buffer *&response, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -683,7 +683,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus SendInfo( const std::string &info, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -697,7 +697,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus SendInfo( const std::string &info, Buffer *&response, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -717,7 +717,7 @@ namespace XrdCl PrepareFlags::Flags flags, uint8_t priority, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -735,7 +735,7 @@ namespace XrdCl PrepareFlags::Flags flags, uint8_t priority, Buffer *&response, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -753,7 +753,7 @@ namespace XrdCl XRootDStatus SetXAttr( const std::string &path, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Set extended attributes - sync @@ -768,7 +768,7 @@ namespace XrdCl XRootDStatus SetXAttr( const std::string &path, const std::vector &attrs, std::vector &result, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Get extended attributes - async @@ -785,7 +785,7 @@ namespace XrdCl XRootDStatus GetXAttr( const std::string &path, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Get extended attributes - sync @@ -800,7 +800,7 @@ namespace XrdCl XRootDStatus GetXAttr( const std::string &path, const std::vector &attrs, std::vector &result, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Delete extended attributes - async @@ -817,7 +817,7 @@ namespace XrdCl XRootDStatus DelXAttr( const std::string &path, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Delete extended attributes - sync @@ -832,7 +832,7 @@ namespace XrdCl XRootDStatus DelXAttr( const std::string &path, const std::vector &attrs, std::vector &result, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! List extended attributes - async @@ -847,7 +847,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus ListXAttr( const std::string &path, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! List extended attributes - sync @@ -860,7 +860,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus ListXAttr( const std::string &path, std::vector &result, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Set filesystem property @@ -902,7 +902,7 @@ namespace XrdCl XRootDStatus SendSet( const char *prefix, const std::string &info, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) XRD_WARN_UNUSED_RESULT; //------------------------------------------------------------------------ @@ -920,7 +920,7 @@ namespace XrdCl const std::string &path, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); FileSystemImpl *pImpl; //< pointer to implementation (TODO: once we can break ABI we can use a shared pointer here, and then we can drop the FileSystemData in source file) FileSystemPlugIn *pPlugIn; //< file system plug-in diff --git a/src/XrdCl/XrdClFileSystemOperations.hh b/src/XrdCl/XrdClFileSystemOperations.hh index f35dff11b35..85419ce6485 100644 --- a/src/XrdCl/XrdClFileSystemOperations.hh +++ b/src/XrdCl/XrdClFileSystemOperations.hh @@ -124,11 +124,11 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); OpenFlags::Flags flags = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Locate( path, flags, handler, timeout ); } @@ -172,11 +172,11 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); OpenFlags::Flags flags = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->DeepLocate( path, flags, handler, timeout ); } @@ -220,11 +220,11 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &source = std::get( this->args ).Get(); std::string &dest = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Mv( source, dest, handler, timeout ); } @@ -268,11 +268,11 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { QueryCode::Code queryCode = std::get( this->args ).Get(); const Buffer &buffer( std::get( this->args ).Get() ); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Query( queryCode, buffer, handler, timeout ); } @@ -316,11 +316,11 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); uint64_t size = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Truncate( path, size, handler, timeout ); } @@ -367,10 +367,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Rm( path, handler, timeout ); } @@ -414,12 +414,12 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); MkDirFlags::Flags flags = std::get( this->args ).Get(); Access::Mode mode = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->MkDir( path, flags, mode, handler, timeout ); } @@ -462,10 +462,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->RmDir( path, handler, timeout ); } @@ -509,11 +509,11 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); Access::Mode mode = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->ChMod( path, mode, handler, timeout ); } @@ -550,9 +550,9 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Ping( handler, timeout ); } @@ -596,10 +596,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Stat( path, handler, timeout ); } @@ -647,10 +647,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->StatVFS( path, handler, timeout ); } @@ -688,9 +688,9 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Protocol( handler, timeout ); } @@ -734,11 +734,11 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); DirListFlags::Flags flags = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->DirList( path, flags, handler, timeout ); } @@ -782,10 +782,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &info = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->SendInfo( info, handler, timeout ); } @@ -829,12 +829,12 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::vector &fileList = std::get( this->args ).Get(); PrepareFlags::Flags flags = std::get( this->args ).Get(); uint8_t priority = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->Prepare( fileList, flags, priority, handler, timeout ); @@ -879,7 +879,7 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); std::string &name = std::get( this->args ).Get(); @@ -889,7 +889,7 @@ namespace XrdCl attrs.push_back( xattr_t( name, value ) ); // wrap the PipelineHandler so the response gets unpacked properly UnpackXAttrStatus *h = new UnpackXAttrStatus( handler ); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; XRootDStatus st = this->filesystem->SetXAttr( path, attrs, h, timeout ); if( !st.IsOK() ) delete h; @@ -944,11 +944,11 @@ namespace XrdCl //! //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); std::vector &attrs = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->SetXAttr( path, attrs, handler, timeout ); } @@ -999,7 +999,7 @@ namespace XrdCl //! //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); std::string &name = std::get( this->args ).Get(); @@ -1008,7 +1008,7 @@ namespace XrdCl attrs.push_back( name ); // wrap the PipelineHandler so the response gets unpacked properly UnpackXAttr *h = new UnpackXAttr( handler ); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; XRootDStatus st = this->filesystem->GetXAttr( path, attrs, h, timeout ); if( !st.IsOK() ) delete h; @@ -1062,11 +1062,11 @@ namespace XrdCl //! //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); std::vector &attrs = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->GetXAttr( path, attrs, handler, timeout ); } @@ -1119,7 +1119,7 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); std::string &name = std::get( this->args ).Get(); @@ -1128,7 +1128,7 @@ namespace XrdCl attrs.push_back( name ); // wrap the PipelineHandler so the response gets unpacked properly UnpackXAttrStatus *h = new UnpackXAttrStatus( handler ); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; XRootDStatus st = this->filesystem->DelXAttr( path, attrs, h, timeout ); if( !st.IsOK() ) delete h; @@ -1184,11 +1184,11 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); std::vector &attrs = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->DelXAttr( path, attrs, handler, timeout ); } @@ -1241,10 +1241,10 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &path = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->filesystem->ListXAttr( path, handler, timeout ); } diff --git a/src/XrdCl/XrdClLocalFileHandler.cc b/src/XrdCl/XrdClLocalFileHandler.cc index b96f8aaafd9..f14afd09a30 100644 --- a/src/XrdCl/XrdClLocalFileHandler.cc +++ b/src/XrdCl/XrdClLocalFileHandler.cc @@ -240,7 +240,7 @@ namespace XrdCl // Open //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::Open( const std::string& url, uint16_t flags, - uint16_t mode, ResponseHandler* handler, uint16_t timeout ) + uint16_t mode, ResponseHandler* handler, time_t timeout ) { AnyObject *resp = 0; XRootDStatus st = OpenImpl( url, flags, mode, resp ); @@ -263,7 +263,7 @@ namespace XrdCl // Close //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::Close( ResponseHandler* handler, - uint16_t timeout ) + time_t timeout ) { if( close( fd ) == -1 ) { @@ -280,7 +280,7 @@ namespace XrdCl // Stat //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::Stat( ResponseHandler* handler, - uint16_t timeout ) + time_t timeout ) { Log *log = DefaultEnv::GetLog(); @@ -314,7 +314,7 @@ namespace XrdCl // Read //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::Read( uint64_t offset, uint32_t size, - void* buffer, ResponseHandler* handler, uint16_t timeout ) + void* buffer, ResponseHandler* handler, time_t timeout ) { #if defined(__APPLE__) Log *log = DefaultEnv::GetLog(); @@ -354,7 +354,7 @@ namespace XrdCl struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { Log *log = DefaultEnv::GetLog(); #if defined(__APPLE__) @@ -391,7 +391,7 @@ namespace XrdCl // Write //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::Write( uint64_t offset, uint32_t size, - const void* buffer, ResponseHandler* handler, uint16_t timeout ) + const void* buffer, ResponseHandler* handler, time_t timeout ) { #if defined(__APPLE__) const char *buff = reinterpret_cast( buffer ); @@ -432,7 +432,7 @@ namespace XrdCl // Sync //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::Sync( ResponseHandler* handler, - uint16_t timeout ) + time_t timeout ) { #if defined(__APPLE__) if( fsync( fd ) ) @@ -463,7 +463,7 @@ namespace XrdCl // Truncate //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::Truncate( uint64_t size, - ResponseHandler* handler, uint16_t timeout ) + ResponseHandler* handler, time_t timeout ) { if( ftruncate( fd, size ) ) { @@ -481,7 +481,7 @@ namespace XrdCl // VectorRead //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::VectorRead( const ChunkList& chunks, - void* buffer, ResponseHandler* handler, uint16_t timeout ) + void* buffer, ResponseHandler* handler, time_t timeout ) { std::unique_ptr info( new VectorReadInfo() ); size_t totalSize = 0; @@ -518,7 +518,7 @@ namespace XrdCl // VectorWrite //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::VectorWrite( const ChunkList &chunks, - ResponseHandler *handler, uint16_t timeout ) + ResponseHandler *handler, time_t timeout ) { for( auto itr = chunks.begin(); itr != chunks.end(); ++itr ) @@ -545,7 +545,7 @@ namespace XrdCl XRootDStatus LocalFileHandler::WriteV( uint64_t offset, ChunkList *chunks, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { size_t iovcnt = chunks->size(); iovec iovcp[iovcnt]; @@ -601,7 +601,7 @@ namespace XrdCl // Fcntl //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::Fcntl( const Buffer &arg, - ResponseHandler *handler, uint16_t timeout ) + ResponseHandler *handler, time_t timeout ) { return XRootDStatus( stError, errNotSupported ); } @@ -610,7 +610,7 @@ namespace XrdCl // Visa //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::Visa( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { return XRootDStatus( stError, errNotSupported ); } @@ -620,7 +620,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::SetXAttr( const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysXAttr *xattr = XrdSysFAttr::Xat; std::vector response; @@ -648,7 +648,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::GetXAttr( const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysXAttr *xattr = XrdSysFAttr::Xat; std::vector response; @@ -691,7 +691,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::DelXAttr( const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysXAttr *xattr = XrdSysFAttr::Xat; std::vector response; @@ -717,7 +717,7 @@ namespace XrdCl // List extended attributes - async //------------------------------------------------------------------------ XRootDStatus LocalFileHandler::ListXAttr( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdSysXAttr *xattr = XrdSysFAttr::Xat; std::vector response; diff --git a/src/XrdCl/XrdClLocalFileHandler.hh b/src/XrdCl/XrdClLocalFileHandler.hh index 2fc03568666..e2af3f0da8c 100644 --- a/src/XrdCl/XrdClLocalFileHandler.hh +++ b/src/XrdCl/XrdClLocalFileHandler.hh @@ -49,7 +49,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Open( const std::string &url, uint16_t flags, uint16_t mode, - ResponseHandler *handler, uint16_t timeout = 0 ); + ResponseHandler *handler, time_t timeout = 0 ); //------------------------------------------------------------------------ //! Handle local redirect to given URL triggered by the given request @@ -64,7 +64,7 @@ namespace XrdCl //! used //! @return status of the operation //------------------------------------------------------------------------ - XRootDStatus Close( ResponseHandler *handler, uint16_t timeout = 0 ); + XRootDStatus Close( ResponseHandler *handler, time_t timeout = 0 ); //------------------------------------------------------------------------ //! Obtain status information for this file - async @@ -76,7 +76,7 @@ namespace XrdCl //! be used //! @return status of the operation //------------------------------------------------------------------------ - XRootDStatus Stat( ResponseHandler *handler, uint16_t timeout = 0 ); + XRootDStatus Stat( ResponseHandler *handler, time_t timeout = 0 ); //------------------------------------------------------------------------ //! Read a data chunk at a given offset - sync @@ -95,7 +95,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Read( uint64_t offset, uint32_t size, void *buffer, - ResponseHandler *handler, uint16_t timeout = 0 ); + ResponseHandler *handler, time_t timeout = 0 ); //------------------------------------------------------------------------ //! Read data into scattered buffers in one operation - async @@ -112,7 +112,7 @@ namespace XrdCl struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write a data chunk at a given offset - async @@ -126,7 +126,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Write( uint64_t offset, uint32_t size, const void *buffer, - ResponseHandler *handler, uint16_t timeout = 0 ); + ResponseHandler *handler, time_t timeout = 0 ); //------------------------------------------------------------------------ //! Commit all pending disk writes - async @@ -136,7 +136,7 @@ namespace XrdCl //! used //! @return status of the operation //------------------------------------------------------------------------ - XRootDStatus Sync( ResponseHandler *handler, uint16_t timeout = 0 ); + XRootDStatus Sync( ResponseHandler *handler, time_t timeout = 0 ); //------------------------------------------------------------------------ //! Truncate the file to a particular size - async @@ -148,7 +148,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Truncate( uint64_t size, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Read scattered data chunks in one operation - async @@ -161,7 +161,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus VectorRead( const ChunkList &chunks, void *buffer, - ResponseHandler *handler, uint16_t timeout = 0 ); + ResponseHandler *handler, time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write scattered data chunks in one operation - async @@ -173,7 +173,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus VectorWrite( const ChunkList &chunks, - ResponseHandler *handler, uint16_t timeout = 0 ); + ResponseHandler *handler, time_t timeout = 0 ); //------------------------------------------------------------------------ //! Write scattered buffers in one operation - async @@ -188,7 +188,7 @@ namespace XrdCl XRootDStatus WriteV( uint64_t offset, ChunkList *chunks, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Queues a task to the jobmanager @@ -213,7 +213,7 @@ namespace XrdCl //! @return status of the operation //------------------------------------------------------------------------ XRootDStatus Fcntl( const Buffer &arg, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Get access token to a file - async @@ -225,7 +225,7 @@ namespace XrdCl //! be used //! @return status of the operation //------------------------------------------------------------------------ - XRootDStatus Visa( ResponseHandler *handler, uint16_t timeout = 0 ); + XRootDStatus Visa( ResponseHandler *handler, time_t timeout = 0 ); //------------------------------------------------------------------------ @@ -242,7 +242,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus SetXAttr( const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Get extended attributes - async @@ -258,7 +258,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus GetXAttr( const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Delete extended attributes - async @@ -274,7 +274,7 @@ namespace XrdCl //------------------------------------------------------------------------ XRootDStatus DelXAttr( const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! List extended attributes - async @@ -288,7 +288,7 @@ namespace XrdCl //! @return : status of the operation //------------------------------------------------------------------------ XRootDStatus ListXAttr( ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! creates the directories specified in path diff --git a/src/XrdCl/XrdClMessageUtils.hh b/src/XrdCl/XrdClMessageUtils.hh index ac12dd6fef4..a3133f7e011 100644 --- a/src/XrdCl/XrdClMessageUtils.hh +++ b/src/XrdCl/XrdClMessageUtils.hh @@ -133,7 +133,7 @@ namespace XrdCl MessageSendParams(): timeout(0), expires(0), followRedirects(true), chunkedResponse(false), stateful(true), hostList(0), chunkList(0), redirectLimit(0), kbuff(0){} - uint16_t timeout; + time_t timeout; time_t expires; HostInfo loadBalancer; bool followRedirects; diff --git a/src/XrdCl/XrdClOperationTimeout.hh b/src/XrdCl/XrdClOperationTimeout.hh index e658085c673..6b560a01664 100644 --- a/src/XrdCl/XrdClOperationTimeout.hh +++ b/src/XrdCl/XrdClOperationTimeout.hh @@ -24,7 +24,7 @@ namespace XrdCl { } - Timeout( uint16_t timeout ): timeout( timeout ), start( time( 0 ) ) + Timeout( time_t timeout ): timeout( timeout ), start( time( 0 ) ) { } @@ -39,7 +39,7 @@ namespace XrdCl { } - operator uint16_t() const + operator time_t() const { if( !timeout ) return 0; time_t elapsed = time( 0 ) - start; @@ -49,7 +49,7 @@ namespace XrdCl private: - uint16_t timeout; + time_t timeout; time_t start; }; diff --git a/src/XrdCl/XrdClOperations.hh b/src/XrdCl/XrdClOperations.hh index 19bc0a40037..eb6ac3f655d 100644 --- a/src/XrdCl/XrdClOperations.hh +++ b/src/XrdCl/XrdClOperations.hh @@ -63,7 +63,7 @@ namespace XrdCl template friend class Operation; - friend std::future Async( Pipeline, uint16_t ); + friend std::future Async( Pipeline, time_t ); friend class Pipeline; friend class PipelineHandler; @@ -135,7 +135,7 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - virtual XRootDStatus RunImpl( PipelineHandler *handler, uint16_t timeout ) = 0; + virtual XRootDStatus RunImpl( PipelineHandler *handler, time_t timeout ) = 0; //------------------------------------------------------------------------ //! Add next operation in the pipeline @@ -148,7 +148,7 @@ namespace XrdCl //! Operation handler //------------------------------------------------------------------------ std::unique_ptr handler; -; + //------------------------------------------------------------------------ //! Flag indicating if it is a valid object //------------------------------------------------------------------------ @@ -290,7 +290,7 @@ namespace XrdCl class Pipeline { template friend class ParallelOperation; - friend std::future Async( Pipeline, uint16_t ); + friend std::future Async( Pipeline, time_t ); friend class PipelineHandler; public: @@ -485,7 +485,7 @@ namespace XrdCl //! //! @return : future status of the operation //---------------------------------------------------------------------------- - inline std::future Async( Pipeline pipeline, uint16_t timeout = 0 ) + inline std::future Async( Pipeline pipeline, time_t timeout = 0 ) { pipeline.Run( timeout ); return std::move( pipeline.ftr ); @@ -500,7 +500,7 @@ namespace XrdCl //! //! @return : status of the operation //---------------------------------------------------------------------------- - inline XRootDStatus WaitFor( Pipeline pipeline, uint16_t timeout = 0 ) + inline XRootDStatus WaitFor( Pipeline pipeline, time_t timeout = 0 ) { return Async( std::move( pipeline ), timeout ).get(); } @@ -644,7 +644,7 @@ namespace XrdCl //------------------------------------------------------------------------ //! Set operation timeout //------------------------------------------------------------------------ - Derived Timeout( uint16_t timeout ) + Derived Timeout( time_t timeout ) { this->timeout = timeout; Derived *me = static_cast*>( this ); @@ -739,7 +739,7 @@ namespace XrdCl //------------------------------------------------------------------------ //! Operation timeout //------------------------------------------------------------------------ - uint16_t timeout; + time_t timeout; }; // Out-of-line methods for class Operation diff --git a/src/XrdCl/XrdClParallelOperation.hh b/src/XrdCl/XrdClParallelOperation.hh index dd38c56d46b..5528c43ca4c 100644 --- a/src/XrdCl/XrdClParallelOperation.hh +++ b/src/XrdCl/XrdClParallelOperation.hh @@ -473,7 +473,7 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { // make sure we have a valid policy for the parallel operation if( !policy ) policy.reset( new AllPolicy() ); @@ -481,7 +481,7 @@ namespace XrdCl std::shared_ptr ctx = std::make_shared( handler, policy.release() ); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; for( size_t i = 0; i < pipelines.size(); ++i ) diff --git a/src/XrdCl/XrdClPlugInInterface.hh b/src/XrdCl/XrdClPlugInInterface.hh index 03881461bcf..3efee70035b 100644 --- a/src/XrdCl/XrdClPlugInInterface.hh +++ b/src/XrdCl/XrdClPlugInInterface.hh @@ -49,7 +49,7 @@ namespace XrdCl OpenFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)url; (void)flags; (void)mode; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -59,7 +59,7 @@ namespace XrdCl //! @see XrdCl::File::Close //------------------------------------------------------------------------ virtual XRootDStatus Close( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -70,7 +70,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual XRootDStatus Stat( bool force, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)force; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -83,7 +83,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)offset; (void)size; (void)buffer; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -97,7 +97,7 @@ namespace XrdCl Optional fdoff, int fd, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { (void)offset; (void)size; (void)fdoff; (void)fd, (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -110,7 +110,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)offset; (void)size; (void)buffer; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -123,7 +123,7 @@ namespace XrdCl uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)offset; (void)size; (void)buffer; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -135,7 +135,7 @@ namespace XrdCl virtual XRootDStatus Write( uint64_t offset, Buffer &&buffer, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { (void)offset; (void)buffer; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -149,7 +149,7 @@ namespace XrdCl Optional fdoff, int fd, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { (void)offset; (void)size; (void)fdoff; (void)fd, (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -163,7 +163,7 @@ namespace XrdCl const void *buffer, std::vector &cksums, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)offset; (void)nbpgs; (void)buffer; (void)cksums, (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -173,7 +173,7 @@ namespace XrdCl //! @see XrdCl::File::Sync //------------------------------------------------------------------------ virtual XRootDStatus Sync( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -184,7 +184,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual XRootDStatus Truncate( uint64_t size, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)size; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -196,7 +196,7 @@ namespace XrdCl virtual XRootDStatus VectorRead( const ChunkList &chunks, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)chunks; (void)buffer; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -207,7 +207,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual XRootDStatus VectorWrite( const ChunkList &chunks, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { (void)chunks; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -221,7 +221,7 @@ namespace XrdCl const struct iovec *iov, int iovcnt, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { (void)offset; (void)iov; (void)iovcnt; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -232,7 +232,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual XRootDStatus Fcntl( const Buffer &arg, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)arg; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -242,7 +242,7 @@ namespace XrdCl //! @see XrdCl::File::Visa //------------------------------------------------------------------------ virtual XRootDStatus Visa( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -294,7 +294,7 @@ namespace XrdCl virtual XRootDStatus Locate( const std::string &path, OpenFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)flags; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -306,7 +306,7 @@ namespace XrdCl virtual XRootDStatus DeepLocate( const std::string &path, OpenFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)flags; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -318,7 +318,7 @@ namespace XrdCl virtual XRootDStatus Mv( const std::string &source, const std::string &dest, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)source; (void)dest; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -330,7 +330,7 @@ namespace XrdCl virtual XRootDStatus Query( QueryCode::Code queryCode, const Buffer &arg, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)queryCode; (void)arg; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -342,7 +342,7 @@ namespace XrdCl virtual XRootDStatus Truncate( const std::string &path, uint64_t size, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)size; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -353,7 +353,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual XRootDStatus Rm( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -366,7 +366,7 @@ namespace XrdCl MkDirFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)flags; (void)mode; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -377,7 +377,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual XRootDStatus RmDir( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -389,7 +389,7 @@ namespace XrdCl virtual XRootDStatus ChMod( const std::string &path, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)mode; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -399,7 +399,7 @@ namespace XrdCl //! @see XrdCl::FileSystem::Ping //------------------------------------------------------------------------ virtual XRootDStatus Ping( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -410,7 +410,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual XRootDStatus Stat( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -421,7 +421,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual XRootDStatus StatVFS( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -431,7 +431,7 @@ namespace XrdCl //! @see XrdCl::FileSystem::Protocol //------------------------------------------------------------------------ virtual XRootDStatus Protocol( ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -443,7 +443,7 @@ namespace XrdCl virtual XRootDStatus DirList( const std::string &path, DirListFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)flags; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -454,7 +454,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual XRootDStatus SendInfo( const std::string &info, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)info; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -467,7 +467,7 @@ namespace XrdCl PrepareFlags::Flags flags, uint8_t priority, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)fileList; (void)flags; (void)priority; (void)handler; (void)timeout; @@ -480,7 +480,7 @@ namespace XrdCl virtual XRootDStatus SetXAttr( const std::string &path, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)attrs; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -492,7 +492,7 @@ namespace XrdCl virtual XRootDStatus GetXAttr( const std::string &path, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)attrs; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -504,7 +504,7 @@ namespace XrdCl virtual XRootDStatus DelXAttr( const std::string &path, const std::vector &attrs, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)attrs; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); @@ -515,7 +515,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual XRootDStatus ListXAttr( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)path; (void)handler; (void)timeout; return XRootDStatus( stError, errNotImplemented ); diff --git a/src/XrdCl/XrdClPoller.hh b/src/XrdCl/XrdClPoller.hh index d8408c4c98c..82dec4202fd 100644 --- a/src/XrdCl/XrdClPoller.hh +++ b/src/XrdCl/XrdClPoller.hh @@ -20,6 +20,7 @@ #define __XRD_CL_POLLER_HH__ #include +#include #include namespace XrdCl @@ -135,7 +136,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual bool EnableReadNotification( Socket *socket, bool notify, - uint16_t timeout = 60 ) = 0; + time_t timeout = 60 ) = 0; //------------------------------------------------------------------------ //! Notify the handler about write events @@ -146,7 +147,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual bool EnableWriteNotification( Socket *socket, bool notify, - uint16_t timeout = 60 ) = 0; + time_t timeout = 60 ) = 0; //------------------------------------------------------------------------ //! Check whether the socket is registered with the poller diff --git a/src/XrdCl/XrdClPollerBuiltIn.cc b/src/XrdCl/XrdClPollerBuiltIn.cc index 2e8a263180a..80e53668602 100644 --- a/src/XrdCl/XrdClPollerBuiltIn.cc +++ b/src/XrdCl/XrdClPollerBuiltIn.cc @@ -46,8 +46,8 @@ namespace XrdSys::IOEvents::CallBack *callBack; bool readEnabled; bool writeEnabled; - uint16_t readTimeout; - uint16_t writeTimeout; + time_t readTimeout; + time_t writeTimeout; }; //---------------------------------------------------------------------------- @@ -361,7 +361,7 @@ namespace XrdCl //---------------------------------------------------------------------------- bool PollerBuiltIn::EnableReadNotification( Socket *socket, bool notify, - uint16_t timeout ) + time_t timeout ) { using namespace XrdSys::IOEvents; Log *log = DefaultEnv::GetLog(); @@ -396,8 +396,8 @@ namespace XrdCl return true; helper->readTimeout = timeout; - log->Dump( PollerMsg, "%s Enable read notifications, timeout: %d", - socket->GetName().c_str(), timeout ); + log->Dump( PollerMsg, "%s Enable read notifications, timeout: %lld", + socket->GetName().c_str(), (long long)timeout ); if( poller ) { @@ -446,7 +446,7 @@ namespace XrdCl //---------------------------------------------------------------------------- bool PollerBuiltIn::EnableWriteNotification( Socket *socket, bool notify, - uint16_t timeout ) + time_t timeout ) { using namespace XrdSys::IOEvents; Log *log = DefaultEnv::GetLog(); @@ -482,8 +482,8 @@ namespace XrdCl helper->writeTimeout = timeout; - log->Dump( PollerMsg, "%s Enable write notifications, timeout: %d", - socket->GetName().c_str(), timeout ); + log->Dump( PollerMsg, "%s Enable write notifications, timeout: %lld", + socket->GetName().c_str(), (long long)timeout ); if( poller ) { diff --git a/src/XrdCl/XrdClPollerBuiltIn.hh b/src/XrdCl/XrdClPollerBuiltIn.hh index 6d38d59caca..80ba6e1ee4d 100644 --- a/src/XrdCl/XrdClPollerBuiltIn.hh +++ b/src/XrdCl/XrdClPollerBuiltIn.hh @@ -92,7 +92,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual bool EnableReadNotification( Socket *socket, bool notify, - uint16_t timeout = 60 ); + time_t timeout = 60 ); //------------------------------------------------------------------------ //! Notify the handler about write events @@ -104,7 +104,7 @@ namespace XrdCl //------------------------------------------------------------------------ virtual bool EnableWriteNotification( Socket *socket, bool notify, - uint16_t timeout = 60); + time_t timeout = 60); //------------------------------------------------------------------------ //! Check whether the socket is registered with the poller diff --git a/src/XrdCl/XrdClSocket.cc b/src/XrdCl/XrdClSocket.cc index 46b44ea513a..6a08d2a72ea 100644 --- a/src/XrdCl/XrdClSocket.cc +++ b/src/XrdCl/XrdClSocket.cc @@ -182,7 +182,7 @@ namespace XrdCl //---------------------------------------------------------------------------- XRootDStatus Socket::Connect( const std::string &host, uint16_t port, - uint16_t timeout ) + time_t timeout ) { if( pSocket == -1 || pStatus == Connected || pStatus == Connecting ) return XRootDStatus( stError, errInvalidOp ); @@ -210,7 +210,7 @@ namespace XrdCl // Connect to the given host //---------------------------------------------------------------------------- XRootDStatus Socket::ConnectToAddress( const XrdNetAddr &addr, - uint16_t timeout ) + time_t timeout ) { if( pSocket == -1 || pStatus == Connected || pStatus == Connecting ) return XRootDStatus( stError, errInvalidOp ); diff --git a/src/XrdCl/XrdClSocket.hh b/src/XrdCl/XrdClSocket.hh index efe96aca1ea..1822a124576 100644 --- a/src/XrdCl/XrdClSocket.hh +++ b/src/XrdCl/XrdClSocket.hh @@ -97,22 +97,22 @@ namespace XrdCl //! //! @param host name of the host to connect to //! @param port port to connect to - //! @param timout timeout in seconds, 0 for no timeout handling (may be + //! @param timeout timeout in seconds, 0 for no timeout handling (may be //! used for non blocking IO) //------------------------------------------------------------------------ XRootDStatus Connect( const std::string &host, uint16_t port, - uint16_t timout = 10 ); + time_t timeout = 10 ); //------------------------------------------------------------------------ //! Connect to the given host address //! //! @param addr address of the host to connect to - //! @param timout timeout in seconds, 0 for no timeout handling (may be + //! @param timeout timeout in seconds, 0 for no timeout handling (may be //! used for non blocking IO) //------------------------------------------------------------------------ XRootDStatus ConnectToAddress( const XrdNetAddr &addr, - uint16_t timout = 10 ); + time_t timeout = 10 ); //------------------------------------------------------------------------ //! Disconnect @@ -140,7 +140,7 @@ namespace XrdCl //! //! @param buffer data to be sent //! @param size size of the data buffer - //! @param timeout timout value in seconds, -1 to wait indefinitely + //! @param timeout timeout value in seconds, -1 to wait indefinitely //! @param bytesRead the amount of data actually read //------------------------------------------------------------------------ XRootDStatus ReadRaw( void *buffer, uint32_t size, int32_t timeout, diff --git a/src/XrdCl/XrdClTPFallBackCopyJob.cc b/src/XrdCl/XrdClTPFallBackCopyJob.cc index 7073c64e9fc..762134692a9 100644 --- a/src/XrdCl/XrdClTPFallBackCopyJob.cc +++ b/src/XrdCl/XrdClTPFallBackCopyJob.cc @@ -35,7 +35,7 @@ namespace XrdCl //---------------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------------- - TPFallBackCopyJob::TPFallBackCopyJob( uint16_t jobId, + TPFallBackCopyJob::TPFallBackCopyJob( uint32_t jobId, PropertyList *jobProperties, PropertyList *jobResults ): CopyJob( jobId, jobProperties, jobResults ), diff --git a/src/XrdCl/XrdClTPFallBackCopyJob.hh b/src/XrdCl/XrdClTPFallBackCopyJob.hh index d711ee936e1..4fa8320d591 100644 --- a/src/XrdCl/XrdClTPFallBackCopyJob.hh +++ b/src/XrdCl/XrdClTPFallBackCopyJob.hh @@ -36,7 +36,7 @@ namespace XrdCl //------------------------------------------------------------------------ //! Constructor //------------------------------------------------------------------------ - TPFallBackCopyJob( uint16_t jobId, + TPFallBackCopyJob( uint32_t jobId, PropertyList *jobProperties, PropertyList *jobResults ); diff --git a/src/XrdCl/XrdClThirdPartyCopyJob.cc b/src/XrdCl/XrdClThirdPartyCopyJob.cc index 25d27bb68e5..23bead0fb15 100644 --- a/src/XrdCl/XrdClThirdPartyCopyJob.cc +++ b/src/XrdCl/XrdClThirdPartyCopyJob.cc @@ -110,7 +110,7 @@ namespace { public: - InitTimeoutCalc( uint16_t timeLeft ) : + InitTimeoutCalc( time_t timeLeft ) : hasInitTimeout( timeLeft ), start( time( 0 ) ), timeLeft( timeLeft ) { @@ -128,7 +128,7 @@ namespace return XrdCl::XRootDStatus(); } - operator uint16_t() + operator time_t() { return timeLeft; } @@ -136,7 +136,7 @@ namespace private: bool hasInitTimeout; time_t start; - uint16_t timeLeft; + time_t timeLeft; }; static XrdCl::XRootDStatus& UpdateErrMsg( XrdCl::XRootDStatus &status, const std::string &str ) @@ -153,7 +153,7 @@ namespace XrdCl //---------------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------------- - ThirdPartyCopyJob::ThirdPartyCopyJob( uint16_t jobId, + ThirdPartyCopyJob::ThirdPartyCopyJob( uint32_t jobId, PropertyList *jobProperties, PropertyList *jobResults ): CopyJob( jobId, jobProperties, jobResults ), @@ -624,7 +624,7 @@ namespace XrdCl } } - initTimeout = uint16_t( timeLeft ); + initTimeout = time_t( timeLeft ); return XRootDStatus(); } @@ -709,7 +709,7 @@ namespace XrdCl XrdSysSemaphore *sem = statusHandler.GetXrdSysSemaphore(); StatInfo *info = 0; - uint16_t tpcTimeout = 0; + time_t tpcTimeout = 0; pProperties->Get( "tpcTimeout", tpcTimeout ); st = dstFile.Sync( &statusHandler, tpcTimeout ); @@ -828,7 +828,7 @@ namespace XrdCl XrdSysSemaphore *sem = statusHandler.GetXrdSysSemaphore(); StatInfo *info = 0; - uint16_t tpcTimeout = 0; + time_t tpcTimeout = 0; pProperties->Get( "tpcTimeout", tpcTimeout ); st = dstFile.Sync( &statusHandler, tpcTimeout ); diff --git a/src/XrdCl/XrdClThirdPartyCopyJob.hh b/src/XrdCl/XrdClThirdPartyCopyJob.hh index f40b57f42d6..7cf06531162 100644 --- a/src/XrdCl/XrdClThirdPartyCopyJob.hh +++ b/src/XrdCl/XrdClThirdPartyCopyJob.hh @@ -33,7 +33,7 @@ namespace XrdCl //------------------------------------------------------------------------ //! Constructor //------------------------------------------------------------------------ - ThirdPartyCopyJob( uint16_t jobId, + ThirdPartyCopyJob( uint32_t jobId, PropertyList *jobProperties, PropertyList *jobResults ); @@ -81,7 +81,7 @@ namespace XrdCl std::string checkSumType; std::string checkSumPreset; uint64_t sourceSize; - uint16_t initTimeout; + time_t initTimeout; bool force; bool coerce; bool delegate; diff --git a/src/XrdCl/XrdClUtils.cc b/src/XrdCl/XrdClUtils.cc index 102a92f7724..07577325af8 100644 --- a/src/XrdCl/XrdClUtils.cc +++ b/src/XrdCl/XrdClUtils.cc @@ -379,7 +379,7 @@ namespace XrdCl //---------------------------------------------------------------------------- // Check if peer supports tpc //---------------------------------------------------------------------------- - XRootDStatus Utils::CheckTPC( const std::string &server, uint16_t timeout ) + XRootDStatus Utils::CheckTPC( const std::string &server, time_t timeout ) { Log *log = DefaultEnv::GetLog(); log->Debug( UtilityMsg, "Checking if the data server %s supports tpc", @@ -423,7 +423,7 @@ namespace XrdCl //------------------------------------------------------------------------ // Check if peer supports tpc / tpc lite //------------------------------------------------------------------------ - XRootDStatus Utils::CheckTPCLite( const std::string &server, uint16_t timeout ) + XRootDStatus Utils::CheckTPCLite( const std::string &server, time_t timeout ) { Log *log = DefaultEnv::GetLog(); log->Debug( UtilityMsg, "Checking if the data server %s supports tpc / tpc lite", diff --git a/src/XrdCl/XrdClUtils.hh b/src/XrdCl/XrdClUtils.hh index adf557be204..cb22d6da68d 100644 --- a/src/XrdCl/XrdClUtils.hh +++ b/src/XrdCl/XrdClUtils.hh @@ -145,7 +145,7 @@ namespace XrdCl //! Check if peer supports tpc //------------------------------------------------------------------------ static XRootDStatus CheckTPC( const std::string &server, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Check if peer supports tpc / tpc lite @@ -154,7 +154,7 @@ namespace XrdCl //! supported, stError otherwise //------------------------------------------------------------------------ static XRootDStatus CheckTPCLite( const std::string &server, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //------------------------------------------------------------------------ //! Convert the fully qualified host name to country code diff --git a/src/XrdCl/XrdClZipArchive.cc b/src/XrdCl/XrdClZipArchive.cc index 36b67ee3f23..715ea1bed45 100644 --- a/src/XrdCl/XrdClZipArchive.cc +++ b/src/XrdCl/XrdClZipArchive.cc @@ -47,7 +47,7 @@ namespace XrdCl uint32_t size, void *usrbuff, ResponseHandler *usrHandler, - uint16_t timeout ) + time_t timeout ) { if( me.openstage != ZipArchive::Done || !me.archive.IsOpen() ) return XRootDStatus( stError, errInvalidOp ); @@ -231,7 +231,7 @@ namespace XrdCl XRootDStatus ZipArchive::OpenOnly( const std::string &url, bool update, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { OpenFlags::Flags flags = update ? OpenFlags::Update : OpenFlags::Read; Pipeline open_only = XrdCl::Open( archive, url, flags ) >> @@ -266,7 +266,7 @@ namespace XrdCl XRootDStatus ZipArchive::OpenArchive( const std::string &url, OpenFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { Log *log = DefaultEnv::GetLog(); Fwd rdsize; // number of bytes to be read @@ -602,7 +602,7 @@ namespace XrdCl // Create the central directory at the end of ZIP archive and close it //--------------------------------------------------------------------------- XRootDStatus ZipArchive::CloseArchive( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { Log *log = DefaultEnv::GetLog(); @@ -696,7 +696,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { return ReadFromImpl( *this, fn, offset, size, buffer, handler, timeout ); } @@ -709,7 +709,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { return ReadFromImpl( *this, fn, offset, size, buffer, handler, timeout ); } @@ -756,7 +756,7 @@ namespace XrdCl XRootDStatus ZipArchive::WriteImpl( uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { Log *log = DefaultEnv::GetLog(); std::vector iov( 2 ); @@ -879,7 +879,7 @@ namespace XrdCl uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { Log *log = DefaultEnv::GetLog(); auto itr = cdmap.find( fn ); diff --git a/src/XrdCl/XrdClZipArchive.hh b/src/XrdCl/XrdClZipArchive.hh index 5c1acdb7625..74f889254a9 100644 --- a/src/XrdCl/XrdClZipArchive.hh +++ b/src/XrdCl/XrdClZipArchive.hh @@ -67,7 +67,7 @@ namespace XrdCl friend class ::XrdEcTests; template - friend XRootDStatus ReadFromImpl( ZipArchive&, const std::string&, uint64_t, uint32_t, void*, ResponseHandler*, uint16_t ); + friend XRootDStatus ReadFromImpl( ZipArchive&, const std::string&, uint64_t, uint32_t, void*, ResponseHandler*, time_t ); public: //----------------------------------------------------------------------- @@ -92,7 +92,7 @@ namespace XrdCl XRootDStatus OpenArchive( const std::string &url, OpenFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //----------------------------------------------------------------------- //! Open a file within the ZIP Archive @@ -123,7 +123,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { if( openfn.empty() ) return XRootDStatus( stError, errInvalidOp ); return ReadFrom( openfn, offset, size, buffer, handler, timeout ); @@ -144,7 +144,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { if( openfn.empty() ) return XRootDStatus( stError, errInvalidOp ); return PgReadFrom( openfn, offset, size, buffer, handler, timeout ); @@ -166,7 +166,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //----------------------------------------------------------------------- //! PgRead data from a given file @@ -184,7 +184,7 @@ namespace XrdCl uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //----------------------------------------------------------------------- //! Append data to a new file @@ -198,7 +198,7 @@ namespace XrdCl inline XRootDStatus Write( uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { if( openstage != Done || openfn.empty() ) return XRootDStatus( stError, errInvalidOp, 0, "Archive not opened." ); @@ -230,7 +230,7 @@ namespace XrdCl uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //----------------------------------------------------------------------- //! Get stat info for given file @@ -330,7 +330,7 @@ namespace XrdCl //! @return : the status of the operation //----------------------------------------------------------------------- XRootDStatus CloseArchive( ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //----------------------------------------------------------------------- //! Close an open file within the ZIP archive @@ -406,7 +406,7 @@ namespace XrdCl XRootDStatus WriteImpl( uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout ); + time_t timeout ); //----------------------------------------------------------------------- //! Open the ZIP archive in read-only mode without parsing the central @@ -420,7 +420,7 @@ namespace XrdCl XRootDStatus OpenOnly( const std::string &url, bool update, ResponseHandler *handler, - uint16_t timeout = 0 ); + time_t timeout = 0 ); //----------------------------------------------------------------------- //! Get a buffer with central directory of the ZIP archive diff --git a/src/XrdCl/XrdClZipListHandler.cc b/src/XrdCl/XrdClZipListHandler.cc index 3e86933b572..4544b5fd4c3 100644 --- a/src/XrdCl/XrdClZipListHandler.cc +++ b/src/XrdCl/XrdClZipListHandler.cc @@ -60,7 +60,7 @@ namespace XrdCl delete this; return; } - uint16_t left = pTimeout - took; + time_t left = pTimeout - took; switch( pStep ) { diff --git a/src/XrdCl/XrdClZipListHandler.hh b/src/XrdCl/XrdClZipListHandler.hh index 3a8f748b022..74989611e96 100644 --- a/src/XrdCl/XrdClZipListHandler.hh +++ b/src/XrdCl/XrdClZipListHandler.hh @@ -74,7 +74,7 @@ namespace XrdCl const std::string &path, DirListFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout = 0 ) : + time_t timeout = 0 ) : pUrl( url ), pFlags( flags ), pHandler( handler ), pTimeout( timeout ), pStartTime( time( 0 ) ), pStep( STAT ) { @@ -121,7 +121,7 @@ namespace XrdCl URL pUrl; DirListFlags::Flags pFlags; ResponseHandler *pHandler; - uint16_t pTimeout; + time_t pTimeout; std::unique_ptr pDirList; time_t pStartTime; diff --git a/src/XrdCl/XrdClZipOperations.hh b/src/XrdCl/XrdClZipOperations.hh index 7bf7a41339f..8746a60997f 100644 --- a/src/XrdCl/XrdClZipOperations.hh +++ b/src/XrdCl/XrdClZipOperations.hh @@ -107,11 +107,11 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &url = std::get( this->args ).Get(); OpenFlags::Flags flags = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->zip->OpenArchive( url, flags, handler, timeout ); } @@ -121,7 +121,7 @@ namespace XrdCl //! Factory for creating OpenArchiveImpl objects //---------------------------------------------------------------------------- inline OpenArchiveImpl OpenArchive( Ctx zip, Arg fn, - Arg flags, uint16_t timeout = 0 ) + Arg flags, time_t timeout = 0 ) { return OpenArchiveImpl( std::move( zip ), std::move( fn ), std::move( flags ) ).Timeout( timeout ); @@ -165,7 +165,7 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &fn = std::get( this->args ).Get(); OpenFlags::Flags flags = std::get( this->args ).Get(); @@ -183,7 +183,7 @@ namespace XrdCl //---------------------------------------------------------------------------- inline OpenFileImpl OpenFile( Ctx zip, Arg fn, Arg flags = OpenFlags::None, Arg size = 0, - Arg crc32 = 0, uint16_t timeout = 0 ) + Arg crc32 = 0, time_t timeout = 0 ) { return OpenFileImpl( std::move( zip ), std::move( fn ), std::move( flags ), std::move( size ), std::move( crc32 ) ).Timeout( timeout ); @@ -227,12 +227,12 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { uint64_t offset = std::get( this->args ).Get(); uint32_t size = std::get( this->args ).Get(); void *buffer = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->zip->Read( offset, size, buffer, handler, timeout ); } @@ -242,7 +242,7 @@ namespace XrdCl //! Factory for creating ArchiveReadImpl objects //---------------------------------------------------------------------------- inline ZipReadImpl Read( Ctx zip, Arg offset, Arg size, - Arg buffer, uint16_t timeout = 0 ) + Arg buffer, time_t timeout = 0 ) { return ZipReadImpl( std::move( zip ), std::move( offset ), std::move( size ), std::move( buffer ) ).Timeout( timeout ); @@ -284,13 +284,13 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &fn = std::get( this->args ).Get(); uint64_t offset = std::get( this->args ).Get(); uint32_t size = std::get( this->args ).Get(); void *buffer = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->zip->ReadFrom( fn, offset, size, buffer, handler, timeout ); } @@ -301,7 +301,7 @@ namespace XrdCl //---------------------------------------------------------------------------- inline ZipReadFromImpl ReadFrom( Ctx zip, Arg fn, Arg offset, Arg size, - Arg buffer, uint16_t timeout = 0 ) + Arg buffer, time_t timeout = 0 ) { return ZipReadFromImpl( std::move( zip ), std::move( fn ), std::move( offset ), std::move( size ), std::move( buffer ) ).Timeout( timeout ); @@ -345,11 +345,11 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { uint32_t size = std::get( this->args ).Get(); const void *buffer = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->zip->Write( size, buffer, handler, timeout ); } @@ -359,7 +359,7 @@ namespace XrdCl //! Factory for creating ArchiveReadImpl objects //---------------------------------------------------------------------------- inline ZipWriteImpl Write( Ctx zip, Arg size, Arg buffer, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { return ZipWriteImpl( std::move( zip ), std::move( size ), std::move( buffer ) ).Timeout( timeout ); @@ -403,13 +403,13 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { std::string &fn = std::get( this->args ).Get(); uint32_t crc32 = std::get( this->args ).Get(); uint32_t size = std::get( this->args ).Get(); const void *buffer = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->zip->AppendFile( fn, crc32, size, buffer, handler, timeout ); } @@ -420,7 +420,7 @@ namespace XrdCl //---------------------------------------------------------------------------- inline AppendFileImpl AppendFile( Ctx zip, Arg fn, Arg crc32, Arg size, - Arg buffer, uint16_t timeout = 0 ) + Arg buffer, time_t timeout = 0 ) { return AppendFileImpl( std::move( zip ), std::move( fn ), std::move( crc32 ), std::move( size ), std::move( buffer ) ).Timeout( timeout ); @@ -464,7 +464,7 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { XRootDStatus st = this->zip->CloseFile(); if( !st.IsOK() ) return st; @@ -505,7 +505,7 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { StatInfo *info = nullptr; XRootDStatus st = this->zip->Stat( info ); @@ -556,7 +556,7 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { DirectoryList *list = nullptr; XRootDStatus st = this->zip->List( list ); @@ -607,9 +607,9 @@ namespace XrdCl //! previous operation //! @return : status of the operation //------------------------------------------------------------------------ - XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout ) + XRootDStatus RunImpl( PipelineHandler *handler, time_t pipelineTimeout ) { - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->zip->CloseArchive( handler, timeout ); } @@ -618,7 +618,7 @@ namespace XrdCl //---------------------------------------------------------------------------- //! Factory for creating CloseFileImpl objects //---------------------------------------------------------------------------- - inline CloseArchiveImpl CloseArchive( Ctx zip, uint16_t timeout = 0 ) + inline CloseArchiveImpl CloseArchive( Ctx zip, time_t timeout = 0 ) { return CloseArchiveImpl( std::move( zip ) ).Timeout( timeout ); } diff --git a/src/XrdClHttp/XrdClHttpFilePlugIn.cc b/src/XrdClHttp/XrdClHttpFilePlugIn.cc index c31e7cdc531..c9706a08073 100644 --- a/src/XrdClHttp/XrdClHttpFilePlugIn.cc +++ b/src/XrdClHttp/XrdClHttpFilePlugIn.cc @@ -83,7 +83,7 @@ HttpFilePlugIn::~HttpFilePlugIn() noexcept { XRootDStatus HttpFilePlugIn::Open(const std::string &url, OpenFlags::Flags flags, Access::Mode /*mode*/, - ResponseHandler *handler, uint16_t timeout) { + ResponseHandler *handler, time_t timeout) { if (is_open_) { logger_->Error(kLogXrdClHttp, "URL %s already open", url.c_str()); return XRootDStatus(stError, errInvalidOp); @@ -179,7 +179,7 @@ XRootDStatus HttpFilePlugIn::Open(const std::string &url, } XRootDStatus HttpFilePlugIn::Close(ResponseHandler *handler, - uint16_t /*timeout*/) { + time_t /*timeout*/) { if (!is_open_) { logger_->Error(kLogXrdClHttp, "Cannot close. URL hasn't been previously opened"); @@ -204,7 +204,7 @@ XRootDStatus HttpFilePlugIn::Close(ResponseHandler *handler, } XRootDStatus HttpFilePlugIn::Stat(bool /*force*/, ResponseHandler *handler, - uint16_t timeout) { + time_t timeout) { if (!is_open_) { logger_->Error(kLogXrdClHttp, "Cannot stat. URL hasn't been previously opened"); @@ -238,7 +238,7 @@ XRootDStatus HttpFilePlugIn::Stat(bool /*force*/, ResponseHandler *handler, XRootDStatus HttpFilePlugIn::Read(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t /*timeout*/) { + time_t /*timeout*/) { if (!is_open_) { logger_->Error(kLogXrdClHttp, "Cannot read. URL hasn't previously been opened"); @@ -343,7 +343,7 @@ class PgReadSubstitutionHandler : public XrdCl::ResponseHandler { XRootDStatus HttpFilePlugIn::PgRead(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout) { + time_t timeout) { ResponseHandler *substitHandler = new PgReadSubstitutionHandler( handler, isChannelEncrypted ); XRootDStatus st = Read(offset, size, buffer, substitHandler, timeout); return st; @@ -351,7 +351,7 @@ XRootDStatus HttpFilePlugIn::PgRead(uint64_t offset, uint32_t size, void *buffer XRootDStatus HttpFilePlugIn::Write(uint64_t offset, uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout) { + time_t timeout) { if (!is_open_) { logger_->Error(kLogXrdClHttp, "Cannot write. URL hasn't previously been opened"); @@ -385,12 +385,12 @@ XRootDStatus HttpFilePlugIn::PgWrite( uint64_t offset, const void *buffer, std::vector &cksums, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { (void)cksums; return Write(offset, size, buffer, handler, timeout); } -XRootDStatus HttpFilePlugIn::Sync(ResponseHandler *handler, uint16_t timeout) { +XRootDStatus HttpFilePlugIn::Sync(ResponseHandler *handler, time_t timeout) { (void)handler; (void)timeout; @@ -402,7 +402,7 @@ XRootDStatus HttpFilePlugIn::Sync(ResponseHandler *handler, uint16_t timeout) { XRootDStatus HttpFilePlugIn::VectorRead(const ChunkList &chunks, void *buffer, ResponseHandler *handler, - uint16_t /*timeout*/) { + time_t /*timeout*/) { if (!is_open_) { logger_->Error(kLogXrdClHttp, "Cannot read. URL hasn't previously been opened"); diff --git a/src/XrdClHttp/XrdClHttpFilePlugIn.hh b/src/XrdClHttp/XrdClHttpFilePlugIn.hh index dbab10a603f..5cb92377ec1 100644 --- a/src/XrdClHttp/XrdClHttpFilePlugIn.hh +++ b/src/XrdClHttp/XrdClHttpFilePlugIn.hh @@ -42,20 +42,20 @@ class HttpFilePlugIn : public FilePlugIn { OpenFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout ) override; + time_t timeout ) override; //------------------------------------------------------------------------ //! @see XrdCl::File::Close //------------------------------------------------------------------------ virtual XRootDStatus Close( ResponseHandler *handler, - uint16_t timeout ) override; + time_t timeout ) override; //------------------------------------------------------------------------ //! @see XrdCl::File::Stat //------------------------------------------------------------------------ virtual XRootDStatus Stat( bool force, ResponseHandler *handler, - uint16_t timeout ) override; + time_t timeout ) override; //------------------------------------------------------------------------ //! @see XrdCl::File::Read @@ -64,7 +64,7 @@ class HttpFilePlugIn : public FilePlugIn { uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) override; + time_t timeout ) override; //------------------------------------------------------------------------ //! @see XrdCl::File::PgRead - async @@ -73,7 +73,7 @@ class HttpFilePlugIn : public FilePlugIn { uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) override; + time_t timeout ) override; //------------------------------------------------------------------------ //! @see XrdCl::File::Write @@ -82,7 +82,7 @@ class HttpFilePlugIn : public FilePlugIn { uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout ) override; + time_t timeout ) override; //------------------------------------------------------------------------ //! @see XrdCl::File::PgWrite - async @@ -92,13 +92,13 @@ class HttpFilePlugIn : public FilePlugIn { const void *buffer, std::vector &cksums, ResponseHandler *handler, - uint16_t timeout ) override; + time_t timeout ) override; //------------------------------------------------------------------------ //! @see XrdCl::File::Sync //------------------------------------------------------------------------ virtual XRootDStatus Sync( ResponseHandler *handler, - uint16_t timeout ) override; + time_t timeout ) override; //------------------------------------------------------------------------ //! @see XrdCl::File::VectorRead @@ -106,7 +106,7 @@ class HttpFilePlugIn : public FilePlugIn { virtual XRootDStatus VectorRead( const ChunkList &chunks, void *buffer, XrdCl::ResponseHandler *handler, - uint16_t timeout ) override; + time_t timeout ) override; //------------------------------------------------------------------------ //! @see XrdCl::File::IsOpen diff --git a/src/XrdClHttp/XrdClHttpFileSystemPlugIn.cc b/src/XrdClHttp/XrdClHttpFileSystemPlugIn.cc index 59650903406..25c840aae10 100644 --- a/src/XrdClHttp/XrdClHttpFileSystemPlugIn.cc +++ b/src/XrdClHttp/XrdClHttpFileSystemPlugIn.cc @@ -64,7 +64,7 @@ HttpFileSystemPlugIn::~HttpFileSystemPlugIn() noexcept { XRootDStatus HttpFileSystemPlugIn::Mv(const std::string &source, const std::string &dest, ResponseHandler *handler, - uint16_t timeout) { + time_t timeout) { //const auto full_source_path = url_.GetLocation() + source; //const auto full_dest_path = url_.GetLocation() + dest; const auto full_source_path = url_.GetProtocol() + "://" @@ -77,8 +77,9 @@ XRootDStatus HttpFileSystemPlugIn::Mv(const std::string &source, + dest; logger_->Debug(kLogXrdClHttp, - "HttpFileSystemPlugIn::Mv - src = %s, dest = %s, timeout = %d", - full_source_path.c_str(), full_dest_path.c_str(), timeout); + "HttpFileSystemPlugIn::Mv - src = %s, dest = %s, timeout = %lld", + full_source_path.c_str(), full_dest_path.c_str(), + (long long)timeout); auto status = Posix::Rename(*davix_client_, full_source_path, full_dest_path, timeout); @@ -95,13 +96,13 @@ XRootDStatus HttpFileSystemPlugIn::Mv(const std::string &source, XRootDStatus HttpFileSystemPlugIn::Rm(const std::string &path, ResponseHandler *handler, - uint16_t timeout) { + time_t timeout) { auto url = url_; url.SetPath(path); logger_->Debug(kLogXrdClHttp, - "HttpFileSystemPlugIn::Rm - path = %s, timeout = %d", - url.GetObfuscatedURL().c_str(), timeout); + "HttpFileSystemPlugIn::Rm - path = %s, timeout = %lld", + url.GetObfuscatedURL().c_str(), (long long)timeout); auto status = Posix::Unlink(*davix_client_, url.GetURL(), timeout); @@ -119,14 +120,14 @@ XRootDStatus HttpFileSystemPlugIn::MkDir(const std::string &path, MkDirFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout) { + time_t timeout) { auto url = url_; url.SetPath(path); logger_->Debug( kLogXrdClHttp, - "HttpFileSystemPlugIn::MkDir - path = %s, flags = %d, timeout = %d", - url.GetObfuscatedURL().c_str(), flags, timeout); + "HttpFileSystemPlugIn::MkDir - path = %s, flags = %d, timeout = %lld", + url.GetObfuscatedURL().c_str(), flags, (long long)timeout); auto status = Posix::MkDir(*davix_client_, url.GetURL(), flags, mode, timeout); if (status.IsError()) { @@ -141,13 +142,13 @@ XRootDStatus HttpFileSystemPlugIn::MkDir(const std::string &path, XRootDStatus HttpFileSystemPlugIn::RmDir(const std::string &path, ResponseHandler *handler, - uint16_t timeout) { + time_t timeout) { auto url = url_; url.SetPath(path); logger_->Debug(kLogXrdClHttp, - "HttpFileSystemPlugIn::RmDir - path = %s, timeout = %d", - url.GetObfuscatedURL().c_str(), timeout); + "HttpFileSystemPlugIn::RmDir - path = %s, timeout = %lld", + url.GetObfuscatedURL().c_str(), (long long)timeout); auto status = Posix::RmDir(*davix_client_, url.GetURL(), timeout); if (status.IsError()) { @@ -162,15 +163,15 @@ XRootDStatus HttpFileSystemPlugIn::RmDir(const std::string &path, XRootDStatus HttpFileSystemPlugIn::DirList(const std::string &path, DirListFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout) { + time_t timeout) { auto url = url_; url.SetPath(path); const auto full_path = url.GetLocation(); logger_->Debug( kLogXrdClHttp, - "HttpFileSystemPlugIn::DirList - path = %s, flags = %d, timeout = %d", - full_path.c_str(), flags, timeout); + "HttpFileSystemPlugIn::DirList - path = %s, flags = %d, timeout = %lld", + full_path.c_str(), flags, (long long)timeout); const bool details = flags & DirListFlags::Stat; const bool recursive = flags & DirListFlags::Recursive; @@ -193,15 +194,15 @@ XRootDStatus HttpFileSystemPlugIn::DirList(const std::string &path, XRootDStatus HttpFileSystemPlugIn::Stat(const std::string &path, ResponseHandler *handler, - uint16_t timeout) { + time_t timeout) { //const auto full_path = url_.GetLocation() + path; const auto full_path = url_.GetProtocol() + "://" + url_.GetHostName() + ":" + std::to_string(url_.GetPort()) + "/" + path; logger_->Debug(kLogXrdClHttp, - "HttpFileSystemPlugIn::Stat - path = %s, timeout = %d", - full_path.c_str(), timeout); + "HttpFileSystemPlugIn::Stat - path = %s, timeout = %lld", + full_path.c_str(), (long long)timeout); auto stat_info = new StatInfo(); //XRootDStatus status; diff --git a/src/XrdClHttp/XrdClHttpFileSystemPlugIn.hh b/src/XrdClHttp/XrdClHttpFileSystemPlugIn.hh index a74a1c3b1e1..25e968732b6 100644 --- a/src/XrdClHttp/XrdClHttpFileSystemPlugIn.hh +++ b/src/XrdClHttp/XrdClHttpFileSystemPlugIn.hh @@ -21,25 +21,25 @@ class HttpFileSystemPlugIn : public FileSystemPlugIn { virtual ~HttpFileSystemPlugIn() noexcept; virtual XRootDStatus Mv(const std::string &source, const std::string &dest, - ResponseHandler *handler, uint16_t timeout) override; + ResponseHandler *handler, time_t timeout) override; virtual XRootDStatus Rm(const std::string &path, ResponseHandler *handler, - uint16_t timeout) override; + time_t timeout) override; virtual XRootDStatus MkDir(const std::string &path, MkDirFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout) override; + time_t timeout) override; virtual XRootDStatus RmDir(const std::string &path, ResponseHandler *handler, - uint16_t timeout) override; + time_t timeout) override; virtual XRootDStatus DirList(const std::string &path, DirListFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout) override; + time_t timeout) override; virtual XRootDStatus Stat(const std::string &path, ResponseHandler *handler, - uint16_t timeout) override; + time_t timeout) override; virtual bool SetProperty(const std::string &name, const std::string &value) override; diff --git a/src/XrdClHttp/XrdClHttpPosix.cc b/src/XrdClHttp/XrdClHttpPosix.cc index 9bddc7a2b05..c60e9944927 100644 --- a/src/XrdClHttp/XrdClHttpPosix.cc +++ b/src/XrdClHttp/XrdClHttpPosix.cc @@ -44,7 +44,7 @@ std::vector SplitString(const std::string& input, return result; } -void SetTimeout(Davix::RequestParams& params, uint16_t timeout) { +void SetTimeout(Davix::RequestParams& params, time_t timeout) { /* * At NERSC archive portal, we get error when setOperationTimeout() * @@ -199,7 +199,7 @@ using namespace XrdCl; std::pair Open(Davix::DavPosix& davix_client, const std::string& url, int flags, - uint16_t timeout) { + time_t timeout) { Davix::RequestParams params; SetTimeout(params, timeout); SetAuthz(params); @@ -231,7 +231,7 @@ XRootDStatus Close(Davix::DavPosix& davix_client, DAVIX_FD* fd) { XRootDStatus MkDir(Davix::DavPosix& davix_client, const std::string& path, XrdCl::MkDirFlags::Flags flags, XrdCl::Access::Mode /*mode*/, - uint16_t timeout) { + time_t timeout) { return XRootDStatus(); @@ -280,7 +280,7 @@ XRootDStatus MkDir(Davix::DavPosix& davix_client, const std::string& path, } XRootDStatus RmDir(Davix::DavPosix& davix_client, const std::string& path, - uint16_t timeout) { + time_t timeout) { Davix::RequestParams params; SetTimeout(params, timeout); SetAuthz(params); @@ -298,7 +298,7 @@ XRootDStatus RmDir(Davix::DavPosix& davix_client, const std::string& path, std::pair DirList( Davix::DavPosix& davix_client, const std::string& path, bool details, - bool /*recursive*/, uint16_t timeout) { + bool /*recursive*/, time_t timeout) { Davix::RequestParams params; SetTimeout(params, timeout); SetAuthz(params); @@ -354,7 +354,7 @@ std::pair DirList( } XRootDStatus Rename(Davix::DavPosix& davix_client, const std::string& source, - const std::string& dest, uint16_t timeout) { + const std::string& dest, time_t timeout) { // most s3 storage systems either: // 1. do not support rename, especially for files that were uploaded using multi-part @@ -379,7 +379,7 @@ XRootDStatus Rename(Davix::DavPosix& davix_client, const std::string& source, } XRootDStatus Stat(Davix::DavPosix& davix_client, const std::string& url, - uint16_t timeout, StatInfo* stat_info) { + time_t timeout, StatInfo* stat_info) { Davix::RequestParams params; SetTimeout(params, timeout); SetAuthz(params); @@ -403,7 +403,7 @@ XRootDStatus Stat(Davix::DavPosix& davix_client, const std::string& url, } XRootDStatus Unlink(Davix::DavPosix& davix_client, const std::string& url, - uint16_t timeout) { + time_t timeout) { Davix::RequestParams params; SetTimeout(params, timeout); SetAuthz(params); @@ -480,7 +480,7 @@ std::pair PReadVec(Davix::DavPosix& davix_client, std::pair PWrite(Davix::DavPosix& davix_client, DAVIX_FD* fd, uint64_t offset, uint32_t size, const void* buffer, - uint16_t timeout) { + time_t timeout) { Davix::DavixError* err = nullptr; off_t new_offset = davix_client.lseek(fd, offset, SEEK_SET, &err); if (uint64_t(new_offset) != offset) { diff --git a/src/XrdClHttp/XrdClHttpPosix.hh b/src/XrdClHttp/XrdClHttpPosix.hh index 3f6ca395b26..b787414aa86 100644 --- a/src/XrdClHttp/XrdClHttpPosix.hh +++ b/src/XrdClHttp/XrdClHttpPosix.hh @@ -22,31 +22,31 @@ namespace Posix { std::pair Open(Davix::DavPosix& davix_client, const std::string& url, - int flags, uint16_t timeout); + int flags, time_t timeout); XrdCl::XRootDStatus Close(Davix::DavPosix& davix_client, DAVIX_FD* fd); XrdCl::XRootDStatus MkDir(Davix::DavPosix& davix_client, const std::string& path, XrdCl::MkDirFlags::Flags flags, - XrdCl::Access::Mode mode, uint16_t timeout); + XrdCl::Access::Mode mode, time_t timeout); XrdCl::XRootDStatus RmDir(Davix::DavPosix& davix_client, - const std::string& path, uint16_t timeout); + const std::string& path, time_t timeout); std::pair DirList( Davix::DavPosix& davix_client, const std::string& path, bool details, - bool recursive, uint16_t timeout); + bool recursive, time_t timeout); XrdCl::XRootDStatus Rename(Davix::DavPosix& davix_client, const std::string& source, const std::string& dest, - uint16_t timeout); + time_t timeout); XrdCl::XRootDStatus Stat(Davix::DavPosix& davix_client, const std::string& url, - uint16_t timeout, XrdCl::StatInfo* stat_info); + time_t timeout, XrdCl::StatInfo* stat_info); XrdCl::XRootDStatus Unlink(Davix::DavPosix& davix_client, - const std::string& url, uint16_t timeout); + const std::string& url, time_t timeout); std::pair Read(Davix::DavPosix& davix_client, DAVIX_FD* fd, void* buffer, @@ -64,7 +64,7 @@ std::pair PReadVec(Davix::DavPosix& davix_client, std::pair PWrite(Davix::DavPosix& davix_client, DAVIX_FD* fd, uint64_t offset, uint32_t size, const void* buffer, - uint16_t timeout); + time_t timeout); } // namespace Posix diff --git a/src/XrdCms/XrdCmsCluster.cc b/src/XrdCms/XrdCmsCluster.cc index 7db85777fc5..4bcad78f293 100644 --- a/src/XrdCms/XrdCmsCluster.cc +++ b/src/XrdCms/XrdCmsCluster.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include "XProtocol/YProtocol.hh" @@ -969,7 +970,7 @@ int XrdCmsCluster::Select(XrdCmsSelect &Sel) pmask |= pinfo.ssvec & Sel.nmask; if (pmask && maxBits(pmask, baseFS.dfsTries())) {Sel.Resp.DLen = snprintf(Sel.Resp.Data, sizeof(Sel.Resp.Data)-1, - "Too many DFS %s attempts; operation terminated", Amode)+1; + "File not found")+1; return RetryErr; } } @@ -1122,6 +1123,7 @@ int XrdCmsCluster::Select(SMask_t pmask, int &port, char *hbuff, int &hlen, : SelbyLoadR(pmask, selR)); if (nP) hlen = nP->netIF.GetName(hbuff, port, nType) + 1; + else hlen = 0; STMutex.UnLock(); return hlen != 1; @@ -1793,10 +1795,17 @@ XrdCmsNode *XrdCmsCluster::SelbyLoad(SMask_t mask, XrdCmsSelector &selR) XrdCmsNode *np, *sp = 0; bool Multi = false, reqSS = (selR.needSpace & XrdCmsNode::allowsSS) != 0; -// Scan for a node (preset possible, suspended, overloaded, full, and dead) -// - selR.Reset(); SelTcnt++; - for (int i = 0; i <= STHi; i++) + // Scan for a node (preset possible, suspended, overloaded, full, and dead) + // + selR.Reset(); SelTcnt++; + int selCap = 1; + int randomSel=1; + bool useWR=(Config.P_randlb==1); + //default 0 to skip the node in random selection if the below checks fail + int Weighed[STMax] = { 0 }; + //float scalingFactor = 1+(1-float(std::clamp(Config.P_fuzz,0,100))/100)*2; + for (int i = 0; i <= STHi; i++) + // Weighed[i] = 0; if ((np = NodeTab[i]) && (np->NodeMask & mask)) {if (!(selR.needNet & np->hasNet)) {selR.xNoNet= true; continue;} selR.nPick++; @@ -1807,7 +1816,14 @@ XrdCmsNode *XrdCmsCluster::SelbyLoad(SMask_t mask, XrdCmsSelector &selR) || (reqSS && np->isNoStage))) {selR.xFull = true; continue;} if (!sp) sp = np; - else{if (selR.needSpace) + else{ + if (useWR){ + //add 1 to the inverse load, this is to allow some selection in case reported loads hit 100 + int nload = 101 - np->myLoad; + selCap += nload;//static_cast(nload + std::pow(nload, scalingFactor)/2); + Weighed[i] = selCap; + } + else{if (selR.needSpace) {if (abs(sp->myMass - np->myMass) <= Config.P_fuzz) {if (sp->RefW > (np->RefW+Config.DiskLinger)) sp=np;} else if (sp->myMass > np->myMass) sp=np; @@ -1823,8 +1839,22 @@ XrdCmsNode *XrdCmsCluster::SelbyLoad(SMask_t mask, XrdCmsSelector &selR) } Multi = true; } + } } - + if (useWR){ + // pick a random weighed node + // + static std::random_device rand_dev; + static std::default_random_engine generator(rand_dev()); + static std::uniform_int_distribution distr(randomSel,selCap); + randomSel = distr(generator); + for(int i=0;i<=STHi;i++){ + if(randomSel<=Weighed[i]){ + sp=NodeTab[i]; + break; + } + } + } // Check for overloaded node and return result // if (!sp) return calcDelay(selR); @@ -1850,9 +1880,9 @@ XrdCmsNode *XrdCmsCluster::SelbyLoadR(SMask_t mask, XrdCmsSelector &selR) selR.Reset(); SelTcnt++; - int totWeight = 0; + for (int i = 0; i <= STHi; ++i) { NodeWeight[i] = 0; // make node unselectable first diff --git a/src/XrdCms/XrdCmsCluster.hh b/src/XrdCms/XrdCmsCluster.hh index 4b16d1f7949..3a30145c258 100644 --- a/src/XrdCms/XrdCmsCluster.hh +++ b/src/XrdCms/XrdCmsCluster.hh @@ -246,7 +246,6 @@ static const int AltSize = 254; // We may revert to IP address XrdSysRWLock STMutex; // Protects all node information variables XrdCmsNode *NodeTab[STMax]; // Current set of nodes int NodeWeight[STMax]; // Current set of load balancing weights - int STHi; // NodeTab high watermark int Reserved; RAtomic_llong SelWtot; // Total number of r/w selections (successful) diff --git a/src/XrdCms/XrdCmsConfig.cc b/src/XrdCms/XrdCmsConfig.cc index 3a2a69af3bb..9a46f235955 100644 --- a/src/XrdCms/XrdCmsConfig.cc +++ b/src/XrdCms/XrdCmsConfig.cc @@ -736,6 +736,7 @@ void XrdCmsConfig::ConfigDefaults(void) P_load = 0; P_mem = 0; P_pag = 0; + P_randlb = 0; // SelbyLoad algorithm choice AskPerf = 10; // Every 10 pings AskPing = 60; // Every 1 minute PingTick = 0; @@ -2688,7 +2689,8 @@ int XrdCmsConfig::xsched(XrdSysError *eDest, XrdOucStream &CFile) {"refreset", -1, &RefReset}, {"affinity", -2, 0}, {"affpath", -3, 0}, - {"tryhname", 1, &V_hntry} + {"tryhname", 1, &V_hntry}, + {"randlb", 1, &P_randlb} }; int numopts = sizeof(scopts)/sizeof(struct schedopts); diff --git a/src/XrdCms/XrdCmsConfig.hh b/src/XrdCms/XrdCmsConfig.hh index 5f925a4a0b0..daae032a0c9 100644 --- a/src/XrdCms/XrdCmsConfig.hh +++ b/src/XrdCms/XrdCmsConfig.hh @@ -107,6 +107,7 @@ int P_io; // % I/O Capacity in load factor int P_load; // % MSC Capacity in load factor int P_mem; // % MEM Capacity in load factor int P_pag; // % PAG Capacity in load factor +int P_randlb; // enable weighted random load balancing char DoMWChk; // When true (default) perform multiple write check char DoHnTry; // When true (default) use hostnames for try redirs diff --git a/src/XrdEc/XrdEcReader.cc b/src/XrdEc/XrdEcReader.cc index f8d15898d50..29ab080104c 100644 --- a/src/XrdEc/XrdEcReader.cc +++ b/src/XrdEc/XrdEcReader.cc @@ -89,11 +89,11 @@ namespace XrdEc // @return : status of the operation //----------------------------------------------------------------------- XrdCl::XRootDStatus RunImpl( XrdCl::PipelineHandler *handler, - uint16_t pipelineTimeout ) + time_t pipelineTimeout ) { std::string url = std::get( this->args ).Get(); bool updt = std::get( this->args ).Get(); - uint16_t timeout = pipelineTimeout < this->timeout ? + time_t timeout = pipelineTimeout < this->timeout ? pipelineTimeout : this->timeout; return this->zip->OpenOnly( url, updt, handler, timeout ); } @@ -105,7 +105,7 @@ namespace XrdEc inline OpenOnlyImpl OpenOnly( XrdCl::Ctx zip, XrdCl::Arg fn, XrdCl::Arg updt, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { return OpenOnlyImpl( std::move( zip ), std::move( fn ), std::move( updt ) ).Timeout( timeout ); @@ -155,7 +155,7 @@ namespace XrdEc uint32_t size, char *usrbuff, callback_t usrcb, - uint16_t timeout ) + time_t timeout ) { std::unique_lock lck( self->mtx ); @@ -431,7 +431,7 @@ namespace XrdEc //--------------------------------------------------------------------------- // Open the erasure coded / striped object //--------------------------------------------------------------------------- - void Reader::Open( XrdCl::ResponseHandler *handler, uint16_t timeout ) + void Reader::Open( XrdCl::ResponseHandler *handler, time_t timeout ) { const size_t size = objcfg.plgr.size(); std::vector opens; opens.reserve( size ); @@ -491,7 +491,7 @@ namespace XrdEc uint32_t length, void *buffer, XrdCl::ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { if( objcfg.nomtfile ) { @@ -585,7 +585,7 @@ namespace XrdEc //----------------------------------------------------------------------- // Close the data object //----------------------------------------------------------------------- - void Reader::Close( XrdCl::ResponseHandler *handler, uint16_t timeout ) + void Reader::Close( XrdCl::ResponseHandler *handler, time_t timeout ) { //--------------------------------------------------------------------- // prepare the pipelines ... @@ -613,7 +613,7 @@ namespace XrdEc //------------------------------------------------------------------------- // on-definition is not allowed here beforeiven stripes from given block //------------------------------------------------------------------------- - void Reader::Read( size_t blknb, size_t strpnb, buffer_t &buffer, callback_t cb, uint16_t timeout ) + void Reader::Read( size_t blknb, size_t strpnb, buffer_t &buffer, callback_t cb, time_t timeout ) { // generate the file name (blknb/strpnb) std::string fn = objcfg.GetFileName( blknb, strpnb ); @@ -851,7 +851,7 @@ namespace XrdEc }; } - void Reader::MissingVectorRead(std::shared_ptr ¤tBlock, size_t blkid, size_t strpid, uint16_t timeout){ + void Reader::MissingVectorRead(std::shared_ptr ¤tBlock, size_t blkid, size_t strpid, time_t timeout){ { std::unique_lock lk(missingChunksMutex); missingChunksVectorRead.emplace_back( @@ -865,7 +865,7 @@ namespace XrdEc } - void Reader::VectorRead(const XrdCl::ChunkList &chunks, void *buffer, XrdCl::ResponseHandler *handler, uint16_t timeout){ + void Reader::VectorRead(const XrdCl::ChunkList &chunks, void *buffer, XrdCl::ResponseHandler *handler, time_t timeout){ if(chunks.size() > 1024) { if(handler) handler->HandleResponse(new XrdCl::XRootDStatus(XrdCl::stError, XrdCl::errInvalidArgs, XrdCl::errInvalidArgs), nullptr); return; diff --git a/src/XrdEc/XrdEcReader.hh b/src/XrdEc/XrdEcReader.hh index 7b2de06480e..927fef07e95 100644 --- a/src/XrdEc/XrdEcReader.hh +++ b/src/XrdEc/XrdEcReader.hh @@ -82,7 +82,7 @@ namespace XrdEc //! //! @param handler : user callback //----------------------------------------------------------------------- - void Open( XrdCl::ResponseHandler *handler, uint16_t timeout = 0 ); + void Open( XrdCl::ResponseHandler *handler, time_t timeout = 0 ); //----------------------------------------------------------------------- //! Read data from the data object @@ -96,7 +96,7 @@ namespace XrdEc uint32_t length, void *buffer, XrdCl::ResponseHandler *handler, - uint16_t timeout ); + time_t timeout ); /* * Read multiple locations and lengths of data @@ -108,12 +108,12 @@ namespace XrdEc void VectorRead( const XrdCl::ChunkList &chunks, void *buffer, XrdCl::ResponseHandler *handler, - uint16_t timeout); + time_t timeout); //----------------------------------------------------------------------- //! Close the data object //----------------------------------------------------------------------- - void Close( XrdCl::ResponseHandler *handler, uint16_t timeout = 0 ); + void Close( XrdCl::ResponseHandler *handler, time_t timeout = 0 ); //----------------------------------------------------------------------- //! @return : get file size @@ -134,7 +134,7 @@ namespace XrdEc //! @param cb : callback //! @param timeout : operation timeout //----------------------------------------------------------------------- - void Read( size_t blknb, size_t strpnb, buffer_t &buffer, callback_t cb, uint16_t timeout = 0 ); + void Read( size_t blknb, size_t strpnb, buffer_t &buffer, callback_t cb, time_t timeout = 0 ); //----------------------------------------------------------------------- //! Read metadata for the object @@ -171,7 +171,7 @@ namespace XrdEc inline static callback_t ErrorCorrected(Reader *reader, std::shared_ptr &self, size_t blkid, size_t strpid); - void MissingVectorRead(std::shared_ptr &block, size_t blkid, size_t strpid, uint16_t timeout = 0); + void MissingVectorRead(std::shared_ptr &block, size_t blkid, size_t strpid, time_t timeout = 0); typedef std::unordered_map> dataarchs_t; typedef std::unordered_map metadata_t; diff --git a/src/XrdEc/XrdEcStrmWriter.cc b/src/XrdEc/XrdEcStrmWriter.cc index 08f764d4eb6..7c0af2833c3 100644 --- a/src/XrdEc/XrdEcStrmWriter.cc +++ b/src/XrdEc/XrdEcStrmWriter.cc @@ -41,7 +41,7 @@ namespace XrdEc //--------------------------------------------------------------------------- // Open the data object for writting //--------------------------------------------------------------------------- - void StrmWriter::Open( XrdCl::ResponseHandler *handler, uint16_t timeout ) + void StrmWriter::Open( XrdCl::ResponseHandler *handler, time_t timeout ) { const size_t size = objcfg.plgr.size(); @@ -105,7 +105,7 @@ namespace XrdEc //--------------------------------------------------------------------------- // Close the data object //--------------------------------------------------------------------------- - void StrmWriter::Close( XrdCl::ResponseHandler *handler, uint16_t timeout ) + void StrmWriter::Close( XrdCl::ResponseHandler *handler, time_t timeout ) { //------------------------------------------------------------------------- // First, check the global status, if we are in an error state just @@ -273,7 +273,7 @@ namespace XrdEc //--------------------------------------------------------------------------- // Close the data object (implementation) //--------------------------------------------------------------------------- - void StrmWriter::CloseImpl( XrdCl::ResponseHandler *handler, uint16_t timeout ) + void StrmWriter::CloseImpl( XrdCl::ResponseHandler *handler, time_t timeout ) { //------------------------------------------------------------------------- // First, check the global status, if we are in an error state just diff --git a/src/XrdEc/XrdEcStrmWriter.hh b/src/XrdEc/XrdEcStrmWriter.hh index a8f26c01f84..8787994401c 100644 --- a/src/XrdEc/XrdEcStrmWriter.hh +++ b/src/XrdEc/XrdEcStrmWriter.hh @@ -84,7 +84,7 @@ namespace XrdEc //! //! @param handler : user callback //----------------------------------------------------------------------- - void Open( XrdCl::ResponseHandler *handler, uint16_t timeout = 0 ); + void Open( XrdCl::ResponseHandler *handler, time_t timeout = 0 ); //----------------------------------------------------------------------- //! Write data to the data object @@ -100,7 +100,7 @@ namespace XrdEc //! //! @param handler : user callback //----------------------------------------------------------------------- - void Close( XrdCl::ResponseHandler *handler, uint16_t timeout = 0 ); + void Close( XrdCl::ResponseHandler *handler, time_t timeout = 0 ); //----------------------------------------------------------------------- //! @return : get file size @@ -162,7 +162,7 @@ namespace XrdEc //--------------------------------------------------------------------- // Indicate that the user issued close //--------------------------------------------------------------------- - void issue_close( XrdCl::ResponseHandler *handler, uint16_t timeout ) + void issue_close( XrdCl::ResponseHandler *handler, time_t timeout ) { std::unique_lock lck( mtx ); //------------------------------------------------------------------- @@ -279,7 +279,7 @@ namespace XrdEc //! //! @param handler : user callback //----------------------------------------------------------------------- - void CloseImpl( XrdCl::ResponseHandler *handler, uint16_t timeout = 0 ); + void CloseImpl( XrdCl::ResponseHandler *handler, time_t timeout = 0 ); const ObjCfg &objcfg; std::unique_ptr wrtbuff; //< current write buffer diff --git a/src/XrdHttp/XrdHttpProtocol.cc b/src/XrdHttp/XrdHttpProtocol.cc index 33e9e0ddb20..be9f3962456 100644 --- a/src/XrdHttp/XrdHttpProtocol.cc +++ b/src/XrdHttp/XrdHttpProtocol.cc @@ -60,6 +60,7 @@ #define XRHTTP_TK_GRACETIME 600 +XrdVERSIONINFO(XrdHttpProtocol, xrdhttp); /******************************************************************************/ /* G l o b a l s */ @@ -89,6 +90,7 @@ bool XrdHttpProtocol::embeddedstatic = true; char *XrdHttpProtocol::staticredir = 0; int XrdHttpProtocol::m_maxdelay = -1; XrdOucHash *XrdHttpProtocol::staticpreload = 0; +XrdSciTokensRedir *XrdHttpProtocol::m_redir = nullptr; kXR_int32 XrdHttpProtocol::myRole = kXR_isManager; bool XrdHttpProtocol::selfhttps2http = false; @@ -1091,6 +1093,7 @@ int XrdHttpProtocol::Config(const char *ConfigFN, XrdOucEnv *myEnv) { else if TS_Xeq("httpsmode", xhttpsmode); else if TS_Xeq("tlsreuse", xtlsreuse); else if TS_Xeq("auth", xauth); + else if TS_Xeq("redirtoken", xredirtoken); else if TS_Xeq("tlsclientauth", xtlsclientauth); else if TS_Xeq("maxdelay", xmaxdelay); else { @@ -3059,6 +3062,43 @@ int XrdHttpProtocol::xmaxdelay(XrdOucStream &Config) { return 0; } +/******************************************************************************/ +/* x r e d i r t o k e n */ +/******************************************************************************/ + +/* Function: xredirtoken + + Purpose: Parses the `http.redirtoken` directive + + `rediretoken` is curently a boolean; setting the directive enables + the functionality. When enabled, an incoming token will be stripped + from the `authz` query parameter and replaced with an equivalent + macaroon. + + Output: 0 upon success or 1 upon failure. + */ +int XrdHttpProtocol::xredirtoken(XrdOucStream &Config) { + auto val = Config.GetWord(); + if (!val || !val[0]) + { + val = (char *)"libXrdAccSciTokens.so"; + } + + + char eMsgBuff[2048]; + XrdVersionInfo *myVer = &XrdVERSIONINFOVAR(XrdHttpProtocol); + XrdOucPinLoader myLib(eMsgBuff, sizeof(eMsgBuff), myVer, + "http.redirtoken", val); + auto redir = (XrdSciTokensRedir **)(myLib.Resolve("SciTokensRedir")); + if (redir == nullptr) { + eDest.Emsg("redirtoken", "Failed to resolve the SciTokenRedir symbol in token library"); + return 1; + } + + m_redir = *redir; + return 0; +} + /******************************************************************************/ /* x t r a c e */ /******************************************************************************/ diff --git a/src/XrdHttp/XrdHttpProtocol.hh b/src/XrdHttp/XrdHttpProtocol.hh index c00310b2742..4f47b56d510 100644 --- a/src/XrdHttp/XrdHttpProtocol.hh +++ b/src/XrdHttp/XrdHttpProtocol.hh @@ -471,5 +471,8 @@ protected: /// The static string version of m_staticheader_map. After config parsing is done, this is /// computed and we won't need to reference m_staticheader_map in the response path. static std::unordered_map m_staticheaders; + + /// Redirect helper from SciTokens + static XrdSciTokensRedir *m_redir; }; #endif diff --git a/src/XrdHttp/XrdHttpReq.cc b/src/XrdHttp/XrdHttpReq.cc index 653c405655d..32fded514d1 100644 --- a/src/XrdHttp/XrdHttpReq.cc +++ b/src/XrdHttp/XrdHttpReq.cc @@ -622,6 +622,13 @@ bool XrdHttpReq::Redir(XrdXrootd::Bridge::Context &info, //!< the result context } else appendOpaque(redirdest, 0, 0, 0); + if (prot->m_redir) { + TRACE(REQ, " XrdHttpReq::Redir Will rewrite URL"); + auto newRedirUrl = prot->m_redir->Redirect(redirdest.c_str()); + if (!newRedirUrl.empty()) { + redirdest = newRedirUrl.c_str(); + } + } TRACE(REQ, " XrdHttpReq::Redir Redirecting to " << obfuscateAuth(redirdest.c_str()).c_str()); @@ -635,7 +642,6 @@ bool XrdHttpReq::Redir(XrdXrootd::Bridge::Context &info, //!< the result context return ret_keepalive; }; - void XrdHttpReq::appendOpaque(XrdOucString &s, XrdSecEntity *secent, char *hash, time_t tnow) { int l = 0; diff --git a/src/XrdMacaroons/CMakeLists.txt b/src/XrdMacaroons/CMakeLists.txt index 6d42feb30ec..fb8873f4097 100644 --- a/src/XrdMacaroons/CMakeLists.txt +++ b/src/XrdMacaroons/CMakeLists.txt @@ -13,13 +13,11 @@ else() find_package(Macaroons) endif() -if(NOT APPLE) - include(FindPkgConfig REQUIRED) - if(FORCE_ENABLED) - pkg_check_modules(JSON REQUIRED json-c) - else() - pkg_check_modules(JSON json-c) - endif() +include(FindPkgConfig REQUIRED) +if(FORCE_ENABLED) + pkg_check_modules(JSON REQUIRED json-c) +else() + pkg_check_modules(JSON json-c) endif() if(MACAROONS_FOUND AND JSON_FOUND AND BUILD_HTTP) @@ -33,6 +31,8 @@ set(XrdMacaroons XrdMacaroons-${PLUGIN_VERSION}) add_library(${XrdMacaroons} MODULE XrdMacaroons.cc XrdMacaroonsAuthz.cc XrdMacaroonsAuthz.hh + XrdMacaroonsGenerate.cc XrdMacaroonsGenerate.hh + XrdMacaroonsUtils.cc XrdMacaroonsUtils.hh XrdMacaroonsConfigure.cc XrdMacaroonsHandler.cc XrdMacaroonsHandler.hh ) diff --git a/src/XrdMacaroons/XrdMacaroonsAuthz.cc b/src/XrdMacaroons/XrdMacaroonsAuthz.cc index df771b06ca6..00bc7726d23 100644 --- a/src/XrdMacaroons/XrdMacaroonsAuthz.cc +++ b/src/XrdMacaroons/XrdMacaroonsAuthz.cc @@ -132,14 +132,13 @@ Authz::Authz(XrdSysLogger *log, char const *config, XrdAccAuthorize *chain) : m_max_duration(86400), m_chain(chain), m_log(log, "macarons_"), - m_authz_behavior(static_cast(Handler::AuthzBehavior::PASSTHROUGH)) + m_authz_behavior(static_cast(AuthzBehavior::PASSTHROUGH)) { - Handler::AuthzBehavior behavior(Handler::AuthzBehavior::PASSTHROUGH); + AuthzBehavior behavior(AuthzBehavior::PASSTHROUGH); XrdOucEnv env; - if (!Handler::Config(config, &env, &m_log, m_location, m_secret, m_max_duration, behavior)) - { - throw std::runtime_error("Macaroon authorization config failed."); - } + auto &configObj = XrdMacaroonsConfigFactory::Get(m_log); + m_location = configObj.site; + m_secret = configObj.secret; m_authz_behavior = static_cast(behavior); } @@ -149,11 +148,11 @@ Authz::OnMissing(const XrdSecEntity *Entity, const char *path, const Access_Operation oper, XrdOucEnv *env) { switch (m_authz_behavior) { - case Handler::AuthzBehavior::PASSTHROUGH: + case AuthzBehavior::PASSTHROUGH: return m_chain ? m_chain->Access(Entity, path, oper, env) : XrdAccPriv_None; - case Handler::AuthzBehavior::ALLOW: + case AuthzBehavior::ALLOW: return AddPriv(oper, XrdAccPriv_None);; - case Handler::AuthzBehavior::DENY: + case AuthzBehavior::DENY: return XrdAccPriv_None; } // Code should be unreachable. @@ -230,7 +229,9 @@ Authz::Access(const XrdSecEntity *Entity, const char *path, if (strncmp(reinterpret_cast(macaroon_loc), m_location.c_str(), location_sz)) { std::string location_str(reinterpret_cast(macaroon_loc), location_sz); - m_log.Emsg("Access", "Macaroon is for incorrect location", location_str.c_str()); + std::stringstream ss; + ss << "Macaroon is for incorrect location; requested " << location_str << "; got " << m_location << "."; + m_log.Emsg("Access", ss.str().c_str()); macaroon_verifier_destroy(verifier); macaroon_destroy(macaroon); return m_chain ? m_chain->Access(Entity, path, oper, env) : XrdAccPriv_None; @@ -468,7 +469,7 @@ AuthzCheck::verify_before(const unsigned char * pred, size_t pred_sz) int AuthzCheck::verify_activity(const unsigned char * pred, size_t pred_sz) { - if (!m_desired_activity.size()) {return 1;} + if (m_desired_activity.empty()) {return 1;} std::string pred_str(reinterpret_cast(pred), pred_sz); if (strncmp("activity:", pred_str.c_str(), 9)) {return 1;} m_log.Log(LogMask::Debug, "AuthzCheck", "running verify activity", pred_str.c_str()); diff --git a/src/XrdMacaroons/XrdMacaroonsConfigure.cc b/src/XrdMacaroons/XrdMacaroonsConfigure.cc index 66c2dbd1b3e..b08479e1c9a 100644 --- a/src/XrdMacaroons/XrdMacaroonsConfigure.cc +++ b/src/XrdMacaroons/XrdMacaroonsConfigure.cc @@ -5,6 +5,8 @@ #include #include +#include +#include #include #include @@ -13,91 +15,106 @@ using namespace Macaroons; +bool XrdMacaroonsConfigFactory::m_configured = false; +XrdMacaroonsConfig XrdMacaroonsConfigFactory::m_config; -static bool xonmissing(XrdOucStream &config_obj, XrdSysError *log, Handler::AuthzBehavior &behavior) + +static bool xonmissing(XrdOucGatherConf &config_obj, XrdSysError &log, AuthzBehavior &behavior) { - char *val = config_obj.GetWord(); + char *val = config_obj.GetToken(); if (!val || !val[0]) { - log->Emsg("Config", "macaroons.onmissing requires a value (valid values: passthrough [default], allow, deny)"); + log.Emsg("Config", "macaroons.onmissing requires a value (valid values: passthrough [default], allow, deny)"); return false; } if (!strcasecmp(val, "passthrough")) { - behavior = Handler::AuthzBehavior::PASSTHROUGH; + behavior = AuthzBehavior::PASSTHROUGH; } else if (!strcasecmp(val, "allow")) { - behavior = Handler::AuthzBehavior::ALLOW; + behavior = AuthzBehavior::ALLOW; } else if (!strcasecmp(val, "deny")) { - behavior = Handler::AuthzBehavior::DENY; + behavior = AuthzBehavior::DENY; } else { - log->Emsg("Config", "macaroons.onmissing is invalid (valid values: passthrough [default], allow, deny)! Provided value:", val); + log.Emsg("Config", "macaroons.onmissing is invalid (valid values: passthrough [default], allow, deny)! Provided value:", val); return false; } return true; } -bool Handler::Config(const char *config, XrdOucEnv *env, XrdSysError *log, - std::string &location, std::string &secret, ssize_t &max_duration, - AuthzBehavior &behavior) -{ - XrdOucStream config_obj(log, getenv("XRDINSTANCE"), env, "=====> "); +const XrdMacaroonsConfig & +XrdMacaroonsConfigFactory::Get(XrdSysError &log) { + if (m_configured) { + return m_config; + } + if (!Config(log)) { + throw std::runtime_error("failed to generate the macaroons configuration"); + } + log.setMsgMask(m_config.mask); + m_configured = true; + return m_config; +} - // Open and attach the config file - // - int cfg_fd; - if ((cfg_fd = open(config, O_RDONLY, 0)) < 0) { - return log->Emsg("Config", errno, "open config file", config); + +bool XrdMacaroonsConfigFactory::Config(XrdSysError &log) +{ + char *config_filename = nullptr; + if (!XrdOucEnv::Import("XRDCONFIGFN", config_filename)) { + return false; + } + XrdOucGatherConf macaroons_conf("macaroons.trace macaroons.secretkey all.sitename macaroons.maxduration macaroons.onmissing", &log); + int result; + if ((result = macaroons_conf.Gather(config_filename, XrdOucGatherConf::trim_lines)) < 0) { + log.Emsg("Config", -result, "parsing config file", config_filename); + return false; } - config_obj.Attach(cfg_fd); - static const char *cvec[] = { "*** macaroons plugin config:", 0 }; - config_obj.Capture(cvec); // Set default mask for logging. - log->setMsgMask(LogMask::Error | LogMask::Warning); + m_config.mask = LogMask::Error | LogMask::Warning; // Set default maximum duration (24 hours). - max_duration = 24*3600; + m_config.maxDuration = 24*3600; // Process items // - char *orig_var, *var; - bool success = true, ismine; - while ((orig_var = config_obj.GetMyFirstWord())) { - var = orig_var; - if ((ismine = !strncmp("all.sitename", var, 12))) var += 4; - else if ((ismine = !strncmp("macaroons.", var, 10)) && var[10]) var += 10; - - - - if (!ismine) {continue;} - - if (!strcmp("secretkey", var)) {success = xsecretkey(config_obj, log, secret);} - else if (!strcmp("sitename", var)) {success = xsitename(config_obj, log, location);} - else if (!strcmp("trace", var)) {success = xtrace(config_obj, log);} - else if (!strcmp("maxduration", var)) {success = xmaxduration(config_obj, log, max_duration);} - else if (!strcmp("onmissing", var)) {success = xonmissing(config_obj, log, behavior);} + bool success = true; + while (macaroons_conf.GetLine()) { + auto directive = macaroons_conf.GetToken(); + if (!strcmp(directive, "secretkey")) {success = xsecretkey(macaroons_conf, log, m_config.secret);} + else if (!strcmp("sitename", directive)) {success = xsitename(macaroons_conf, log, m_config.site);} + else if (!strcmp("trace", directive)) {success = xtrace(macaroons_conf, log);} + else if (!strcmp("maxduration", directive)) {success = xmaxduration(macaroons_conf, log, m_config.maxDuration);} + else if (!strcmp("onmissing", directive)) {success = xonmissing(macaroons_conf, log, m_config.behavior);} else { - log->Say("Config warning: ignoring unknown directive '", orig_var, "'."); - config_obj.Echo(); + log.Say("Config warning: ignoring unknown directive '", directive, "'."); + macaroons_conf.EchoLine(); continue; } if (!success) { - config_obj.Echo(); + log.Emsg("MacaroonsConfig", "failed to process configuration directive"); + macaroons_conf.EchoLine(); break; } } - if (success && !location.size()) - { - log->Emsg("Config", "all.sitename must be specified to use macaroons."); - return false; + if (success) { + if (m_config.site.empty()) + { + log.Emsg("Config", "all.sitename must be specified to use macaroons."); + return false; + } + if (m_config.secret.empty()) + { + log.Emsg("Config", "macaroons.secretkey must be specified and the file non-empty to use macaroons."); + return false; + } } + m_config.mask = log.getMsgMask(); return success; } -bool Handler::xtrace(XrdOucStream &Config, XrdSysError *log) +bool XrdMacaroonsConfigFactory::xtrace(XrdOucGatherConf &Config, XrdSysError &log) { static struct traceopts { const char *opname; enum LogMask opval; } tropts[] = { { "all", LogMask::All }, @@ -109,10 +126,10 @@ bool Handler::xtrace(XrdOucStream &Config, XrdSysError *log) int i, neg, trval = 0, numopts = sizeof(tropts)/sizeof(struct traceopts); - char *val = Config.GetWord(); + char *val = Config.GetToken(); if (!val || !*val) { - log->Emsg("Config", "macaroons.trace requires at least one directive" + log.Emsg("Config", "macaroons.trace requires at least one directive" " [ all | error | warning | info | debug | none | off ]"); return false; } @@ -134,46 +151,46 @@ bool Handler::xtrace(XrdOucStream &Config, XrdSysError *log) } if (neg) --val; if (i >= numopts) - log->Emsg("Config", "macaroons.trace: ignoring invalid trace option:", val); + log.Emsg("Config", "macaroons.trace: ignoring invalid trace option:", val); } - val = Config.GetWord(); + val = Config.GetToken(); } - log->setMsgMask(trval); + log.setMsgMask(trval); return true; } -bool Handler::xmaxduration(XrdOucStream &config_obj, XrdSysError *log, ssize_t &max_duration) +bool XrdMacaroonsConfigFactory::xmaxduration(XrdOucGatherConf &config_obj, XrdSysError &log, ssize_t &max_duration) { - char *val = config_obj.GetWord(); + char *val = config_obj.GetToken(); if (!val || !val[0]) { - log->Emsg("Config", "macaroons.maxduration requires a value"); + log.Emsg("Config", "macaroons.maxduration requires a value"); return false; } char *endptr = NULL; long int max_duration_parsed = strtoll(val, &endptr, 10); if (endptr == val) { - log->Emsg("Config", "Unable to parse macaroons.maxduration as an integer", val); + log.Emsg("Config", "Unable to parse macaroons.maxduration as an integer", val); return false; } if (errno != 0) { - log->Emsg("Config", errno, "parse macaroons.maxduration as an integer."); + log.Emsg("Config", errno, "parse macaroons.maxduration as an integer."); } max_duration = max_duration_parsed; return true; } -bool Handler::xsitename(XrdOucStream &config_obj, XrdSysError *log, std::string &location) +bool XrdMacaroonsConfigFactory::xsitename(XrdOucGatherConf &config_obj, XrdSysError &log, std::string &location) { - char *val = config_obj.GetWord(); + char *val = config_obj.GetToken(); if (!val || !val[0]) { - log->Emsg("Config", "all.sitename requires a name"); + log.Emsg("Config", "all.sitename requires a name"); return false; } @@ -181,19 +198,19 @@ bool Handler::xsitename(XrdOucStream &config_obj, XrdSysError *log, std::string return true; } -bool Handler::xsecretkey(XrdOucStream &config_obj, XrdSysError *log, std::string &secret) +bool XrdMacaroonsConfigFactory::xsecretkey(XrdOucGatherConf &config_obj, XrdSysError &log, std::string &secret) { - char *val = config_obj.GetWord(); + char *val = config_obj.GetToken(); if (!val || !val[0]) { - log->Emsg("Config", "Shared secret key not specified"); + log.Emsg("Config", "Shared secret key not specified"); return false; } FILE *fp = fopen(val, "rb"); if (fp == NULL) { - log->Emsg("Config", errno, "open shared secret key file", val); + log.Emsg("Config", errno, "open shared secret key file", val); return false; } @@ -204,14 +221,14 @@ bool Handler::xsecretkey(XrdOucStream &config_obj, XrdSysError *log, std::string b64 = BIO_new(BIO_f_base64()); if (!b64) { - log->Emsg("Config", "Failed to allocate base64 filter"); + log.Emsg("Config", "Failed to allocate base64 filter"); return false; } bio = BIO_new_fp(fp, 0); // fp will be closed when BIO is freed. if (!bio) { BIO_free_all(b64); - log->Emsg("Config", "Failed to allocate BIO filter"); + log.Emsg("Config", "Failed to allocate BIO filter"); return false; } bio_out = BIO_new(BIO_s_mem()); @@ -219,7 +236,7 @@ bool Handler::xsecretkey(XrdOucStream &config_obj, XrdSysError *log, std::string { BIO_free_all(b64); BIO_free_all(bio); - log->Emsg("Config", "Failed to allocate BIO output"); + log.Emsg("Config", "Failed to allocate BIO output"); return false; } @@ -236,13 +253,13 @@ bool Handler::xsecretkey(XrdOucStream &config_obj, XrdSysError *log, std::string if (inlen < 0) { BIO_free_all(b64); BIO_free_all(bio_out); - log->Emsg("Config", errno, "read secret key."); + log.Emsg("Config", errno, "read secret key."); return false; } if (!BIO_flush(bio_out)) { BIO_free_all(b64); BIO_free_all(bio_out); - log->Emsg("Config", errno, "flush secret key."); + log.Emsg("Config", errno, "flush secret key."); return false; } @@ -255,7 +272,7 @@ bool Handler::xsecretkey(XrdOucStream &config_obj, XrdSysError *log, std::string BIO_free_all(bio_out); if (secret.size() < 32) { - log->Emsg("Config", "Secret key is too short; must be 32 bytes long. Try running 'openssl rand -base64 -out", val, "64' to generate a new key"); + log.Emsg("Config", "Secret key is too short; must be 32 bytes long. Try running 'openssl rand -base64 -out", val, "64' to generate a new key"); return false; } diff --git a/src/XrdMacaroons/XrdMacaroonsGenerate.cc b/src/XrdMacaroons/XrdMacaroonsGenerate.cc new file mode 100644 index 00000000000..602ee730779 --- /dev/null +++ b/src/XrdMacaroons/XrdMacaroonsGenerate.cc @@ -0,0 +1,138 @@ + +#include "XrdMacaroonsGenerate.hh" +#include "XrdMacaroonsHandler.hh" +#include "XrdMacaroonsUtils.hh" + +#include "XrdOuc/XrdOucEnv.hh" +#include "XrdOuc/XrdOucGatherConf.hh" + +#include + +using namespace Macaroons; + +std::string +XrdMacaroonsGenerator::Generate(const std::string &id, const std::string &user, const std::string &path, const std::bitset &opers, time_t expiry, const std::vector &other_caveats) +{ + if (m_secret.empty()) { + m_log.Log(LogMask::Error, "Redirect", "Cannot overwrite redirect URL; no macaroon secret configured"); + return ""; + } + + std::string activity = "activity:READ_METADATA"; + if (opers[AOP_Read]) { + activity += ",DOWNLOAD"; + } + if (opers[AOP_Create]) { + activity += ",UPLOAD"; + } + if (opers[AOP_Delete]) { + activity += ",DELETE"; + } + if (opers[AOP_Chown]) { + activity += ",MANAGE,UPDATE_METADATA"; + } + if (opers[AOP_Readdir]) { + activity += ",LIST"; + } + + char utc_time_buf[21]; + if (!strftime(utc_time_buf, 21, "%FT%TZ", gmtime(&expiry))) + { + m_log.Log(LogMask::Warning, "Redirect", "Failed to generate UTC time for macaroon"); + return ""; + } + std::string time_caveat = "before:" + std::string(utc_time_buf); + + enum macaroon_returncode mac_err; + struct macaroon *mac = macaroon_create(reinterpret_cast(m_sitename.c_str()), + m_sitename.size(), + reinterpret_cast(m_secret.c_str()), + m_secret.size(), + reinterpret_cast(id.c_str()), + id.size(), &mac_err); + if (!mac) { + m_log.Log(LogMask::Warning, "Redirect", "Failed to create a new macaroon"); + return ""; + } + + struct macaroon *mac_with_name; + if (user.empty()) { + mac_with_name = mac; + } else { + auto name_caveat = "name:" + user; + mac_with_name = macaroon_add_first_party_caveat(mac, + reinterpret_cast(name_caveat.c_str()), + name_caveat.size(), + &mac_err); + macaroon_destroy(mac); + } + if (!mac_with_name) + { + m_log.Log(LogMask::Warning, "Redirect", "Failed to add username to macaroon"); + return ""; + } + + struct macaroon *mac_with_activities = macaroon_add_first_party_caveat( + mac_with_name, + reinterpret_cast(activity.c_str()), + activity.size(), + &mac_err + ); + + macaroon_destroy(mac_with_name); + if (!mac_with_activities) + { + m_log.Log(LogMask::Warning, "Redirect", "Failed to add activities to macaroon"); + return ""; + } + + for (const auto &caveat : other_caveats) + { + struct macaroon *mac_tmp = mac_with_activities; + mac_with_activities = macaroon_add_first_party_caveat(mac_tmp, + reinterpret_cast(caveat.c_str()), + caveat.size(), + &mac_err); + macaroon_destroy(mac_tmp); + if (!mac_with_activities) + { + return ""; + } + } + + std::string path_caveat = "path:" + Macaroons::NormalizeSlashes(path); + m_log.Emsg("Generate", "Creating path caveat at ", path_caveat.c_str()); + struct macaroon *mac_with_path = macaroon_add_first_party_caveat( + mac_with_activities, + reinterpret_cast(path_caveat.c_str()), + path_caveat.size(), + &mac_err); + macaroon_destroy(mac_with_activities); + if (!mac_with_path) { + m_log.Log(LogMask::Warning, "Redirect", "Failed to add path restriction to macaroon"); + return ""; + } + + struct macaroon *mac_with_date = macaroon_add_first_party_caveat( + mac_with_path, + reinterpret_cast(time_caveat.c_str()), + time_caveat.size(), + &mac_err); + macaroon_destroy(mac_with_path); + if (!mac_with_date) { + m_log.Log(LogMask::Warning, "Redirect", "Failed to add expiration date to macaroon"); + return ""; + } + + size_t size_hint = macaroon_serialize_size_hint(mac_with_date); + + std::vector macaroon_resp; macaroon_resp.resize(size_hint); + if (macaroon_serialize(mac_with_date, &macaroon_resp[0], size_hint, &mac_err)) + { + m_log.Log(LogMask::Warning, "Redirect", "Failed to serialize macaroon to base64"); + return ""; + } + macaroon_destroy(mac_with_date); + + return std::string(&macaroon_resp[0]); +} diff --git a/src/XrdMacaroons/XrdMacaroonsGenerate.hh b/src/XrdMacaroons/XrdMacaroonsGenerate.hh new file mode 100644 index 00000000000..76ba4f6a6c1 --- /dev/null +++ b/src/XrdMacaroons/XrdMacaroonsGenerate.hh @@ -0,0 +1,43 @@ + +#ifndef __XRDMACAROONS_GENERATOR_H +#define __XRDMACAROONS_GENERATOR_H + +#include "XrdMacaroonsUtils.hh" + +#include "XrdAcc/XrdAccAuthorize.hh" +#include "XrdSys/XrdSysError.hh" + +#include +#include +#include +#include + +namespace Macaroons { + +class XrdMacaroonsGenerator final { +public: + XrdMacaroonsGenerator(XrdSysError &err) : + m_log(err) + { + auto &config = XrdMacaroonsConfigFactory::Get(m_log); + m_secret = config.secret; + m_sitename = config.site; + } + + // Generate a macaroon, returning it as an encoded string. + // @param id - unique ID for the macaroon + // @param path - path to limit the macaroon to + // @param opers - the permitted operations bitmask for the macaroon + // @param expiry - the Unix timestamp when the macaroon should expir + std::string Generate(const std::string &id, const std::string &user, const std::string &path, const std::bitset &opers, time_t expiry, const std::vector &other_caveats); + +private: + + XrdSysError &m_log; + std::string m_secret; + std::string m_sitename; +}; + +} + +#endif diff --git a/src/XrdMacaroons/XrdMacaroonsHandler.cc b/src/XrdMacaroons/XrdMacaroonsHandler.cc index 2bb5af5c099..3ba41081eea 100644 --- a/src/XrdMacaroons/XrdMacaroonsHandler.cc +++ b/src/XrdMacaroons/XrdMacaroonsHandler.cc @@ -53,28 +53,6 @@ char *unquote(const char *str) { } - -std::string Macaroons::NormalizeSlashes(const std::string &input) -{ - std::string output; - // In most cases, the output should be "about as large" - // as the input - output.reserve(input.size()); - char prior_chr = '\0'; - size_t output_idx = 0; - for (size_t idx = 0; idx < input.size(); idx++) { - char chr = input[idx]; - if (prior_chr == '/' && chr == '/') { - output_idx++; - continue; - } - output += input[output_idx]; - prior_chr = chr; - output_idx++; - } - return output; -} - static ssize_t determine_validity(const std::string& input) { @@ -127,12 +105,24 @@ Handler::~Handler() } +// Generate and return an ID for use with the new macaroon +// +// Note: this also writes the creation of the ID (and the input +// information) into the log for auditing purposes. +// +// @param resource - the URL resource / path prefix the macaroon will authorize +// @param entity - the security principal that will receive the macaroon +// @param activities - the activities the macaroon will be authorized for +// @param other_caveats - additional caveats that will restrict the macaroon +// @param expiry - the Unix timestamp when the token will expire +// +// @return - the ID to embed into the macaroon. The function will not fail std::string Handler::GenerateID(const std::string &resource, const XrdSecEntity &entity, const std::string &activities, const std::vector &other_caveats, - const std::string &before) + time_t expiry) { uuid_t uu; uuid_generate_random(uu); @@ -140,7 +130,7 @@ Handler::GenerateID(const std::string &resource, uuid_unparse(uu, uuid_buf); std::string result(uuid_buf); -// The following code shoul have been strictly for debugging purposes. This +// The following code should have been strictly for debugging purposes. This // added code skips it unless debug logging has been enabled. Due to the code // structure, indentation is a bit of a struggle as this is a minimal fix. // @@ -165,7 +155,14 @@ if (m_log->getMsgMask() & LogMask::Debug) ss << "user_caveat=" << *iter << ", "; } - ss << "expires=" << before; + char utc_time_buf[21]; + if (strftime(utc_time_buf, 21, "%FT%TZ", gmtime(&expiry))) + { + std::string utc_time_str(utc_time_buf); + ss << "expires=" << utc_time_str; + } else { + m_log->Emsg("MacaroonGen", "Failed to generate the human-readable expiry time"); + } m_log->Emsg("MacaroonGen", ss.str().c_str()); // Mask::Debug } @@ -173,17 +170,31 @@ if (m_log->getMsgMask() & LogMask::Debug) } -std::string +std::bitset Handler::GenerateActivities(const XrdHttpExtReq & req, const std::string &resource) const { - std::string result = "activity:READ_METADATA"; + std::bitset result; // TODO - generate environment object that includes the Authorization header. XrdAccPrivs privs = m_chain ? m_chain->Access(&req.GetSecEntity(), resource.c_str(), AOP_Any, NULL) : XrdAccPriv_None; - if ((privs & XrdAccPriv_Create) == XrdAccPriv_Create) {result += ",UPLOAD";} - if (privs & XrdAccPriv_Read) {result += ",DOWNLOAD";} - if (privs & XrdAccPriv_Delete) {result += ",DELETE";} - if ((privs & XrdAccPriv_Chown) == XrdAccPriv_Chown) {result += ",MANAGE,UPDATE_METADATA";} - if (privs & XrdAccPriv_Readdir) {result += ",LIST";} + if ((privs & XrdAccPriv_Create) == XrdAccPriv_Create) {result.set(AOP_Create);} + if (privs & XrdAccPriv_Read) {result.set(AOP_Read);} + if (privs & XrdAccPriv_Delete) {result.set(AOP_Delete);} + if ((privs & XrdAccPriv_Chown) == XrdAccPriv_Chown) {result.set(AOP_Chown);} + if (privs & XrdAccPriv_Readdir) {result.set(AOP_Readdir);} + return result; +} + + +// Given a list of operations, returns a human-readable list of activities that are authorized +std::string +Handler::GenerateActivitiesStr(const std::bitset &opers) const +{ + std::string result = "READ_METADATA"; + if (opers[AOP_Create]) {result += ",UPLOAD";} + if (opers[AOP_Read]) {result += ",DOWNLOAD";} + if (opers[AOP_Delete]) {result += ",DELETE";} + if (opers[AOP_Chown]) {result += ",MANAGE,UPDATE_METADATA";} + if (opers[AOP_Readdir]) {result += ",LIST";} return result; } @@ -244,7 +255,7 @@ int Handler::ProcessTokenRequest(XrdHttpExtReq &req) } if (header->second != "application/x-www-form-urlencoded") { - return req.SendSimpleResp(400, NULL, NULL, "Content-Type must be set to `application/macaroon-request' to request a macaroon", 0); + return req.SendSimpleResp(400, NULL, NULL, "Content-Type must be set to `application/x-www-form-urlencoded' to process a form-encoded request", 0); } char *request_data_raw; // Note: this does not null-terminate the buffer contents. @@ -437,6 +448,10 @@ int Handler::ProcessReq(XrdHttpExtReq &req) { json_object_put(macaroon_req); return req.SendSimpleResp(400, NULL, NULL, "Invalid ISO 8601 duration for validity key", 0); + } else { + std::stringstream ss; + ss << "Generating macaroon with validity of " << validity << " seconds"; + m_log->Log(LogMask::Debug, "ProcessReq", ss.str().c_str()); } json_object *caveats_obj; std::vector other_caveats; @@ -474,116 +489,23 @@ Handler::GenerateMacaroonResponse(XrdHttpExtReq &req, const std::string &resourc { validity = (validity > m_max_duration) ? m_max_duration : validity; } - now += validity; - - char utc_time_buf[21]; - if (!strftime(utc_time_buf, 21, "%FT%TZ", gmtime(&now))) - { - return req.SendSimpleResp(500, NULL, NULL, "Internal error constructing UTC time", 0); - } - std::string utc_time_str(utc_time_buf); - std::stringstream ss; - ss << "before:" << utc_time_str; - std::string utc_time_caveat = ss.str(); - - std::string activities = GenerateActivities(req, resource); - std::string macaroon_id = GenerateID(resource, req.GetSecEntity(), activities, other_caveats, utc_time_str); - enum macaroon_returncode mac_err; - - struct macaroon *mac = macaroon_create(reinterpret_cast(m_location.c_str()), - m_location.size(), - reinterpret_cast(m_secret.c_str()), - m_secret.size(), - reinterpret_cast(macaroon_id.c_str()), - macaroon_id.size(), &mac_err); - if (!mac) { - return req.SendSimpleResp(500, NULL, NULL, "Internal error constructing the macaroon", 0); - } - - // Embed the SecEntity name, if present. - struct macaroon *mac_with_name; - const char * sec_name = req.GetSecEntity().name; - if (sec_name) { - std::stringstream name_caveat_ss; - name_caveat_ss << "name:" << sec_name; - std::string name_caveat = name_caveat_ss.str(); - mac_with_name = macaroon_add_first_party_caveat(mac, - reinterpret_cast(name_caveat.c_str()), - name_caveat.size(), - &mac_err); - macaroon_destroy(mac); - } else { - mac_with_name = mac; - } - if (!mac_with_name) - { - return req.SendSimpleResp(500, NULL, NULL, "Internal error adding default activities to macaroon", 0); - } - - struct macaroon *mac_with_activities = macaroon_add_first_party_caveat(mac_with_name, - reinterpret_cast(activities.c_str()), - activities.size(), - &mac_err); - macaroon_destroy(mac_with_name); - if (!mac_with_activities) - { - return req.SendSimpleResp(500, NULL, NULL, "Internal error adding default activities to macaroon", 0); - } + auto expiry = now + validity; + std::bitset opers = GenerateActivities(req, resource); + std::string macaroon_id = GenerateID(resource, req.GetSecEntity(), GenerateActivitiesStr(opers), other_caveats, expiry); - for (const auto &caveat : other_caveats) - { - struct macaroon *mac_tmp = mac_with_activities; - mac_with_activities = macaroon_add_first_party_caveat(mac_tmp, - reinterpret_cast(caveat.c_str()), - caveat.size(), - &mac_err); - macaroon_destroy(mac_tmp); - if (!mac_with_activities) - { - return req.SendSimpleResp(500, NULL, NULL, "Internal error adding user caveat to macaroon", 0); - } - } - - // Note we don't call `NormalizeSlashes` here; for backward compatibility reasons, we ensure the - // token issued is identical to what was working with prior versions of XRootD. This allows for a - // mix of old/new versions in a single cluster to interoperate. In a few years, it might be reasonable - // to invoke it here as well. - std::string path_caveat = "path:" + resource; - struct macaroon *mac_with_path = macaroon_add_first_party_caveat(mac_with_activities, - reinterpret_cast(path_caveat.c_str()), - path_caveat.size(), - &mac_err); - macaroon_destroy(mac_with_activities); - if (!mac_with_path) { - return req.SendSimpleResp(500, NULL, NULL, "Internal error adding path to macaroon", 0); - } - - struct macaroon *mac_with_date = macaroon_add_first_party_caveat(mac_with_path, - reinterpret_cast(utc_time_caveat.c_str()), - utc_time_caveat.size(), - &mac_err); - macaroon_destroy(mac_with_path); - if (!mac_with_date) { - return req.SendSimpleResp(500, NULL, NULL, "Internal error adding date to macaroon", 0); - } - - size_t size_hint = macaroon_serialize_size_hint(mac_with_date); - - std::vector macaroon_resp; macaroon_resp.resize(size_hint); - if (macaroon_serialize(mac_with_date, &macaroon_resp[0], size_hint, &mac_err)) - { - printf("Returned macaroon_serialize code: %zu\n", size_hint); - return req.SendSimpleResp(500, NULL, NULL, "Internal error serializing macaroon", 0); + auto username = req.GetSecEntity().name ? std::string(req.GetSecEntity().name) : ""; + auto macaroon_encoded = m_generator.Generate(macaroon_id, username, resource, opers, expiry, other_caveats); + if (macaroon_encoded.empty()) { + return req.SendSimpleResp(500, nullptr, nullptr, "Internal error when generating new macaroon", 0); } - macaroon_destroy(mac_with_date); json_object *response_obj = json_object_new_object(); if (!response_obj) { return req.SendSimpleResp(500, NULL, NULL, "Unable to create new JSON response object.", 0); } - json_object *macaroon_obj = json_object_new_string_len(&macaroon_resp[0], strlen(&macaroon_resp[0])); + json_object *macaroon_obj = json_object_new_string_len(macaroon_encoded.c_str(), macaroon_encoded.length()); if (!macaroon_obj) { return req.SendSimpleResp(500, NULL, NULL, "Unable to create a new JSON macaroon string.", 0); diff --git a/src/XrdMacaroons/XrdMacaroonsHandler.hh b/src/XrdMacaroons/XrdMacaroonsHandler.hh index 6c1a5d8df7a..5b669b296de 100644 --- a/src/XrdMacaroons/XrdMacaroonsHandler.hh +++ b/src/XrdMacaroons/XrdMacaroonsHandler.hh @@ -1,9 +1,15 @@ +#ifndef __XRD_MACAROONS_HANDLER_H +#define __XRD_MACAROONS_HANDLER_H + #include #include #include #include +#include "XrdMacaroonsGenerate.hh" +#include "XrdMacaroonsUtils.hh" + #include "XrdHttp/XrdHttpExtHandler.hh" class XrdOucEnv; @@ -13,14 +19,6 @@ class XrdAccAuthorize; namespace Macaroons { -enum LogMask { - Debug = 0x01, - Info = 0x02, - Warning = 0x04, - Error = 0x08, - All = 0xff -}; - // 'Normalize' the macaroon path. This only takes care of double slashes // but, as is common in XRootD, it doesn't treat these as a hierarchy. // For example, these result in the same path: @@ -42,21 +40,13 @@ public: XrdAccAuthorize *chain) : m_max_duration(86400), m_chain(chain), - m_log(log) + m_log(log), + m_generator(*m_log) { - AuthzBehavior behavior; - if (!Config(config, myEnv, m_log, m_location, m_secret, m_max_duration, behavior)) - { - throw std::runtime_error("Macaroon handler config failed."); - } + const auto &configObj = XrdMacaroonsConfigFactory::Get(*log); + m_max_duration = configObj.maxDuration; } - enum AuthzBehavior { - PASSTHROUGH, - ALLOW, - DENY - }; - virtual ~Handler(); virtual bool MatchesPath(const char *verb, const char *path) override; @@ -64,30 +54,22 @@ public: virtual int Init(const char *cfgfile) override {return 0;} - // Static configuration method; made static to allow Authz object to reuse - // this code. - static bool Config(const char *config, XrdOucEnv *env, XrdSysError *log, - std::string &location, std::string &secret, ssize_t &max_duration, - AuthzBehavior &behavior); - private: - std::string GenerateID(const std::string &, const XrdSecEntity &, const std::string &, const std::vector &, const std::string &); - std::string GenerateActivities(const XrdHttpExtReq &, const std::string &) const; + std::string GenerateID(const std::string &, const XrdSecEntity &, const std::string &, const std::vector &, time_t); + std::bitset GenerateActivities(const XrdHttpExtReq &, const std::string &) const; + std::string GenerateActivitiesStr(const std::bitset &opers) const; + int ProcessOAuthConfig(XrdHttpExtReq &req); int ProcessTokenRequest(XrdHttpExtReq& req); int GenerateMacaroonResponse(XrdHttpExtReq& req, const std::string &response, const std::vector &, ssize_t validity, bool oauth_response); - static bool xsecretkey(XrdOucStream &Config, XrdSysError *log, std::string &secret); - static bool xsitename(XrdOucStream &Config, XrdSysError *log, std::string &location); - static bool xtrace(XrdOucStream &Config, XrdSysError *log); - static bool xmaxduration(XrdOucStream &Config, XrdSysError *log, ssize_t &max_duration); - ssize_t m_max_duration; XrdAccAuthorize *m_chain; XrdSysError *m_log; - std::string m_location; - std::string m_secret; + XrdMacaroonsGenerator m_generator; }; } + +#endif diff --git a/src/XrdMacaroons/XrdMacaroonsUtils.cc b/src/XrdMacaroons/XrdMacaroonsUtils.cc new file mode 100644 index 00000000000..cec8a655bf9 --- /dev/null +++ b/src/XrdMacaroons/XrdMacaroonsUtils.cc @@ -0,0 +1,105 @@ + +#include "XrdMacaroonsUtils.hh" + +#include "XrdSys/XrdSysError.hh" + +#include +#include + +#include + +bool +Macaroons::GetSecretKey(const std::string &filename, XrdSysError *log, std::string &secret) +{ + FILE *fp = fopen(filename.c_str(), "rb"); + + if (fp == NULL) { + log->Emsg("Config", errno, "open shared secret key file", filename.c_str()); + return false; + } + + BIO *bio, *b64, *bio_out; + char inbuf[512]; + int inlen; + + b64 = BIO_new(BIO_f_base64()); + if (!b64) + { + log->Emsg("Config", "Failed to allocate base64 filter"); + return false; + } + bio = BIO_new_fp(fp, 0); // fp will be closed when BIO is freed. + if (!bio) + { + BIO_free_all(b64); + log->Emsg("Config", "Failed to allocate BIO filter"); + return false; + } + bio_out = BIO_new(BIO_s_mem()); + if (!bio_out) + { + BIO_free_all(b64); + BIO_free_all(bio); + log->Emsg("Config", "Failed to allocate BIO output"); + return false; + } + + BIO_push(b64, bio); + while ((inlen = BIO_read(b64, inbuf, 512)) > 0) + { + if (inlen < 0) { + if (errno == EINTR) continue; + break; + } else { + BIO_write(bio_out, inbuf, inlen); + } + } + if (inlen < 0) { + BIO_free_all(b64); + BIO_free_all(bio_out); + log->Emsg("Config", errno, "read secret key."); + return false; + } + if (!BIO_flush(bio_out)) { + BIO_free_all(b64); + BIO_free_all(bio_out); + log->Emsg("Config", errno, "flush secret key."); + return false; + } + + char *decoded; + long data_len = BIO_get_mem_data(bio_out, &decoded); + BIO_free_all(b64); + + secret = std::string(decoded, data_len); + + BIO_free_all(bio_out); + + if (secret.size() < 32) { + log->Emsg("Config", "Secret key is too short; must be 32 bytes long. Try running 'openssl rand -base64 -out", filename.c_str(), "64' to generate a new key"); + return false; + } + + return true; +} + +std::string Macaroons::NormalizeSlashes(const std::string &input) +{ + std::string output; + // In most cases, the output should be "about as large" + // as the input + output.reserve(input.size()); + char prior_chr = '\0'; + size_t output_idx = 0; + for (size_t idx = 0; idx < input.size(); idx++) { + char chr = input[idx]; + if (prior_chr == '/' && chr == '/') { + output_idx++; + continue; + } + output += input[output_idx]; + prior_chr = chr; + output_idx++; + } + return output; +} diff --git a/src/XrdMacaroons/XrdMacaroonsUtils.hh b/src/XrdMacaroons/XrdMacaroonsUtils.hh new file mode 100644 index 00000000000..40b6c1c8936 --- /dev/null +++ b/src/XrdMacaroons/XrdMacaroonsUtils.hh @@ -0,0 +1,62 @@ +#pragma once + +#include + +class XrdSysError; +class XrdOucGatherConf; + +namespace Macaroons { + +enum LogMask { + Debug = 0x01, + Info = 0x02, + Warning = 0x04, + Error = 0x08, + All = 0xff +}; + +enum AuthzBehavior { + PASSTHROUGH, + ALLOW, + DENY +}; + +bool GetSecretKey(const std::string &filename, XrdSysError *log, std::string &secret); + +std::string NormalizeSlashes(const std::string &input); + +struct XrdMacaroonsConfig { +private: + XrdMacaroonsConfig(const XrdMacaroonsConfig &) = delete; + +public: + XrdMacaroonsConfig() = default; + int mask; // The configured log mask for XrdMacaroons + AuthzBehavior behavior; // The behavior for handling authorization on failures. + ssize_t maxDuration; // The maximum acceptable duration of generated macaroons. + std::string site; // The sitename to use within a generated macaroon (or for verifying a macaroon). + std::string secret; // The secret string ot use when generating/verifying macaroons. +}; + +// An internal class solely for encapsulating the various macaroons configurations +// This class should be constructed at configuration time; it is subsequently constant. +class XrdMacaroonsConfigFactory { +public: + static const XrdMacaroonsConfig &Get(XrdSysError &log); + +private: + XrdMacaroonsConfigFactory(); + + // Static configuration method; made static to allow Authz and Handler object to reuse + // this code. + static bool Config(XrdSysError &log); + + static bool xsecretkey(XrdOucGatherConf &Config, XrdSysError &log, std::string &secret); + static bool xsitename(XrdOucGatherConf &Config, XrdSysError &log, std::string &location); + static bool xtrace(XrdOucGatherConf &Config, XrdSysError &log); + static bool xmaxduration(XrdOucGatherConf &Config, XrdSysError &log, ssize_t &max_duration); + + static bool m_configured; + static XrdMacaroonsConfig m_config; +}; +} diff --git a/src/XrdOfs/XrdOfs.cc b/src/XrdOfs/XrdOfs.cc index c04efda01ec..50eff4ec7fe 100644 --- a/src/XrdOfs/XrdOfs.cc +++ b/src/XrdOfs/XrdOfs.cc @@ -225,6 +225,7 @@ XrdOfs::XrdOfs() : dMask{0000,0775}, fMask{0000,0775}, // Legacy DirRdr = false; reProxy = false; OssHasPGrw= false; + tryXERT = false; } /******************************************************************************/ @@ -285,11 +286,19 @@ int XrdOfsDirectory::open(const char *dir_path, // In {fname = strdup(dir_path); return SFS_OK; } - else {delete dp; dp = 0;} + +// Handle extended error information +// + std::string eText; + const char* etP = 0; + if (dp && XrdOfsFS->tryXERT) + {if (dp->getErrMsg(eText)) etP = eText.c_str(); + delete dp; dp = 0; + } // Encountered an error // - return XrdOfsFS->Emsg(epname, error, retc, "open directory", dir_path); + return XrdOfsFS->Emsg(epname, error, retc, "open directory", dir_path, etP); } /******************************************************************************/ @@ -333,7 +342,10 @@ const char *XrdOfsDirectory::nextEntry() // Read the next directory entry // if ((retc = dp->Readdir(dname, sizeof(dname))) < 0) - {XrdOfsFS->Emsg(epname, error, retc, "read directory", fname); + {std::string eText; + const char* etP = 0; + if (XrdOfsFS->tryXERT && dp->getErrMsg(eText)) etP = eText.c_str(); + XrdOfsFS->Emsg(epname, error, retc, "read directory", fname, etP); return 0; } @@ -383,8 +395,11 @@ int XrdOfsDirectory::close() // Close this directory // if ((retc = dp->Close())) - retc = XrdOfsFS->Emsg(epname, error, retc, "close", fname); - else retc = SFS_OK; + {std::string eText; + const char* etP = 0; + if (XrdOfsFS->tryXERT && dp->getErrMsg(eText)) etP = eText.c_str(); + retc = XrdOfsFS->Emsg(epname, error, retc, "close", fname, etP); + } else retc = SFS_OK; // All done // @@ -582,7 +597,8 @@ int XrdOfsFile::open(const char *path, // In // Preset TPC handling and if not allowed, complain // if (tpcKey && (open_mode & SFS_O_NOTPC)) - return XrdOfsFS->Emsg(epname, error, EPROTOTYPE, "tpc", path); + return XrdOfsFS->Emsg(epname, error, EPROTOTYPE, "tpc", path, + "+TPC prohibited due to security configuration"); // Create the file if so requested o/w try to attach the file // @@ -618,7 +634,8 @@ int XrdOfsFile::open(const char *path, // In if (isPosc) {bool isNew = (open_mode & SFS_O_TRUNC) == 0; if ((oP.poscNum = XrdOfsFS->poscQ->Add(tident, path, isNew)) < 0) - return XrdOfsFS->Emsg(epname, error, oP.poscNum, "pcreate", path); + return XrdOfsFS->Emsg(epname, error, oP.poscNum, "pcreate", path, + "+ofs_open: failed to enter file into posc queue"); } // Create the file. If ENOTSUP is returned, promote the creation to @@ -676,7 +693,8 @@ int XrdOfsFile::open(const char *path, // In if (tpcKey && isRW) {char pfnbuff[MAXPATHLEN+8]; const char *pfnP; if (!(pfnP = XrdOfsOss->Lfn2Pfn(path, pfnbuff, MAXPATHLEN, retc))) - return XrdOfsFS->Emsg(epname, error, retc, "open", path); + return XrdOfsFS->Emsg(epname, error, retc, "open", path, + "+ofs_open: mapping tpc target lfn to pfn failed"); XrdOfsTPC::Facts Args(client, &error, &Open_Env, tpcKey, path, pfnP); if ((retc = XrdOfsTPC::Validate(&myTPC, Args))) return retc; } @@ -688,7 +706,8 @@ int XrdOfsFile::open(const char *path, // In {if (!isRW) return XrdOfsFS->Stall(error, -1, path); if ((retc = oP.hP->PoscSet(tident, oP.poscNum, theMode))) {if (retc > 0) XrdOfsFS->poscQ->Del(path, retc); - else return XrdOfsFS->Emsg(epname, error, retc, "access", path); + else return XrdOfsFS->Emsg(epname, error, retc, "access", path, + "+ofs_open: posc mode initiation failed"); } } @@ -699,7 +718,8 @@ int XrdOfsFile::open(const char *path, // In if (!(oP.hP->Inactive())) {dorawio = (oh->isCompressed && open_mode & SFS_O_RAWIO ? 1 : 0); if (tpcKey && isRW) - return XrdOfsFS->Emsg(epname, error, EALREADY, "tpc", path); + return XrdOfsFS->Emsg(epname, error, EALREADY, "tpc", path, + "+ofs_open: this tpc is already in progress"); XrdOfsFS->ocMutex.Lock(); oh = oP.hP; XrdOfsFS->ocMutex.UnLock(); FTRACE(open, "attach use=" <Usage()); if (oP.poscNum > 0) XrdOfsFS->poscQ->Commit(path, oP.poscNum); @@ -740,14 +760,18 @@ int XrdOfsFile::open(const char *path, // In } if (XrdOfsFS->Balancer && retc == -ENOENT) XrdOfsFS->Balancer->Removed(path); - return XrdOfsFS->Emsg(epname, error, retc, "open", path); + const char* etP = 0; + std::string eText; + if (XrdOfsFS->tryXERT && oP.fP->getErrMsg(eText)) etP = eText.c_str(); + return XrdOfsFS->Emsg(epname, error, retc, "open", path, etP); } // Verify that we can actually use this file // if (oP.poscNum > 0) {if ((retc = oP.fP->Fchmod(static_cast(theMode|XRDSFS_POSCPEND)))) - return XrdOfsFS->Emsg(epname, error, retc, "fchmod", path); + return XrdOfsFS->Emsg(epname, error, retc, "fchmod", path, + "+ofs_open: POSC file designation failed"); XrdOfsFS->poscQ->Commit(path, oP.poscNum); } @@ -768,7 +792,7 @@ int XrdOfsFile::open(const char *path, // In int theFD = oP.fP->getFD(); if (theFD >= 0 && fadFails < 4096) if (posix_fadvise(theFD, 0, 0, POSIX_FADV_SEQUENTIAL) < 0) - {OfsEroute.Emsg(epname, errno, "fadsize for sequential I/O."); + {OfsEroute.Emsg(epname, errno, "fadvise for sequential I/O."); fadFails++; } } @@ -1011,13 +1035,15 @@ int XrdOfsFile::CreateCKP() // Verify that this file is open r/w mode // if (!(oh->isRW)) return XrdOfsFS->Emsg("CreateCKP", error, ENOTTY, - "create checkpoint for R/O", oh->Name()); + "create checkpoint for R/O", oh->Name(), + "+ofs_CreateCKP: file is not open in r/w mode"); // POSC and checkpoints are mutally exclusive // if (oh->isRW == XrdOfsHandle::opPC) return XrdOfsFS->Emsg("CreateCKP", error, ENOTTY, - "create checkpoint for POSC file", oh->Name()); + "create checkpoint for POSC file", oh->Name(), + "+ofs_CreateCKP: POSC file cannot be checkpointed"); // Get a new checkpoint object // @@ -1130,7 +1156,7 @@ XrdSfsXferSize XrdOfsFile::pgRead(XrdSfsFileOffset offset, nbytes = (XrdSfsXferSize)(oh->Select().pgRead((void *)buffer, (off_t)offset, (size_t)rdlen, csvec, pgOpts)); if (nbytes < 0) - return XrdOfsFS->Emsg(epname, error, (int)nbytes, "pgRead", oh->Name()); + return XrdOfsFS->Emsg(epname,error,(int)nbytes,"pgRead",oh,false,false); // Return number of bytes read // @@ -1163,7 +1189,7 @@ XrdSfsXferSize XrdOfsFile::pgRead(XrdSfsAio *aioparm, uint64_t opts) // #if _FILE_OFFSET_BITS!=64 if (aiop->sfsAio.aio_offset > 0x000000007fffffff) - return XrdOfsFS->Emsg(epname, error, EFBIG, "pgRead", oh->Name()); + return XrdOfsFS->Emsg(epname,error,-EFBIG,"pgRead",oh->Name(),0,false); #endif // Pass through any flags of interest @@ -1174,7 +1200,7 @@ XrdSfsXferSize XrdOfsFile::pgRead(XrdSfsAio *aioparm, uint64_t opts) // Issue the read. Only true errors are returned here. // if ((rc = oh->Select().pgRead(aioparm, pgOpts)) < 0) - return XrdOfsFS->Emsg(epname, error, rc, "pgRead", oh->Name()); + return XrdOfsFS->Emsg(epname, error, rc, "pgRead", oh, false, false); // All done // @@ -1211,7 +1237,7 @@ XrdSfsXferSize XrdOfsFile::pgWrite(XrdSfsFileOffset offset, // #if _FILE_OFFSET_BITS!=64 if (offset > 0x000000007fffffff) - return XrdOfsFS->Emsg(epname, error, EFBIG, "pgwrite", oh); + return XrdOfsFS->Emsg(epname, error, -EFBIG, "pgwrite", oh, true, false); #endif // Silly Castor stuff @@ -1230,7 +1256,7 @@ XrdSfsXferSize XrdOfsFile::pgWrite(XrdSfsFileOffset offset, nbytes = (XrdSfsXferSize)(oh->Select().pgWrite((void *)buffer, (off_t)offset, (size_t)wrlen, csvec, pgOpts)); if (nbytes < 0) - return XrdOfsFS->Emsg(epname, error, (int)nbytes, "pgwrite", oh); + return XrdOfsFS->Emsg(epname,error,(int)nbytes,"pgwrite",oh,true,false); // Return number of bytes written // @@ -1276,7 +1302,7 @@ XrdSfsXferSize XrdOfsFile::pgWrite(XrdSfsAio *aioparm, uint64_t opts) // #if _FILE_OFFSET_BITS!=64 if (aiop->sfsAio.aio_offset > 0x000000007fffffff) - return XrdOfsFS->Emsg(epname, error, EFBIG, "pgwrite", oh->Name()); + return XrdOfsFS->Emsg(epname, error, -EFBIG, "pgwrite", oh, true, false); #endif // Silly Castor stuff @@ -1293,7 +1319,7 @@ XrdSfsXferSize XrdOfsFile::pgWrite(XrdSfsAio *aioparm, uint64_t opts) // oh->isPending = 1; if ((rc = oh->Select().pgWrite(aioparm, pgOpts)) < 0) - return XrdOfsFS->Emsg(epname, error, rc, "pgwrite", oh->Name()); + return XrdOfsFS->Emsg(epname, error, rc, "pgwrite", oh, true, false); // All done // @@ -1326,13 +1352,13 @@ int XrdOfsFile::read(XrdSfsFileOffset offset, // In // #if _FILE_OFFSET_BITS!=64 if (offset > 0x000000007fffffff) - return XrdOfsFS->Emsg(epname, error, EFBIG, "read", oh->Name()); + return XrdOfsFS->Emsg(epname,error,-EFBIG,"read",oh->Name(),0,false); #endif // Now preread the actual number of bytes // if ((retc = oh->Select().Read((off_t)offset, (size_t)blen)) < 0) - return XrdOfsFS->Emsg(epname, error, (int)retc, "preread", oh->Name()); + return XrdOfsFS->Emsg(epname, error, (int)retc, "preread", oh, 0, false); // Return number of bytes read // @@ -1369,7 +1395,7 @@ XrdSfsXferSize XrdOfsFile::read(XrdSfsFileOffset offset, // In // #if _FILE_OFFSET_BITS!=64 if (offset > 0x000000007fffffff) - return XrdOfsFS->Emsg(epname, error, EFBIG, "read", oh->Name()); + return XrdOfsFS->Emsg(epname,error,-EFBIG,"read",oh->Name(),0,false); #endif // Now read the actual number of bytes @@ -1380,7 +1406,7 @@ XrdSfsXferSize XrdOfsFile::read(XrdSfsFileOffset offset, // In : (XrdSfsXferSize)(oh->Select().Read((void *)buff, (off_t)offset, (size_t)blen))); if (nbytes < 0) - return XrdOfsFS->Emsg(epname, error, (int)nbytes, "read", oh->Name()); + return XrdOfsFS->Emsg(epname, error, (int)nbytes, "read", oh, 0, false); // Return number of bytes read // @@ -1410,7 +1436,7 @@ XrdSfsXferSize XrdOfsFile::readv(XrdOucIOVec *readV, // In XrdSfsXferSize nbytes = oh->Select().ReadV(readV, readCount); if (nbytes < 0) - return XrdOfsFS->Emsg(epname, error, (int)nbytes, "readv", oh->Name()); + return XrdOfsFS->Emsg(epname,error,(int)nbytes,"readv",oh,false,false); return nbytes; @@ -1452,13 +1478,13 @@ int XrdOfsFile::read(XrdSfsAio *aiop) // #if _FILE_OFFSET_BITS!=64 if (aiop->sfsAio.aio_offset > 0x000000007fffffff) - return XrdOfsFS->Emsg(epname, error, EFBIG, "read", oh->Name()); + return XrdOfsFS->Emsg(epname,error,-EFBIG,"read",oh->Name(),0,false); #endif // Issue the read. Only true errors are returned here. // if ((rc = oh->Select().Read(aiop)) < 0) - return XrdOfsFS->Emsg(epname, error, rc, "read", oh->Name()); + return XrdOfsFS->Emsg(epname, error, rc, "read", oh, false, false); // All done // @@ -1498,7 +1524,7 @@ XrdSfsXferSize XrdOfsFile::write(XrdSfsFileOffset offset, // In // #if _FILE_OFFSET_BITS!=64 if (offset > 0x000000007fffffff) - return XrdOfsFS->Emsg(epname, error, EFBIG, "write", oh); + return XrdOfsFS->Emsg(epname,error,-EFBIG,"write",oh,true,false); #endif // Silly Castor stuff @@ -1512,7 +1538,7 @@ XrdSfsXferSize XrdOfsFile::write(XrdSfsFileOffset offset, // In nbytes = (XrdSfsXferSize)(oh->Select().Write((const void *)buff, (off_t)offset, (size_t)blen)); if (nbytes < 0) - return XrdOfsFS->Emsg(epname, error, (int)nbytes, "write", oh); + return XrdOfsFS->Emsg(epname,error,(int)nbytes,"write",oh,true,false); // Return number of bytes written // @@ -1549,7 +1575,7 @@ int XrdOfsFile::write(XrdSfsAio *aiop) // #if _FILE_OFFSET_BITS!=64 if (aiop->sfsAio.aio_offset > 0x000000007fffffff) - return XrdOfsFS->Emsg(epname, error, EFBIG, "write", oh->Name()); + return XrdOfsFS->Emsg(epname, error, -EFBIG, "write", oh, true, false); #endif // Silly Castor stuff @@ -1561,7 +1587,7 @@ int XrdOfsFile::write(XrdSfsAio *aiop) // oh->isPending = 1; if ((rc = oh->Select().Write(aiop)) < 0) - return XrdOfsFS->Emsg(epname, error, rc, "write", oh->Name()); + return XrdOfsFS->Emsg(epname, error, rc, "write", oh, true, false); // All done // @@ -1612,7 +1638,7 @@ int XrdOfsFile::stat(struct stat *buf) // Out // Perform the function // if ((retc = oh->Select().Fstat(buf)) < 0) - return XrdOfsFS->Emsg(epname,error,retc,"get state for",oh->Name()); + return XrdOfsFS->Emsg(epname,error,retc,"get state for",oh); return SFS_OK; } @@ -1657,7 +1683,7 @@ int XrdOfsFile::sync() // In // if ((retc = oh->Select().Fsync())) {oh->isPending = 1; - return XrdOfsFS->Emsg(epname, error, retc, "synchronize", oh); + return XrdOfsFS->Emsg(epname, error, retc, "synchronize", oh, true); } // Indicate all went well @@ -1707,7 +1733,7 @@ int XrdOfsFile::truncate(XrdSfsFileOffset flen) // In // Make sure the offset is not too large // if (sizeof(off_t) < sizeof(flen) && flen > 0x000000007fffffff) - return XrdOfsFS->Emsg(epname, error, EFBIG, "truncate", oh); + return XrdOfsFS->Emsg(epname, error, EFBIG, "truncate", oh, true); // Silly Castor stuff // @@ -1718,7 +1744,7 @@ int XrdOfsFile::truncate(XrdSfsFileOffset flen) // In // oh->isPending = 1; if ((retc = oh->Select().Ftruncate(flen))) - return XrdOfsFS->Emsg(epname, error, retc, "truncate", oh); + return XrdOfsFS->Emsg(epname, error, retc, "truncate", oh, true); // Indicate Success // @@ -1850,7 +1876,8 @@ int XrdOfs::chksum( csFunc Func, // In // At this point we need to convert the lfn to a pfn // if (CksPfn && !(Path = XrdOfsOss->Lfn2Pfn(Path, buff, MAXPATHLEN, rc))) - return Emsg(epname, einfo, rc, "checksum", Path); + return Emsg(epname, einfo, rc, "checksum", Path, + "+ofs_chksum: lfn to pfn mapping failed"); // Originally we only passed he env pointer for proxy servers. Due to popular // demand, we always pass the env as it points to the SecEntity object unless @@ -1884,7 +1911,7 @@ int XrdOfs::chksum( csFunc Func, // In // We failed // - return Emsg(epname, einfo, rc, "checksum", Path); + return Emsg(epname, einfo, rc, "checksum", Path, "?"); } /******************************************************************************/ @@ -1935,7 +1962,7 @@ int XrdOfs::chmod(const char *path, // In // We need to adjust the mode based on whether this is a file or directory. // if ((retc = XrdOfsOss->Stat(path, &Stat, 0, &chmod_Env))) - return XrdOfsFS->Emsg(epname, einfo, retc, "change", path); + return XrdOfsFS->Emsg(epname, einfo, retc, "stat", path, "?"); if (S_ISDIR(Stat.st_mode)) acc_mode = (acc_mode | dMask[0]) & dMask[1]; else acc_mode = (acc_mode | fMask[0]) & fMask[1]; @@ -1952,7 +1979,7 @@ int XrdOfs::chmod(const char *path, // In // An error occurred, return the error info // - return XrdOfsFS->Emsg(epname, einfo, retc, "change", path); + return XrdOfsFS->Emsg(epname, einfo, retc, "chmod", path, "?"); } /******************************************************************************/ @@ -2041,7 +2068,7 @@ int XrdOfs::exists(const char *path, // In // An error occurred, return the error info // - return XrdOfsFS->Emsg(epname, einfo, retc, "locate", path); + return XrdOfsFS->Emsg(epname, einfo, retc, "locate", path, "?"); } /******************************************************************************/ @@ -2118,7 +2145,7 @@ int XrdOfs::mkdir(const char *path, // In // Perform the actual operation // if ((retc = XrdOfsOss->Mkdir(path, acc_mode, mkpath, &mkdir_Env))) - return XrdOfsFS->Emsg(epname, einfo, retc, "mkdir", path); + return XrdOfsFS->Emsg(epname, einfo, retc, "mkdir", path, "?"); // Check if we should generate an event // @@ -2244,7 +2271,7 @@ int XrdOfs::remove(const char type, // In // retc = (type=='d' ? XrdOfsOss->Remdir(path, 0, &rem_Env) : XrdOfsOss->Unlink(path, Opt, &rem_Env)); - if (retc) return XrdOfsFS->Emsg(epname, einfo, retc, "remove", path); + if (retc) return XrdOfsFS->Emsg(epname, einfo, retc, "remove", path, "?"); if (type == 'f') XrdOfsHandle::Hide(path); if (Balancer) Balancer->Removed(path); return SFS_OK; @@ -2346,7 +2373,7 @@ int XrdOfs::rename(const char *old_name, // In // Perform actual rename operation // if ((retc = XrdOfsOss->Rename(old_name, new_name, &old_Env, &new_Env))) - {return XrdOfsFS->Emsg(epname, einfo, retc, "rename", old_name); + {return XrdOfsFS->Emsg(epname, einfo, retc, "rename", old_name, "?"); } XrdOfsHandle::Hide(old_name); if (Balancer) {Balancer->Removed(old_name); @@ -2395,7 +2422,7 @@ int XrdOfs::stat(const char *path, // In // Now try to find the file or directory // if ((retc = XrdOfsOss->Stat(path, buf, 0, &stat_Env))) - return XrdOfsFS->Emsg(epname, einfo, retc, "locate", path); + return XrdOfsFS->Emsg(epname, einfo, retc, "locate", path, "?"); return SFS_OK; } @@ -2444,7 +2471,7 @@ int XrdOfs::stat(const char *path, // In if (!(retc = XrdOfsOss->Stat(path, &buf, XRDOSS_resonly, &stat_Env))) mode=buf.st_mode; else if ((-ENOMSG) != retc) - return XrdOfsFS->Emsg(epname, einfo, retc, "locate", path); + return XrdOfsFS->Emsg(epname, einfo, retc, "locate", path, "?"); return SFS_OK; } @@ -2504,7 +2531,7 @@ int XrdOfs::truncate(const char *path, // In // An error occurred, return the error info // - return XrdOfsFS->Emsg(epname, einfo, retc, "trunc", path); + return XrdOfsFS->Emsg(epname, einfo, retc, "trunc", path, "?"); } /******************************************************************************/ @@ -2515,18 +2542,30 @@ int XrdOfs::Emsg(const char *pfx, // Message prefix value XrdOucErrInfo &einfo, // Place to put text & error code int ecode, // The error code const char *op, // Operation being performed - XrdOfsHandle *hP) // The target handle + XrdOfsHandle *hP, // The target handle + bool posChk, // Unpersist if in posc mode + bool chkType)// Check for type of error & subclass { + const char* etP = 0; int rc; +// Screen out non-errors +// + if (chkType && (rc = EmsgType(ecode)) != SFS_ERROR) return rc; + +// Get any extended information +// + std::string eText; + if (XrdOfsFS->tryXERT && hP->Select().getErrMsg(eText)) etP = eText.c_str(); + // First issue the error message so if we have to unpersist it makes sense // - if ((rc = Emsg(pfx, einfo, ecode, op, hP->Name())) != SFS_ERROR) return rc; + rc = Emsg(pfx, einfo, ecode, op, hP->Name(), etP); // If this is a POSC file then we need to unpersist it. Note that we are always // called with the handle **unlocked** // - if (hP->isRW == XrdOfsHandle::opPC) + if (posChk && hP->isRW == XrdOfsHandle::opPC) {hP->Lock(); XrdOfsFS->Unpersist(hP); hP->UnLock(); @@ -2534,7 +2573,7 @@ int XrdOfs::Emsg(const char *pfx, // Message prefix value // Now return the error // - return SFS_ERROR; + return rc; } /******************************************************************************/ @@ -2543,43 +2582,81 @@ int XrdOfs::Emsg(const char *pfx, // Message prefix value XrdOucErrInfo &einfo, // Place to put text & error code int ecode, // The error code const char *op, // Operation being performed - const char *target) // The target (e.g., fname) + const char *target, // The target (e.g., fname) + const char *xtra, // Optional extra error information + bool chkType)// Check for type of error & subclass { - char buffer[MAXPATHLEN+80]; + char* buffer; + int buflen, rc; + bool msgDone = false; -// If the error is EBUSY then we just need to stall the client. This is -// a hack in order to provide for proxy support +// Screen out non-errors // -// The hack unfotunately is now beinng triggered for reads and writes when -// it was never so before (presumably due to client changes). So do not -// apply the hack for these operations. This gets a better fix in R 6.0 + if (chkType && (rc = EmsgType(ecode)) != SFS_ERROR) return rc; + +// Setup message handling // -if (strcmp("read", op) && strcmp("readv", op) && strcmp("pgRead", op) && - strcmp("write",op) && strcmp("pgwrite",op)) { - if (ecode < 0) ecode = -ecode; - if (ecode == EBUSY) return 5; // A hack for proxy support + if (einfo.extData()) einfo.Reset(); + buffer = einfo.getMsgBuff(buflen); + std::string eText; -// Check for timeout conditions that require a client delay +// Check for extended information // - if (ecode == ETIMEDOUT) return OSSDelay; - } + if (xtra) + switch(*xtra) + {case '?': xtra = 0; + if (XrdOfsFS->tryXERT && XrdOfsOss->getErrMsg(eText)) + {if (eText.find("Unable") != std::string::npos) + {einfo.setErrInfo(ecode, eText.c_str()); + msgDone = true; + } else xtra = eText.c_str(); + } + break; + case '+': xtra++; + break; + default: einfo.setErrInfo(ecode, xtra); + msgDone = true; + break; + } -// Format the error message +// Format the error message if it has not been already set // - XrdOucERoute::Format(buffer, sizeof(buffer), ecode, op, target); + if (!msgDone) + {XrdOucERoute::Format(buffer, buflen, ecode, op, target, xtra); + einfo.setErrCode(ecode); + } -// Print it out if debugging is enabled +// Print it out // -#ifndef NODEBUG OfsEroute.Emsg(pfx, einfo.getErrUser(), buffer); -#endif -// Place the error message in the error object and return +// Return an error // - einfo.setErrInfo(ecode, buffer); return SFS_ERROR; } +/******************************************************************************/ +/* E m s g T y p e */ +/******************************************************************************/ + +int XrdOfs::EmsgType(int ecode) // The error code +{ + +// If the error is EBUSY then we just need to stall the client. This is +// a hack in order to provide for proxy support +// + if (ecode < 0) ecode = -ecode; + if (ecode == EBUSY) return 5; // A hack for proxy support + +// Check for timeout conditions that require a client delay +// + if (ecode == ETIMEDOUT) return OSSDelay; + +// This is a real error +// + return SFS_ERROR; +} + /******************************************************************************/ /* P R I V A T E S E C T I O N */ /******************************************************************************/ diff --git a/src/XrdOfs/XrdOfs.hh b/src/XrdOfs/XrdOfs.hh index 4843ea5e33a..cbffb7873c6 100644 --- a/src/XrdOfs/XrdOfs.hh +++ b/src/XrdOfs/XrdOfs.hh @@ -430,9 +430,10 @@ XrdCmsClient *Finder; // ->Cluster Management Service virtual int ConfigXeq(char *var, XrdOucStream &, XrdSysError &); static int Emsg(const char *, XrdOucErrInfo &, int, const char *x, - XrdOfsHandle *hP); + XrdOfsHandle *hP, bool posChk=false, bool chktype=true); static int Emsg(const char *, XrdOucErrInfo &, int, const char *x, - const char *y=""); + const char *y="", const char* xtra=0, bool chktype=true); +static int EmsgType(int ecode); static int fsError(XrdOucErrInfo &myError, int rc); const char *Split(const char *Args, const char **Opq, char *Path, int Plen); int Stall(XrdOucErrInfo &, int, const char *); @@ -481,6 +482,7 @@ XrdSysMutex ocMutex; // Global mutex for open/close bool DirRdr; // Opendir() can be redirected. bool reProxy; // Reproxying required for TPC bool OssHasPGrw; // True: oss implements full rgRead/Write +bool tryXERT; // Try using extended error text from OSS /******************************************************************************/ /* O t h e r D a t a */ diff --git a/src/XrdOfs/XrdOfsConfig.cc b/src/XrdOfs/XrdOfsConfig.cc index 34131f5977e..1c54c6769e8 100644 --- a/src/XrdOfs/XrdOfsConfig.cc +++ b/src/XrdOfs/XrdOfsConfig.cc @@ -282,6 +282,7 @@ int XrdOfs::Configure(XrdSysError &Eroute, XrdOucEnv *EnvInfo) { if (xrdEnv) xrdEnv->Put("XrdCache", "T"); // Existence check } if (ossFeatures & XRDOSS_HASNAIO) FeatureSet |= XrdSfs::hasNAIO; + if (ossFeatures & XRDOSS_HASXERT) tryXERT = true; if (xrdEnv) xrdEnv->PutPtr("XrdOss*", XrdOfsOss); ofsConfig->Plugin(Cks); CksPfn = !ofsConfig->OssCks(); diff --git a/src/XrdOss/XrdOss.hh b/src/XrdOss/XrdOss.hh index 8207dcc1391..7b63420d726 100644 --- a/src/XrdOss/XrdOss.hh +++ b/src/XrdOss/XrdOss.hh @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -417,6 +418,21 @@ static const int Fctl_utimes = 1; virtual int Fctl(int cmd, int alen, const char *args, char **resp=0); +//----------------------------------------------------------------------------- +//! Obtain detailed error message text for the immediately preceeding +//! directory or file error (see also XrdOss::getErrMsg()). +//! +//! @param eText - Where the message text is to be returned. +//! +//! @return True if message text is available, false otherwise. +//! +//! @note This method should be called using the same thread that encountered +//! the error; otherwise, missleading error text may be returned. +//! @note Upon return, the internal error message text is cleared. +//----------------------------------------------------------------------------- + +virtual bool getErrMsg(std::string& eText) {return false;} + //----------------------------------------------------------------------------- //! Return the underlying file descriptor. //! @@ -598,6 +614,21 @@ virtual uint64_t Features(); virtual int FSctl(int cmd, int alen, const char *args, char **resp=0); +//----------------------------------------------------------------------------- +//! Obtain detailed error message text for the immediately preceeding error +//! returned by any method in this class. +//! +//! @param eText - Where the message text is to be returned. +//! +//! @return True if message text is available, false otherwise. +//! +//! @note This method should be called using the same thread that encountered +//! the error; otherwise, missleading error text may be returned. +//! @note Upon return, the internal error message text is cleared. +//----------------------------------------------------------------------------- + +virtual bool getErrMsg(std::string& eText) {return false;} + //----------------------------------------------------------------------------- //! Initialize the storage system V1 (deprecated). //! diff --git a/src/XrdOss/XrdOssWrapper.hh b/src/XrdOss/XrdOssWrapper.hh index 8658271293f..c3570fef88a 100644 --- a/src/XrdOss/XrdOssWrapper.hh +++ b/src/XrdOss/XrdOssWrapper.hh @@ -404,6 +404,21 @@ uint16_t DFType() {return wrapDF.DFType();} virtual int Fctl(int cmd, int alen, const char *args, char **resp=0) {return wrapDF.Fctl(cmd, alen, args, resp);} +//----------------------------------------------------------------------------- +//! Obtain detailed error message text for the immediately preceeding +//! directory or file error (see also XrdOssWrapper::getErrMsg()). +//! +//! @param eText - Where the message text is to be returned. +//! +//! @return True if message text is available, false otherwise. +//! +//! @note This method should be called using the same thread that encountered +//! the error; otherwise, missleading error text may be returned. +//! @note Upon return, the internal error message text is cleared. +//----------------------------------------------------------------------------- + +virtual bool getErrMsg(std::string& eText) {return wrapDF.getErrMsg(eText);} + //----------------------------------------------------------------------------- //! Return the underlying file descriptor. //! @@ -535,6 +550,22 @@ virtual void EnvInfo(XrdOucEnv *envP) {wrapPI.EnvInfo(envP);} virtual uint64_t Features() {return wrapPI.Features();} +//----------------------------------------------------------------------------- +//! Obtain detailed error message text for the immediately preceeding error +//! returned by any method in this class. +//! +//! @param eText - Where the message text is to be returned. +//! +//! @return True if message text is available, false otherwise. +//! +//! @note This method should be called using the same thread that encountered +//! the error; otherwise, missleading error text may be returned. +//! @note Upon return, the internal error message text is cleared. +//----------------------------------------------------------------------------- + +virtual bool getErrMsg(std::string& eText) + {return wrapPI.getErrMsg(eText);} + //----------------------------------------------------------------------------- //! Execute a special storage system operation. //! diff --git a/src/XrdOuc/XrdOucECMsg.hh b/src/XrdOuc/XrdOucECMsg.hh index e05da5dfc3e..b773e3a8c32 100644 --- a/src/XrdOuc/XrdOucECMsg.hh +++ b/src/XrdOuc/XrdOucECMsg.hh @@ -62,6 +62,7 @@ XrdOucECMsg& Append(char dlm='\n') //----------------------------------------------------------------------------- int Get(std::string& ecm, bool rst=true); +int Get() {return eCode;} //----------------------------------------------------------------------------- //! Determine if an error text message exists. diff --git a/src/XrdOuc/XrdOucERoute.cc b/src/XrdOuc/XrdOucERoute.cc index 3c2af9a59c0..93f10f03c10 100644 --- a/src/XrdOuc/XrdOucERoute.cc +++ b/src/XrdOuc/XrdOucERoute.cc @@ -42,9 +42,11 @@ /******************************************************************************/ int XrdOucERoute::Format(char *buff, int blen, int ecode, const char *etxt1, - const char *etxt2) + const char *etxt2, + const char *xtra) { const char *esep = " ", *estr = XrdSysError::ec2text(ecode); + const char *xsep = ""; char ebuff[256]; int n; @@ -60,10 +62,13 @@ int XrdOucERoute::Format(char *buff, int blen, int ecode, const char *etxt1, // Set format elements // if (!etxt2) etxt2 = esep = ""; + if (xtra) xsep = "\nAdditional context: "; + else xtra = ""; // Format the message // - n = snprintf(buff, blen, "Unable to %s%s%s; %s",etxt1,esep,etxt2,estr); + n = snprintf(buff, blen, "Unable to %s%s%s; %s%s%s",etxt1,esep,etxt2,estr, + xsep, xtra); return (n < blen ? n : blen-1); } diff --git a/src/XrdOuc/XrdOucERoute.hh b/src/XrdOuc/XrdOucERoute.hh index 5aeeec95bc5..8b2ef1c491b 100644 --- a/src/XrdOuc/XrdOucERoute.hh +++ b/src/XrdOuc/XrdOucERoute.hh @@ -46,12 +46,14 @@ public: //! @param ecode the error number associated iwth the error. //! @param etxt1 associated text token #1. //! @param etxt2 associated text token #2 (optional). +//! @param xtra Optional additional text to include on the next line //! //! @return The number of characters placed in the buffer less null. //----------------------------------------------------------------------------- static int Format(char *buff, int blen, int ecode, const char *etxt1, - const char *etxt2=0); + const char *etxt2=0, + const char *xtra =0); //----------------------------------------------------------------------------- //! Format an error message using Format() and route it as requested. diff --git a/src/XrdPosix/XrdPosixConfig.cc b/src/XrdPosix/XrdPosixConfig.cc index ca3821e46d0..7d0b92f2ccf 100644 --- a/src/XrdPosix/XrdPosixConfig.cc +++ b/src/XrdPosix/XrdPosixConfig.cc @@ -528,6 +528,15 @@ void XrdPosixConfig::SetEnv(const char *kword, int kval) else env->PutInt((std::string)kword, kval); } +/******************************************************************************/ + +void XrdPosixConfig::SetEnv(const char *kword, void* ptr) +{ + XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv(); + + env->PutPtr((std::string)kword, ptr); +} + /******************************************************************************/ /* Private: S e t I P V 4 */ /******************************************************************************/ diff --git a/src/XrdPosix/XrdPosixConfig.hh b/src/XrdPosix/XrdPosixConfig.hh index 66f408566ac..7fe0f622209 100644 --- a/src/XrdPosix/XrdPosixConfig.hh +++ b/src/XrdPosix/XrdPosixConfig.hh @@ -61,6 +61,8 @@ static bool OpenFC(const char *path, int oflag, mode_t mode, static void SetEnv(const char *kword, int kval); +static void SetEnv(const char *kword, void* ptr); + static void setOids(bool isok); static int Stats(const char *theID, char *buff, int blen); diff --git a/src/XrdPss/XrdPss.cc b/src/XrdPss/XrdPss.cc index c5d1a085eb8..0d1e3c5d12b 100644 --- a/src/XrdPss/XrdPss.cc +++ b/src/XrdPss/XrdPss.cc @@ -164,7 +164,8 @@ XrdOss *XrdOssGetStorageSystem2(XrdOss *native_oss, XrdPssSys::XrdPssSys() : HostArena(0), LocalRoot(0), theN2N(0), DirFlags(0), myVersion(&XrdVERSIONINFOVAR(XrdOssGetStorageSystem2)), - myFeatures(XRDOSS_HASPRXY|XRDOSS_HASPGRW|XRDOSS_HASNOSF) + myFeatures(XRDOSS_HASPRXY|XRDOSS_HASPGRW| + XRDOSS_HASNOSF|XRDOSS_HASXERT) {} /******************************************************************************/ @@ -311,6 +312,19 @@ void XrdPssSys::EnvInfo(XrdOucEnv *envP) } } +/******************************************************************************/ +/* g e t E r r M s g */ +/******************************************************************************/ + +bool XrdPssSys::getErrMsg(std::string& eText) +{ +// Return what we have but make sure to reset whatever we have +// + if (XrdProxy::ecMsg.Get() <= 0 || !XrdProxy::ecMsg.hasMsg()) return false; + XrdProxy::ecMsg.Get(eText); + return true; +} + /******************************************************************************/ /* L f n 2 P f n */ /******************************************************************************/ @@ -417,7 +431,7 @@ int XrdPssSys::Remdir(const char *path, int Opts, XrdOucEnv *eP) } // Issue unlink and return result // - return (XrdPosixXrootd::Rmdir(pbuff) ? -errno : XrdOssOK); + return (XrdPosixXrootd::Rmdir(pbuff) ? Info(errno) : XrdOssOK); } /******************************************************************************/ @@ -466,7 +480,7 @@ int XrdPssSys::Rename(const char *oldname, const char *newname, // Execute the rename and return result // - return (XrdPosixXrootd::Rename(oldName, newName) ? -errno : XrdOssOK); + return (XrdPosixXrootd::Rename(oldName, newName) ? Info(errno) : XrdOssOK); } /******************************************************************************/ @@ -522,7 +536,7 @@ int XrdPssSys::Stat(const char *path, struct stat *buff, int Opts, XrdOucEnv *eP // Return proxied stat // - return (XrdPosixXrootd::Stat(pbuff, buff) ? -errno : XrdOssOK); + return (XrdPosixXrootd::Stat(pbuff, buff) ? Info(errno) : XrdOssOK); } /******************************************************************************/ @@ -582,7 +596,7 @@ int XrdPssSys::Truncate(const char *path, unsigned long long flen, // Return proxied truncate. We only do this on a single machine because the // redirector will forbid the trunc() if multiple copies exist. // - return (XrdPosixXrootd::Truncate(pbuff, flen) ? -errno : XrdOssOK); + return (XrdPosixXrootd::Truncate(pbuff, flen) ? Info(errno) : XrdOssOK); } /******************************************************************************/ @@ -629,7 +643,7 @@ int XrdPssSys::Unlink(const char *path, int Opts, XrdOucEnv *envP) // Unlink the file and return result. // - return (XrdPosixXrootd::Unlink(pbuff) ? -errno : XrdOssOK); + return (XrdPosixXrootd::Unlink(pbuff) ? Info(errno) : XrdOssOK); } /******************************************************************************/ @@ -681,7 +695,11 @@ int XrdPssDir::Opendir(const char *dir_path, XrdOucEnv &Env) // Open the directory // myDir = XrdPosixXrootd::Opendir(pbuff); - if (!myDir) return -errno; + if (!myDir) + {rc = -errno; + lastEtrc = XrdPosixXrootd::QueryError(lastEtext); + return rc; + } return XrdOssOK; } @@ -711,7 +729,10 @@ int XrdPssDir::Readdir(char *buff, int blen) if (myDir) {dirent *entP, myEnt; int rc = XrdPosixXrootd::Readdir_r(myDir, &myEnt, &entP); - if (rc) return -rc; + if (rc) + {lastEtrc = XrdPosixXrootd::QueryError(lastEtext, myDir); + return -rc; + } if (!entP) *buff = 0; else strlcpy(buff, myEnt.d_name, blen); return XrdOssOK; @@ -754,7 +775,11 @@ int XrdPssDir::Close(long long *retsz) // if ((theDir = myDir)) {myDir = 0; - if (XrdPosixXrootd::Closedir(theDir)) return -errno; + if (XrdPosixXrootd::Closedir(theDir)) + {int rc = errno; + lastEtrc = XrdPosixXrootd::QueryError(lastEtext); + return -rc; + } return XrdOssOK; } @@ -762,7 +787,22 @@ int XrdPssDir::Close(long long *retsz) // return -XRDOSS_E8002; } - + +/******************************************************************************/ +/* g e t E r r M s g */ +/******************************************************************************/ + +bool XrdPssDir::getErrMsg(std::string& eText) +{ +// Return what we have but make sure to reset whatever we have +// + if (lastEtrc <= 0 || lastEtext.empty()) return false; + eText = lastEtext; + lastEtext.clear(); + lastEtrc = 0; + return true; +} + /******************************************************************************/ /* o o s s _ F i l e M e t h o d s */ /******************************************************************************/ @@ -888,7 +928,11 @@ int XrdPssFile::Open(const char *path, int Oflag, mode_t Mode, XrdOucEnv &Env) // Try to open and if we failed, return an error // if (!XrdPssSys::dcaCheck || !ioCache) - {if ((fd = XrdPosixXrootd::Open(pbuff,Oflag,Mode)) < 0) return -errno; + {if ((fd = XrdPosixXrootd::Open(pbuff,Oflag,Mode)) < 0) + {rc = -errno; + lastEtrc = XrdPosixXrootd::QueryError(lastEtext); + return rc; + } } else { XrdPosixInfo Info; Info.ffReady = XrdPssSys::dcaWorld; @@ -897,7 +941,11 @@ int XrdPssFile::Open(const char *path, int Oflag, mode_t Mode, XrdOucEnv &Env) return -EDESTADDRREQ; } fd = Info.fileFD; - if (fd < 0) return -errno; + if (fd < 0) + {rc = -errno; + lastEtrc = XrdPosixXrootd::QueryError(lastEtext); + return rc; + } } // All done @@ -936,7 +984,25 @@ int XrdPssFile::Close(long long *retsz) // rc = XrdPosixXrootd::Close(fd); fd = -1; - return (rc == 0 ? XrdOssOK : -errno); + if (rc == 0) return XrdOssOK; + rc = -errno; + lastEtrc = XrdPosixXrootd::QueryError(lastEtext); + return rc; +} + +/******************************************************************************/ +/* g e t E r r M s g */ +/******************************************************************************/ + +bool XrdPssFile::getErrMsg(std::string& eText) +{ +// Return what we have but make sure to reset whatever we have +// + if (lastEtrc <= 0 || lastEtext.empty()) return false; + eText = lastEtext; + lastEtext.clear(); + lastEtrc = 0; + return true; } /******************************************************************************/ @@ -978,7 +1044,10 @@ ssize_t XrdPssFile::pgRead(void *buffer, // Issue the pgread // if ((bytes = XrdPosixExtra::pgRead(fd,buffer,offset,rdlen,vecCS,psxOpts)) < 0) - return (ssize_t)-errno; + {int rc = -errno; + lastEtrc = XrdPosixXrootd::QueryError(lastEtext, fd); + return (ssize_t)rc; + } // Copy out the checksum vector // @@ -1029,7 +1098,11 @@ ssize_t XrdPssFile::pgWrite(void *buffer, {XrdOucPgrwUtils::dataInfo dInfo((const char*)buffer,csvec,offset,wrlen); off_t bado; int badc; - if (!XrdOucPgrwUtils::csVer(dInfo, bado, badc)) return -EDOM; + if (!XrdOucPgrwUtils::csVer(dInfo, bado, badc)) + {lastEtext = "pgWrite checksum verification failed."; + lastEtrc = EDOM; + return -EDOM; + } } // Check if caller want checksum generated and possibly returned @@ -1050,7 +1123,12 @@ ssize_t XrdPssFile::pgWrite(void *buffer, // Return result // - return (bytes < 0 ? (ssize_t)-errno : bytes); + if (bytes < 0) + {int rc = -errno; + lastEtrc = XrdPosixXrootd::QueryError(lastEtext, fd); + return (ssize_t)rc; + } + return bytes; } /******************************************************************************/ @@ -1096,8 +1174,12 @@ ssize_t XrdPssFile::Read(void *buff, off_t offset, size_t blen) if (fd < 0) return (ssize_t)-XRDOSS_E8004; - return (retval = XrdPosixXrootd::Pread(fd, buff, blen, offset)) < 0 - ? (ssize_t)-errno : retval; + if ((retval = XrdPosixXrootd::Pread(fd, buff, blen, offset)) < 0) + {int rc = -errno; + lastEtrc = XrdPosixXrootd::QueryError(lastEtext, fd); + return (ssize_t)rc; + } + return retval; } /******************************************************************************/ @@ -1123,7 +1205,12 @@ ssize_t XrdPssFile::ReadV(XrdOucIOVec *readV, // In if (fd < 0) return (ssize_t)-XRDOSS_E8004; - return (retval = XrdPosixXrootd::VRead(fd, readV, readCount)) < 0 ? (ssize_t)-errno : retval;; + if ((retval = XrdPosixXrootd::VRead(fd, readV, readCount)) < 0) + {int rc = -errno; + lastEtrc = XrdPosixXrootd::QueryError(lastEtext, fd); + return (ssize_t)rc; + } + return (ssize_t)retval;; } /******************************************************************************/ @@ -1168,8 +1255,12 @@ ssize_t XrdPssFile::Write(const void *buff, off_t offset, size_t blen) if (fd < 0) return (ssize_t)-XRDOSS_E8004; - return (retval = XrdPosixXrootd::Pwrite(fd, buff, blen, offset)) < 0 - ? (ssize_t)-errno : retval; + if ((retval = XrdPosixXrootd::Pwrite(fd, buff, blen, offset)) < 0) + {int rc = -errno; + lastEtrc = XrdPosixXrootd::QueryError(lastEtext, fd); + return (ssize_t)rc; + } + return (ssize_t)retval; } /******************************************************************************/ @@ -1190,7 +1281,12 @@ int XrdPssFile::Fstat(struct stat *buff) // If we have a file descriptor then return a stat for it // - if (fd >= 0) return (XrdPosixXrootd::Fstat(fd, buff) ? -errno : XrdOssOK); + if (fd >= 0) + {if (XrdPosixXrootd::Fstat(fd, buff) == 0) return XrdOssOK; + int rc = -errno; + lastEtrc = XrdPosixXrootd::QueryError(lastEtext, fd); + return (ssize_t)rc; + } // Otherwise, if this is not a tpc of any kind, return an error // @@ -1274,7 +1370,10 @@ int XrdPssFile::Fsync(void) { if (fd < 0) return -XRDOSS_E8004; - return (XrdPosixXrootd::Fsync(fd) ? -errno : XrdOssOK); + if (XrdPosixXrootd::Fsync(fd) == 0) return XrdOssOK; + int rc = -errno; + lastEtrc = XrdPosixXrootd::QueryError(lastEtext, fd); + return (ssize_t)rc; } /******************************************************************************/ @@ -1303,7 +1402,10 @@ int XrdPssFile::Ftruncate(unsigned long long flen) { if (fd < 0) return -XRDOSS_E8004; - return (XrdPosixXrootd::Ftruncate(fd, flen) ? -errno : XrdOssOK); + if (XrdPosixXrootd::Ftruncate(fd, flen) == 0) return XrdOssOK; + int rc = -errno; + lastEtrc = XrdPosixXrootd::QueryError(lastEtext, fd); + return (ssize_t)rc; } /******************************************************************************/ diff --git a/src/XrdPss/XrdPss.hh b/src/XrdPss/XrdPss.hh index 2ad5f36507e..e5dfeeb03ff 100644 --- a/src/XrdPss/XrdPss.hh +++ b/src/XrdPss/XrdPss.hh @@ -33,6 +33,7 @@ #include #include #include +#include #include #include "XrdSys/XrdSysHeaders.hh" #include "XrdOuc/XrdOucECMsg.hh" @@ -49,25 +50,28 @@ class XrdPssDir : public XrdOssDF { public: -int Close(long long *retsz=0); -int Opendir(const char *, XrdOucEnv &); -int Readdir(char *buff, int blen); +int Close(long long *retsz=0) override; +bool getErrMsg(std::string& eText) override; +int Opendir(const char *, XrdOucEnv &) override; +int Readdir(char *buff, int blen) override; // Store the `buf` pointer in the directory object. Future calls to `Readdir` // will, as a side-effect, fill in the corresponding `stat` information in // the memory referred to from the pointer. // // Returns -errno on failure; otherwise, returns 0 and stashes away the pointer. -int StatRet(struct stat *buf); +int StatRet(struct stat *buf) override; // Constructor and destructor XrdPssDir(const char *tid) : XrdOssDF(tid, XrdOssDF::DF_isDir|XrdOssDF::DF_isProxy), - myDir(0) {} + myDir(0), lastEtrc(0) {} ~XrdPssDir() {if (myDir) Close();} private: DIR *myDir; + std::string lastEtext; + int lastEtrc; }; /******************************************************************************/ @@ -85,32 +89,33 @@ public: // The following two are virtual functions to allow for upcasting derivations // of this implementation // -virtual int Close(long long *retsz=0); -virtual int Open(const char *, int, mode_t, XrdOucEnv &); - -int Fchmod(mode_t mode) {return XrdOssOK;} -int Fstat(struct stat *); -int Fsync(); -int Fsync(XrdSfsAio *aiop); -int Ftruncate(unsigned long long); +virtual int Close(long long *retsz=0) override; +virtual int Open(const char *, int, mode_t, XrdOucEnv &) override; + +int Fchmod(mode_t mode) override {return XrdOssOK;} +int Fstat(struct stat *) override; +int Fsync() override; +int Fsync(XrdSfsAio *aiop) override; +int Ftruncate(unsigned long long) override; +bool getErrMsg(std::string& eText) override; ssize_t pgRead (void* buffer, off_t offset, size_t rdlen, - uint32_t* csvec, uint64_t opts); -int pgRead (XrdSfsAio* aioparm, uint64_t opts); + uint32_t* csvec, uint64_t opts) override; +int pgRead (XrdSfsAio* aioparm, uint64_t opts) override; ssize_t pgWrite(void* buffer, off_t offset, size_t wrlen, - uint32_t* csvec, uint64_t opts); -int pgWrite(XrdSfsAio* aioparm, uint64_t opts); -ssize_t Read( off_t, size_t); -ssize_t Read( void *, off_t, size_t); -int Read(XrdSfsAio *aiop); -ssize_t ReadV(XrdOucIOVec *readV, int n); -ssize_t ReadRaw( void *, off_t, size_t); -ssize_t Write(const void *, off_t, size_t); -int Write(XrdSfsAio *aiop); + uint32_t* csvec, uint64_t opts) override; +int pgWrite(XrdSfsAio* aioparm, uint64_t opts) override; +ssize_t Read( off_t, size_t) override; +ssize_t Read( void *, off_t, size_t) override; +int Read(XrdSfsAio *aiop) override; +ssize_t ReadV(XrdOucIOVec *readV, int n) override; +ssize_t ReadRaw( void *, off_t, size_t) override; +ssize_t Write(const void *, off_t, size_t) override; +int Write(XrdSfsAio *aiop) override; // Constructor and destructor XrdPssFile(const char *tid) : XrdOssDF(tid, XrdOssDF::DF_isFile|XrdOssDF::DF_isProxy), - rpInfo(0), tpcPath(0), entity(0) {} + rpInfo(0), tpcPath(0), entity(0), lastEtrc(0) {} virtual ~XrdPssFile() {if (fd >= 0) Close(); if (rpInfo) delete(rpInfo); @@ -133,6 +138,8 @@ struct tprInfo char *tpcPath; const XrdSecEntity *entity; +std::string lastEtext; +int lastEtrc; }; /******************************************************************************/ @@ -167,6 +174,7 @@ virtual int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0) override; void EnvInfo(XrdOucEnv *envP) override; uint64_t Features() override {return myFeatures;} +bool getErrMsg(std::string& eText) override; int Init(XrdSysLogger *, const char *) override {return -ENOTSUP;} int Init(XrdSysLogger *, const char *, XrdOucEnv *envP) override; int Lfn2Pfn(const char *Path, char *buff, int blen) override; diff --git a/src/XrdPss/XrdPssConfig.cc b/src/XrdPss/XrdPssConfig.cc index 701edb9080a..9b1dd18b17c 100644 --- a/src/XrdPss/XrdPssConfig.cc +++ b/src/XrdPss/XrdPssConfig.cc @@ -166,6 +166,7 @@ int XrdPssSys::Configure(const char *cfn, XrdOucEnv *envP) Output: 0 upon success or !0 otherwise. */ char theRdr[maxHLen]; + void* voidPtr; int NoGo = 0; // Get environmental values @@ -216,6 +217,12 @@ int XrdPssSys::Configure(const char *cfn, XrdOucEnv *envP) return 1; } +// Re-export pfc.gStream* internal envar. Normally, this is used inconjunction +// with a cache but that isn't necessarily true in the future. +// + if ((voidPtr = envP->GetPtr("pfc.gStream*"))) + XrdPosixConfig::SetEnv("pfc.gStream*", voidPtr); + // Check if we should configure authentication security mapping // if (sssMap && !ConfigMapID()) return 1; diff --git a/src/XrdSciTokens/CMakeLists.txt b/src/XrdSciTokens/CMakeLists.txt index df34f4289e1..00bbb6e452a 100644 --- a/src/XrdSciTokens/CMakeLists.txt +++ b/src/XrdSciTokens/CMakeLists.txt @@ -5,8 +5,10 @@ if(NOT ENABLE_SCITOKENS) endif() if(FORCE_ENABLED) + find_package(Macaroons REQUIRED) find_package(SciTokensCpp REQUIRED) else() + find_package(Macaroons) find_package(SciTokensCpp) endif() @@ -21,6 +23,14 @@ set(XrdAccSciTokens XrdAccSciTokens-${PLUGIN_VERSION}) add_library(${XrdAccSciTokens} MODULE XrdSciTokensAccess.cc XrdSciTokensHelper.hh XrdSciTokensMon.cc XrdSciTokensMon.hh + XrdSciTokensRedir.hh + XrdSciTokensHelper.hh + + ../XrdMacaroons/XrdMacaroonsUtils.cc + ../XrdMacaroons/XrdMacaroonsUtils.hh + ../XrdMacaroons/XrdMacaroonsGenerate.cc + ../XrdMacaroons/XrdMacaroonsGenerate.hh + ../XrdMacaroons/XrdMacaroonsConfigure.cc ) target_link_libraries(${XrdAccSciTokens} @@ -39,6 +49,12 @@ target_include_directories(${XrdAccSciTokens} ${SCITOKENS_CPP_INCLUDE_DIR} ) +if(MACAROONS_FOUND) + target_compile_definitions(${XrdAccSciTokens} PRIVATE HAVE_MACAROONS) + target_include_directories(${XrdAccSciTokens} PRIVATE ${MACAROONS_INCLUDES}) + target_link_libraries(${XrdAccSciTokens} PRIVATE uuid::uuid OpenSSL::Crypto ${MACAROONS_LIB}) +endif() + if(HAVE_SCITOKEN_CONFIG_SET_STR) target_compile_definitions(${XrdAccSciTokens} PRIVATE diff --git a/src/XrdSciTokens/XrdSciTokensAccess.cc b/src/XrdSciTokens/XrdSciTokensAccess.cc index f982556a3ec..b55353c8fe6 100644 --- a/src/XrdSciTokens/XrdSciTokensAccess.cc +++ b/src/XrdSciTokens/XrdSciTokensAccess.cc @@ -9,6 +9,7 @@ #include "XrdTls/XrdTlsContext.hh" #include "XrdVersion.hh" +#include #include #include #include @@ -24,9 +25,15 @@ #include "INIReader.h" #include "picojson.h" +#include +#ifdef HAVE_MACAROONS +#include "XrdMacaroons/XrdMacaroonsGenerate.hh" +#endif + #include "scitokens/scitokens.h" #include "XrdSciTokens/XrdSciTokensHelper.hh" #include "XrdSciTokens/XrdSciTokensMon.hh" +#include "XrdSciTokens/XrdSciTokensRedir.hh" // The status-quo to retrieve the default object is to copy/paste the // linker definition and invoke directly. @@ -155,6 +162,19 @@ const std::string OpToName(Access_Operation op) { return "unknown"; } +const std::string OpsToName(std::bitset ops) { + if (ops.none()) {return "none";} + std::string result; + bool first = true; + for (int idx=0; idx(idx)); + first = false; + } + } + return result; +} + std::string AccessRuleStr(const AccessRulesRaw &rules) { std::unordered_map> rule_map; for (const auto &rule : rules) { @@ -352,9 +372,10 @@ class XrdAccRules public: XrdAccRules(uint64_t expiry_time, const std::string &username, const std::string &token_subject, const std::string &issuer, const std::vector &rules, const std::vector &groups, - uint32_t authz_strategy) : + uint32_t authz_strategy, time_t token_expiry) : m_authz_strategy(authz_strategy), m_expiry_time(expiry_time), + m_token_expiry(token_expiry), m_username(username), m_token_subject(token_subject), m_issuer(issuer), @@ -387,6 +408,14 @@ class XrdAccRules return false; } + std::bitset applyAll(std::string path) { + std::bitset result; + for (int idx=0; idx m_expiry_time;} void parse(const AccessRulesRaw &rules) { @@ -433,6 +462,7 @@ class XrdAccRules const std::string & get_token_subject() const {return m_token_subject;} const std::string & get_default_username() const {return m_username;} const std::string & get_issuer() const {return m_issuer;} + time_t get_token_expiration() const {return m_token_expiry;} uint32_t get_authz_strategy() const {return m_authz_strategy;} @@ -442,7 +472,10 @@ class XrdAccRules private: uint32_t m_authz_strategy; AccessRulesRaw m_rules; + // Expiration time of cache entry, relative to the CLOCK_MONOTONIC uint64_t m_expiry_time{0}; + // Expiration time of the token, relative to Unix epoch + time_t m_token_expiry{0}; const std::string m_username; const std::string m_token_subject; const std::string m_issuer; @@ -454,9 +487,10 @@ class XrdAccSciTokens; XrdAccSciTokens *accSciTokens = nullptr; XrdSciTokensHelper *SciTokensHelper = nullptr; +XrdSciTokensRedir *SciTokensRedir = nullptr; class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, - public XrdSciTokensMon + public XrdSciTokensMon, public XrdSciTokensRedir { enum class AuthzBehavior { @@ -478,6 +512,16 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, if (!Config(envP)) { throw std::runtime_error("Failed to configure SciTokens authorization."); } + +#ifdef HAVE_MACAROONS + // TODO: When there's a separate plugin interface for reaching into XrdMacaroons, + // remove the ifdef and try loading the plugin instead + try { + m_generator = std::make_unique(m_log); + } catch (std::runtime_error &exc) { + m_log.Emsg("XrdAccSciTokens", "failed to configure token generator: ", exc.what()); + } +#endif } virtual ~XrdAccSciTokens() { @@ -510,45 +554,9 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, return OnMissing(Entity, path, oper, env); } m_log.Log(LogMask::Debug, "Access", "Trying token-based access control"); - std::shared_ptr access_rules; - uint64_t now = monotonic_time(); - Check(now); - { - std::lock_guard guard(m_mutex); - const auto iter = m_map.find(authz); - if (iter != m_map.end() && !iter->second->expired()) { - access_rules = iter->second; - } - } + auto access_rules = GetRules(authz); if (!access_rules) { - m_log.Log(LogMask::Debug, "Access", "Token not found in recent cache; parsing."); - try { - uint64_t cache_expiry; - AccessRulesRaw rules; - std::string username; - std::string token_subject; - std::string issuer; - std::vector map_rules; - std::vector groups; - uint32_t authz_strategy; - if (GenerateAcls(authz, cache_expiry, rules, username, token_subject, issuer, map_rules, groups, authz_strategy)) { - access_rules.reset(new XrdAccRules(now + cache_expiry, username, token_subject, issuer, map_rules, groups, authz_strategy)); - access_rules->parse(rules); - } else { - m_log.Log(LogMask::Warning, "Access", "Failed to generate ACLs for token"); - return OnMissing(Entity, path, oper, env); - } - if (m_log.getMsgMask() & LogMask::Debug) { - m_log.Log(LogMask::Debug, "Access", "New valid token", access_rules->str().c_str()); - } - } catch (std::exception &exc) { - m_log.Log(LogMask::Warning, "Access", "Error generating ACLs for authorization", exc.what()); - return OnMissing(Entity, path, oper, env); - } - std::lock_guard guard(m_mutex); - m_map[authz] = access_rules; - } else if (m_log.getMsgMask() & LogMask::Debug) { - m_log.Log(LogMask::Debug, "Access", "Cached token", access_rules->str().c_str()); + return OnMissing(Entity, path, oper, env); } // Strategy: assuming the corresponding strategy is enabled, we populate the name in @@ -586,21 +594,12 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, } group_success = true; } + std::bitset opers; + opers[oper] = access_rules->apply(oper, path); + bool scope_success; + std::string username = GetUser(opers, path, access_rules, scope_success); - std::string username; - bool mapping_success = false; - bool scope_success = false; - username = access_rules->get_username(path); - - mapping_success = (access_rules->get_authz_strategy() & IssuerAuthz::Mapping) && !username.empty(); - scope_success = (access_rules->get_authz_strategy() & IssuerAuthz::Capability) && access_rules->apply(oper, path); - if (scope_success && (m_log.getMsgMask() & LogMask::Debug)) { - std::stringstream ss; - ss << "Grant authorization based on scopes for operation=" << OpToName(oper) << ", path=" << path; - m_log.Log(LogMask::Debug, "Access", ss.str().c_str()); - } - - if (!scope_success && !mapping_success && !group_success) { + if (username.empty() && !scope_success && !group_success) { auto returned_accs = OnMissing(&new_secentity, path, oper, env); // Clean up the new_secentity if (new_secentity.vorg != nullptr) free(new_secentity.vorg); @@ -610,14 +609,9 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, return returned_accs; } - // Default user only applies to scope-based mappings. - if (scope_success && username.empty()) { - username = access_rules->get_default_username(); - } - // Setting the request.name will pass the username to the next plugin. // Ensure we do that only if map-based or scope-based authorization worked. - if (scope_success || mapping_success) { + if (!username.empty()) { // Set scitokens.name in the extra attribute Entity->eaAPI->Add("request.name", username, true); new_secentity.eaAPI->Add("request.name", username, true); @@ -651,6 +645,90 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, return returned_op; } + virtual std::string Redirect(const char *url) override { + // No generator has been configured; do not log the skipped redirector override. + if (!m_generator) { + return ""; + } + + if (!url) { + m_log.Log(LogMask::Debug, "Redirect", "Null URL"); + return ""; + } + m_log.Log(LogMask::Debug, "Redirect", "Will parse redirect URL", url); + auto hostStart = strstr(url, "://"); + if (!hostStart) { + m_log.Log(LogMask::Info, "Redirect", "No host block found in URL", url); + return ""; + } + auto pathStart = strchr(hostStart + 3, '/'); + if (!pathStart) { + m_log.Log(LogMask::Debug, "Redirect", "No path found in URL", url); + return ""; + } + + auto queryStart = strchr(pathStart, '?'); + if (!queryStart) { + m_log.Log(LogMask::Debug, "Redirect", "No query string found in URL", url); + return ""; + } + + auto authzStart = strstr(queryStart + 1, "authz="); + if (!authzStart) { + m_log.Log(LogMask::Debug, "Redirect", "No authz argument found in URL", url); + return ""; + } + auto authzEnd = strchr(authzStart, '&'); + std::string authz; + if (authzEnd) { + authz = std::string(authzStart + 6, authzEnd - authzStart); + } else { + authz = std::string(authzStart + 6); + } + if (!strncmp(authz.c_str(), "Bearer%20", 9)) { + authz = authz.substr(9); + } + + std::string path(pathStart, queryStart - pathStart); + + auto rules = GetRules(authz); + if (!rules) { + m_log.Log(LogMask::Warning, "Redirect", "Failed to generate rules for token"); + return ""; + } + + auto opers = rules->applyAll(path); + if (!opers.any()) { + m_log.Log(LogMask::Warning, "Redirect", "Token does not authorize any operations"); + return ""; + } + + bool scope_success; + auto user = GetUser(opers, path, rules, scope_success); + + auto expiry = rules->get_token_expiration(); + auto now = time(NULL); + expiry = std::min(now + 10, expiry); + + uuid_t uu; + uuid_generate_random(uu); + char uuid_buf[37]; + uuid_unparse(uu, uuid_buf); + + std::vector other_caveats; + auto macaroon_encoded = m_generator->Generate(uuid_buf, user, path, opers, expiry, other_caveats); + if (macaroon_encoded.empty()) { + return ""; + } + + std::string urlPrefix(url, authzStart + 6 - url); + auto result = urlPrefix + macaroon_encoded; + if (authzEnd) { + result += std::string(authzEnd); + } + return result; + } + virtual Issuers IssuerList() override { /* @@ -753,7 +831,7 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, return XrdAccPriv_None; } - bool GenerateAcls(const std::string &authz, uint64_t &cache_expiry, AccessRulesRaw &rules, std::string &username, std::string &token_subject, std::string &issuer, std::vector &map_rules, std::vector &groups, uint32_t &authz_strategy) { + bool GenerateAcls(const std::string &authz, uint64_t &cache_lifetime, AccessRulesRaw &rules, std::string &username, std::string &token_subject, std::string &issuer, std::vector &map_rules, std::vector &groups, uint32_t &authz_strategy, time_t &token_expiry) { // Does this look like a JWT? If not, bail out early and // do not pollute the log. bool looks_good = true; @@ -792,6 +870,7 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, return false; } + long long lifetime; long long expiry; if (scitoken_get_expiration(token, &expiry, &err_msg)) { m_log.Log(LogMask::Warning, "GenerateAcls", "Unable to determine token expiration:", err_msg); @@ -800,10 +879,10 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, return false; } if (expiry > 0) { - expiry = std::max(static_cast(monotonic_time() - expiry), - static_cast(60)); + lifetime = std::max(expiry - time(nullptr), static_cast(60)); } else { - expiry = 60; + expiry = time(nullptr) + 60; + lifetime = 60; } char *value = nullptr; @@ -978,6 +1057,7 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, xrd_rules.emplace_back(AOP_Mkdir, write_path); xrd_rules.emplace_back(AOP_Rename, write_path); xrd_rules.emplace_back(AOP_Insert, write_path); + xrd_rules.emplace_back(AOP_Stat, write_path); xrd_rules.emplace_back(AOP_Update, write_path); xrd_rules.emplace_back(AOP_Stat, write_path); xrd_rules.emplace_back(AOP_Chmod, write_path); @@ -986,7 +1066,8 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, } authz_strategy = config.m_authz_strategy; - cache_expiry = expiry; + cache_lifetime = lifetime; + token_expiry = expiry; rules = std::move(xrd_rules); username = std::move(tmp_username); issuer = std::move(token_issuer); @@ -1327,6 +1408,7 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, return true; } + // Iterate through the internal cache, check for expiration. void Check(uint64_t now) { if (now <= m_next_clean) {return;} @@ -1344,6 +1426,85 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, m_next_clean = monotonic_time() + m_expiry_secs; } + // Given an access token, return the corresponding access rules + std::shared_ptr GetRules(const std::string &authz) { + uint64_t now = monotonic_time(); + Check(now); + { + std::lock_guard guard(m_mutex); + const auto iter = m_map.find(authz); + if (iter != m_map.end() && !iter->second->expired()) { + auto rules = iter->second; + m_log.Log(LogMask::Debug, "Access", "Cached token", rules->str().c_str()); + return rules; + } + } + std::shared_ptr access_rules; + m_log.Log(LogMask::Debug, "Access", "Token not found in recent cache; parsing."); + try { + uint64_t cache_lifetime; + AccessRulesRaw rules; + std::string username; + std::string token_subject; + std::string issuer; + std::vector map_rules; + std::vector groups; + uint32_t authz_strategy; + time_t token_expiry; + if (GenerateAcls(authz, cache_lifetime, rules, username, token_subject, issuer, map_rules, groups, authz_strategy, token_expiry)) { + access_rules.reset(new XrdAccRules(now + cache_lifetime, username, token_subject, issuer, map_rules, groups, authz_strategy, token_expiry)); + access_rules->parse(rules); + } else { + m_log.Log(LogMask::Warning, "Access", "Failed to generate ACLs for token"); + return access_rules; + } + if (m_log.getMsgMask() & LogMask::Debug) { + m_log.Log(LogMask::Debug, "Access", "New valid token", access_rules->str().c_str()); + } + } catch (std::exception &exc) { + m_log.Log(LogMask::Warning, "Access", "Error generating ACLs for authorization", exc.what()); + return access_rules; + } + std::lock_guard guard(m_mutex); + m_map[authz] = access_rules; + return access_rules; + } + + // Given a set of rules, determine the authorized username + std::string GetUser(std::bitset opers, std::string path, std::shared_ptr rules, bool &scope_success) { + + std::string username; + bool mapping_success = false; + username = rules->get_username(path); + + mapping_success = (rules->get_authz_strategy() & IssuerAuthz::Mapping) && !username.empty(); + scope_success = (rules->get_authz_strategy() & IssuerAuthz::Capability) && opers.any(); + if (scope_success && (m_log.getMsgMask() & LogMask::Debug)) { + std::stringstream ss; + ss << "Grant authorization based on scopes for operation=" << OpsToName(opers) << ", path=" << path; + m_log.Log(LogMask::Debug, "Access", ss.str().c_str()); + } + bool group_success = (rules->get_authz_strategy() & IssuerAuthz::Group) && rules->groups().size(); + + if (!scope_success && !mapping_success && !group_success) { + return ""; + } + + // Default user only applies to scope-based mappings. + if (scope_success && username.empty()) { + username = rules->get_default_username(); + } + + // Setting the request.name will pass the username to the next plugin. + // Ensure we do that only if map-based or scope-based authorization worked. + if (scope_success || mapping_success) { + // Set scitokens.name in the extra attribute + return username; + } + + return ""; + } + bool m_config_lock_initialized{false}; std::mutex m_mutex; pthread_rwlock_t m_config_lock; @@ -1358,6 +1519,7 @@ class XrdAccSciTokens : public XrdAccAuthorize, public XrdSciTokensHelper, XrdSysError m_log; AuthzBehavior m_authz_behavior{AuthzBehavior::PASSTHROUGH}; std::string m_cfg_file; + std::unique_ptr m_generator; static constexpr uint64_t m_expiry_secs = 60; }; @@ -1368,6 +1530,7 @@ void InitAccSciTokens(XrdSysLogger *lp, const char *cfn, const char *parm, try { accSciTokens = new XrdAccSciTokens(lp, parm, accP, envP); SciTokensHelper = accSciTokens; + SciTokensRedir = accSciTokens; } catch (std::exception &) { } } diff --git a/src/XrdSciTokens/XrdSciTokensRedir.hh b/src/XrdSciTokens/XrdSciTokensRedir.hh new file mode 100644 index 00000000000..f29b0b8b579 --- /dev/null +++ b/src/XrdSciTokens/XrdSciTokensRedir.hh @@ -0,0 +1,47 @@ +#ifndef __XrdSciTokensRedir_hh__ +#define __XrdSciTokensRedir_hh__ + +/******************************************************************************/ +/* */ +/* X r d S c i T o k e n s R e d i r . h h */ +/* */ +/******************************************************************************/ + +//----------------------------------------------------------------------------- +//! This class defines the XrdAccSciTokensRedir API to generate a redirect token +//! associated with a token. It requires that the SciTokens authorization plugin +//! be loaded and initialized. Upon successful loading and initialization the +//! symbol "SciTokensAcls" will contain the address of an instance of this class. +//! The inspiration for this approach was taken the XrdSciTokensHelper.hh +//----------------------------------------------------------------------------- + +#include + +class XrdSciTokensRedir +{ +public: + +//----------------------------------------------------------------------------- +//! Alter a given URL to embed a redirect token. +//! +//! This will scan the URL for an embedded authorization token and, if it's a +//! valid SciToken, replaces it with a "redirect token" that is equivalent to +//! the SciToken intersected with the path in the URL. +//! +//! @param url - Pointer to the URL to modify. +//! +//! @result Returns the modified URL; an empty string is given if an error occurs. +//! If no modification was done, it returns the original URL. +//----------------------------------------------------------------------------- + +virtual std::string Redirect(const char *url) = 0; + +//----------------------------------------------------------------------------- +//! Constructor and Destructor. +//----------------------------------------------------------------------------- + + XrdSciTokensRedir() {} +virtual ~XrdSciTokensRedir() {} +}; + +#endif diff --git a/src/XrdXrootd/XrdXrootdConfig.cc b/src/XrdXrootd/XrdXrootdConfig.cc index 6be6bcd209d..fc0d7333aad 100644 --- a/src/XrdXrootd/XrdXrootdConfig.cc +++ b/src/XrdXrootd/XrdXrootdConfig.cc @@ -1690,7 +1690,8 @@ int XrdXrootdProtocol::xred(XrdOucStream &Config) {"rm", RD_rm}, {"rmdir", RD_rmdir}, {"stat", RD_stat}, - {"trunc", RD_trunc} + {"trunc", RD_trunc}, + {"write", RD_write} }; static const int rHLen = 264; char rHost[2][rHLen], *hP[2], *val; diff --git a/src/XrdXrootd/XrdXrootdProtocol.cc b/src/XrdXrootd/XrdXrootdProtocol.cc index 251ba3affba..23a7c6210df 100644 --- a/src/XrdXrootd/XrdXrootdProtocol.cc +++ b/src/XrdXrootd/XrdXrootdProtocol.cc @@ -471,7 +471,7 @@ int XrdXrootdProtocol::Process2() switch(Request.header.requestid) {case kXR_login: return do_Login(); case kXR_protocol: return do_Protocol(); - case kXR_bind: return do_Bind(); + //case kXR_bind: return do_Bind(); default: Response.Send(kXR_InvalidRequest, "Invalid request; user not logged in"); return Link->setEtext("request without login"); diff --git a/src/XrdXrootd/XrdXrootdProtocol.hh b/src/XrdXrootd/XrdXrootdProtocol.hh index 1831bd795c4..1a9f0f593c0 100644 --- a/src/XrdXrootd/XrdXrootdProtocol.hh +++ b/src/XrdXrootd/XrdXrootdProtocol.hh @@ -241,7 +241,8 @@ private: enum RD_func {RD_chmod = 0, RD_chksum, RD_dirlist, RD_locate, RD_mkdir, RD_mv, RD_prepare, RD_prepstg, RD_rm, RD_rmdir, RD_stat, RD_trunc, RD_ovld, RD_client, - RD_open1, RD_open2, RD_open3, RD_open4, RD_Num}; + RD_write, RD_open1, RD_open2, RD_open3, RD_open4, + RD_Num}; int do_Auth(); int do_Bind(); diff --git a/src/XrdXrootd/XrdXrootdXeq.cc b/src/XrdXrootd/XrdXrootdXeq.cc index a287c1355a4..1dd19bf1a1a 100644 --- a/src/XrdXrootd/XrdXrootdXeq.cc +++ b/src/XrdXrootd/XrdXrootdXeq.cc @@ -1459,15 +1459,22 @@ int XrdXrootdProtocol::do_Open() // doDig = (digFS && SFS_LCLPATH(fn)); -// Validate the path and then check if static redirection applies +// Validate the path/req type and then check if static redirection applies // if (doDig) {popt = XROOTDXP_NOLK; opC = 0;} - else {int ropt; - if (!(popt = Squash(fn))) return vpEmsg("Opening", fn); - if (Route[RD_open1].Host[rdType] && (ropt = RPList.Validate(fn))) - return Response.Send(kXR_redirect, Route[ropt].Port[rdType], - Route[ropt].Host[rdType]); - } + else {int ropt = -1; + if (!(popt = Squash(fn))) return vpEmsg("Opening", fn); + if (Route[RD_open1].Host[rdType]) + ropt = RPList.Validate(fn); + else + if (Route[RD_write].Host[rdType] && ('w' == usage || strchr(op, 'd'))) + ropt = RD_write; + if (ropt > 0) + return Response.Send( + kXR_redirect, Route[ropt].Port[rdType], + Route[ropt].Host[rdType] + ); + } // Add the multi-write option if this path supports it // diff --git a/src/XrdXrootd/XrdXrootdXeqPgrw.cc b/src/XrdXrootd/XrdXrootdXeqPgrw.cc index db44b0c0d6c..85f92f9cdd3 100644 --- a/src/XrdXrootd/XrdXrootdXeqPgrw.cc +++ b/src/XrdXrootd/XrdXrootdXeqPgrw.cc @@ -270,7 +270,6 @@ int XrdXrootdProtocol::do_PgRIO() iov[i++].iov_len = pgPageSize; buff += pgPageSize; } - // If this is an unaligned read, offset the unaligned segment in the buffer // so that remaining pages are page-aligned. It will be reset when needed. // We also calculate the actual length of the first read. diff --git a/tests/XrdCl/CMakeLists.txt b/tests/XrdCl/CMakeLists.txt index 3b7280019a3..09b0918aff4 100644 --- a/tests/XrdCl/CMakeLists.txt +++ b/tests/XrdCl/CMakeLists.txt @@ -1,4 +1,5 @@ add_executable(xrdcl-unit-tests + XrdClEnv.cc XrdClURL.cc XrdClPoller.cc XrdClSocket.cc diff --git a/tests/XrdCl/IdentityPlugIn.cc b/tests/XrdCl/IdentityPlugIn.cc index eea454e50c0..d565e95c47b 100644 --- a/tests/XrdCl/IdentityPlugIn.cc +++ b/tests/XrdCl/IdentityPlugIn.cc @@ -67,7 +67,7 @@ namespace OpenFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFile::Open" ); @@ -78,7 +78,7 @@ namespace // Close //------------------------------------------------------------------------ virtual XRootDStatus Close( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFile::Close" ); @@ -90,7 +90,7 @@ namespace //------------------------------------------------------------------------ virtual XRootDStatus Stat( bool force, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFile::Stat" ); @@ -105,7 +105,7 @@ namespace uint32_t size, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFile::Read" ); @@ -119,7 +119,7 @@ namespace uint32_t size, const void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFile::Write" ); @@ -130,7 +130,7 @@ namespace // Sync //------------------------------------------------------------------------ virtual XRootDStatus Sync( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFile::Sync" ); @@ -142,7 +142,7 @@ namespace //------------------------------------------------------------------------ virtual XRootDStatus Truncate( uint64_t size, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFile::Truncate" ); @@ -155,7 +155,7 @@ namespace virtual XRootDStatus VectorRead( const ChunkList &chunks, void *buffer, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFile::VectorRead" ); @@ -167,7 +167,7 @@ namespace //------------------------------------------------------------------------ virtual XRootDStatus Fcntl( const Buffer &arg, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFile::Fcntl" ); @@ -178,7 +178,7 @@ namespace // Visa //------------------------------------------------------------------------ virtual XRootDStatus Visa( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFile::Visa" ); @@ -253,7 +253,7 @@ namespace virtual XRootDStatus Locate( const std::string &path, OpenFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::Locate" ); @@ -266,7 +266,7 @@ namespace virtual XRootDStatus Mv( const std::string &source, const std::string &dest, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::Mv" ); @@ -279,7 +279,7 @@ namespace virtual XRootDStatus Query( QueryCode::Code queryCode, const Buffer &arg, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::Query" ); @@ -292,7 +292,7 @@ namespace virtual XRootDStatus Truncate( const std::string &path, uint64_t size, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::Truncate" ); @@ -304,7 +304,7 @@ namespace //------------------------------------------------------------------------ virtual XRootDStatus Rm( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::Rm" ); @@ -318,7 +318,7 @@ namespace MkDirFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::MkDir" ); @@ -330,7 +330,7 @@ namespace //------------------------------------------------------------------------ virtual XRootDStatus RmDir( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::RmDir" ); @@ -343,7 +343,7 @@ namespace virtual XRootDStatus ChMod( const std::string &path, Access::Mode mode, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::ChMod" ); @@ -354,7 +354,7 @@ namespace // Ping //------------------------------------------------------------------------ virtual XRootDStatus Ping( ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::Ping" ); @@ -366,7 +366,7 @@ namespace //------------------------------------------------------------------------ virtual XRootDStatus Stat( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::Stat" ); @@ -378,7 +378,7 @@ namespace //------------------------------------------------------------------------ virtual XRootDStatus StatVFS( const std::string &path, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::StatVFS" ); @@ -389,7 +389,7 @@ namespace // Protocol //------------------------------------------------------------------------ virtual XRootDStatus Protocol( ResponseHandler *handler, - uint16_t timeout = 0 ) + time_t timeout = 0 ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::Protocol" ); @@ -402,7 +402,7 @@ namespace virtual XRootDStatus DirList( const std::string &path, DirListFlags::Flags flags, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::DirList" ); @@ -414,7 +414,7 @@ namespace //------------------------------------------------------------------------ virtual XRootDStatus SendInfo( const std::string &info, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::SendInfo" ); @@ -428,7 +428,7 @@ namespace PrepareFlags::Flags flags, uint8_t priority, ResponseHandler *handler, - uint16_t timeout ) + time_t timeout ) { XrdCl::Log *log = TestEnv::GetLog(); log->Debug( 1, "Calling IdentityFileSystem::Prepare" ); diff --git a/tests/XrdCl/XrdClEnv.cc b/tests/XrdCl/XrdClEnv.cc new file mode 100644 index 00000000000..46e35dff250 --- /dev/null +++ b/tests/XrdCl/XrdClEnv.cc @@ -0,0 +1,108 @@ +#undef NDEBUG + +#include +#include +#include +#include + +#include + +using XrdCl::Env; + +class XrdClEnvTest : public ::testing::Test { +protected: + void SetUp() override { + XrdCl::DefaultEnv::SetLogLevel("Dump"); + + unsetenv("XRD_TEST_INVALID"); + + setenv("XRD_TEST_INT", "42", 1); + setenv("XRD_TEST_STRING", "XRootD", 1); + } + + Env e; +}; + +TEST_F(XrdClEnvTest, Int) { + // get by default value + int ParallelEvtLoop = 0; + EXPECT_TRUE(e.GetDefaultIntValue("ParallelEvtLoop", ParallelEvtLoop)); + EXPECT_EQ(ParallelEvtLoop, XrdCl::DefaultParallelEvtLoop); + + // get/put by normalized name + int test_int = 0; + EXPECT_TRUE(e.PutInt("test_int", -1)); + EXPECT_TRUE(e.GetInt("test_int", test_int)); + EXPECT_EQ(test_int, -1); + + // get/put by environment name + EXPECT_TRUE(e.PutInt("XRD_TEST_INT", 0)); + EXPECT_TRUE(e.GetInt("XRD_TEST_INT", test_int)); + EXPECT_EQ(test_int, 0); + + // imported value, should not be overriden + EXPECT_TRUE(e.ImportInt("test_int", "XRD_TEST_INT")); + EXPECT_FALSE(e.PutInt("XRD_TEST_INT", 1)); + EXPECT_TRUE(e.GetInt("XRD_TEST_INT", test_int)); + EXPECT_EQ(test_int, 42); + + // should return false if importing unset environment variable + int test_invalid = 1729; + EXPECT_FALSE(e.ImportInt("test_invalid", "XRD_TEST_INVALID")); + EXPECT_FALSE(e.GetInt("XRD_TEST_INVALID", test_invalid)); + EXPECT_EQ(test_invalid, 1729); // unchanged + + // should return false if value imported is not an integer + EXPECT_FALSE(e.ImportInt("test_string", "XRD_TEST_STRING")); +} + +TEST_F(XrdClEnvTest, String) { + std::string str; + + // get by default value + EXPECT_FALSE(e.GetDefaultStringValue("DoesNotExist", str)); + EXPECT_TRUE(e.GetDefaultStringValue("XRD_CPRETRYPOLICY", str)); + EXPECT_EQ(str, XrdCl::DefaultCpRetryPolicy); + + // get/put by normalized name + EXPECT_TRUE(e.PutString("test_string", "hello1")); + EXPECT_TRUE(e.GetString("test_string", str)); + EXPECT_EQ(str, "hello1"); + + EXPECT_TRUE(e.PutString("XRD_TEST_STRING", "hello2")); + EXPECT_TRUE(e.GetString("test_string", str)); + EXPECT_EQ(str, "hello2"); + + // get/put by environment name + EXPECT_TRUE(e.PutString("XRD_TEST_STRING", "hello3")); + EXPECT_TRUE(e.GetString("XRD_TEST_STRING", str)); + EXPECT_EQ(str, "hello3"); + + EXPECT_TRUE(e.PutString("test_string", "hello4")); + EXPECT_TRUE(e.GetString("XRD_TEST_STRING", str)); + EXPECT_EQ(str, "hello4"); + + // imported value, should not be overriden + EXPECT_TRUE(e.ImportString("test_string", "XRD_TEST_STRING")); + EXPECT_FALSE(e.PutString("XRD_TEST_STRING", "hello5")); + EXPECT_FALSE(e.PutString("test_string", "hello6")); + EXPECT_TRUE(e.GetString("XRD_TEST_STRING", str)); + EXPECT_EQ(str, "XRootD"); + + // should return false if importing unset environment variable + str = "valid"; + EXPECT_FALSE(e.ImportString("test_invalid", "XRD_TEST_INVALID")); + EXPECT_FALSE(e.GetString("XRD_TEST_INVALID", str)); + EXPECT_EQ(str, "valid"); +} + +TEST_F(XrdClEnvTest, Pointer) { + void *ptr = nullptr; + + EXPECT_FALSE(e.GetPtr("XRD_TEST_INVALID", ptr)); + EXPECT_EQ(ptr, nullptr); + + EXPECT_TRUE(e.PutPtr("gStream", this)); + EXPECT_TRUE(e.GetPtr("gStream", ptr)); + EXPECT_EQ(ptr, this); +} diff --git a/tests/XrdCl/XrdClFileCopyTest.cc b/tests/XrdCl/XrdClFileCopyTest.cc index 43df8e2473a..64605d51204 100644 --- a/tests/XrdCl/XrdClFileCopyTest.cc +++ b/tests/XrdCl/XrdClFileCopyTest.cc @@ -289,7 +289,7 @@ namespace //------------------------------------------------------------------------ // Job progress //------------------------------------------------------------------------ - virtual void JobProgress( uint16_t jobNum, + virtual void JobProgress( uint32_t jobNum, uint64_t bytesProcessed, uint64_t bytesTotal ) { @@ -300,7 +300,7 @@ namespace //------------------------------------------------------------------------ // Determine whether the job should be canceled //------------------------------------------------------------------------ - virtual bool ShouldCancel( uint16_t jobNum ) { return pCancel; } + virtual bool ShouldCancel( uint32_t jobNum ) { return pCancel; } private: bool pCancel; diff --git a/xrootd.spec b/xrootd.spec index 9ecd527c1bb..d2fd82f6f4c 100644 --- a/xrootd.spec +++ b/xrootd.spec @@ -9,7 +9,7 @@ Name: xrootd Epoch: 1 -Release: 1%{?dist}%{?with_clang:.clang}%{?with_asan:.asan} +Release: 99%{?dist}%{?with_clang:.clang}%{?with_asan:.asan}%{?with_openssl11:.ssl11} Summary: Extended ROOT File Server Group: System Environment/Daemons License: LGPL-3.0-or-later AND BSD-2-Clause AND BSD-3-Clause AND curl AND MIT AND Zlib @@ -271,12 +271,12 @@ xrdcl-http is an XRootD client plugin which allows XRootD to interact with HTTP repositories. %if %{with ceph} -%package ceph +%package ceph-buffered Summary: XRootD plugin for interfacing with the Ceph storage platform Group: System Environment/Libraries Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release} -%description ceph +%description ceph-buffered The xrootd-ceph is an OSS layer plugin for the XRootD server for interfacing with the Ceph storage platform. %endif @@ -686,7 +686,7 @@ fi %config(noreplace) %{_sysconfdir}/%{name}/client.plugins.d/xrdcl-http-plugin.conf %if %{with ceph} -%files ceph +%files ceph-buffered %{_libdir}/libXrdCeph-5.so %{_libdir}/libXrdCephXattr-5.so %{_libdir}/libXrdCephPosix.so.*