From 7e8eb3b6a1430b55211d4b499582b244c7c08af0 Mon Sep 17 00:00:00 2001 From: Andrew Hanushevsky Date: Mon, 17 Jun 2013 09:05:20 -0700 Subject: [PATCH] Add setSF() method to the bridge to allow brdiged protocols to disable using sendfile() for an open file (nenecassry for https wgets). --- src/XrdXrootd/XrdXrootdBridge.hh | 17 +++++++++++++++++ src/XrdXrootd/XrdXrootdProtocol.hh | 1 + src/XrdXrootd/XrdXrootdTransit.hh | 7 +++++++ src/XrdXrootd/XrdXrootdXeq.cc | 21 +++++++++++++++++++++ 4 files changed, 46 insertions(+) diff --git a/src/XrdXrootd/XrdXrootdBridge.hh b/src/XrdXrootd/XrdXrootdBridge.hh index 62932b0c671..71c5ff5d570 100644 --- a/src/XrdXrootd/XrdXrootdBridge.hh +++ b/src/XrdXrootd/XrdXrootdBridge.hh @@ -171,6 +171,23 @@ virtual bool Run(const char *xreqP, //!< xrootd request header virtual bool Disc() = 0; +//----------------------------------------------------------------------------- +//! Set file's sendfile capability. +//! +//! The setSF() method allows you to turn on or off the ability of an open +//! file to be used with the sendfile() system call. This is useful when you +//! must see the data prior to sending to the client (e.g. for encryption). +//! +//! @param fhandle the filehandle as returned by kXR_open. +//! @param mode When true, enables sendfile() otherwise it is disabled. +//! +//! @return =0 Sucessful. +//! @return <0 Call failed. The return code is -errno and usually will +//! indicate that the filehandle is not valid. +//----------------------------------------------------------------------------- + +virtual int setSF(kXR_char *fhandle, bool seton=false) = 0; + //----------------------------------------------------------------------------- //! Set the maximum delay. //! diff --git a/src/XrdXrootd/XrdXrootdProtocol.hh b/src/XrdXrootd/XrdXrootdProtocol.hh index fcb8eae5192..2e204676270 100644 --- a/src/XrdXrootd/XrdXrootdProtocol.hh +++ b/src/XrdXrootd/XrdXrootdProtocol.hh @@ -207,6 +207,7 @@ XrdObject ProtLink; protected: void MonAuth(); + int SetSF(kXR_char *fhandle, bool seton=false); static XrdXrootdXPath RPList; // Redirected paths static XrdXrootdXPath RQList; // Redirected paths for ENOENT diff --git a/src/XrdXrootd/XrdXrootdTransit.hh b/src/XrdXrootd/XrdXrootdTransit.hh index a223fe4f10f..00ab9dd77bb 100644 --- a/src/XrdXrootd/XrdXrootdTransit.hh +++ b/src/XrdXrootd/XrdXrootdTransit.hh @@ -128,6 +128,13 @@ int Send(int rcode, const struct iovec *ioVec, int ioNum, int ioLen); int Send(long long offset, int dlen, int fdnum); +//----------------------------------------------------------------------------- +//! Set sendfile() enablement. +//----------------------------------------------------------------------------- + +int setSF(kXR_char *fhandle, bool seton=false) + {return SetSF(fhandle, seton);} + //----------------------------------------------------------------------------- //! Set maximum wait time. //----------------------------------------------------------------------------- diff --git a/src/XrdXrootd/XrdXrootdXeq.cc b/src/XrdXrootd/XrdXrootdXeq.cc index da4a1a92df4..293e5a8da2a 100644 --- a/src/XrdXrootd/XrdXrootdXeq.cc +++ b/src/XrdXrootd/XrdXrootdXeq.cc @@ -2750,6 +2750,27 @@ int XrdXrootdProtocol::rpEmsg(const char *op, char *fn) return Response.Send(kXR_NotAuthorized, buff); } +/******************************************************************************/ +/* S e t S F */ +/******************************************************************************/ + +int XrdXrootdProtocol::SetSF(kXR_char *fhandle, bool seton) +{ + XrdXrootdFHandle fh(fhandle); + XrdXrootdFile *theFile; + + if (!FTab || !(theFile = FTab->Get(fh.handle))) return -EBADF; + +// Turn it off or on if so wanted +// + if (!seton) theFile->sfEnabled = 0; + else if (theFile->fdNum >= 0) theFile->sfEnabled = 1; + +// All done +// + return 0; +} + /******************************************************************************/ /* S q u a s h */ /******************************************************************************/