Skip to content

Commit

Permalink
Add setSF() method to the bridge to allow brdiged protocols to disable
Browse files Browse the repository at this point in the history
using sendfile() for an open file (nenecassry for https wgets).
  • Loading branch information
abh3 committed Jun 17, 2013
1 parent 951256e commit 7e8eb3b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/XrdXrootd/XrdXrootdBridge.hh
Expand Up @@ -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.
//!
Expand Down
1 change: 1 addition & 0 deletions src/XrdXrootd/XrdXrootdProtocol.hh
Expand Up @@ -207,6 +207,7 @@ XrdObject<XrdXrootdProtocol> ProtLink;
protected:

void MonAuth();
int SetSF(kXR_char *fhandle, bool seton=false);

static XrdXrootdXPath RPList; // Redirected paths
static XrdXrootdXPath RQList; // Redirected paths for ENOENT
Expand Down
7 changes: 7 additions & 0 deletions src/XrdXrootd/XrdXrootdTransit.hh
Expand Up @@ -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.
//-----------------------------------------------------------------------------
Expand Down
21 changes: 21 additions & 0 deletions src/XrdXrootd/XrdXrootdXeq.cc
Expand Up @@ -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 */
/******************************************************************************/
Expand Down

0 comments on commit 7e8eb3b

Please sign in to comment.