Skip to content

Commit

Permalink
[Xcache] Allow N2N to optionally see the client's CGI.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed May 27, 2020
1 parent baf0763 commit d021e65
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
18 changes: 10 additions & 8 deletions src/XrdOuc/XrdOucPsx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ bool XrdOucPsx::ParseINet(XrdSysError *Eroute, XrdOucStream &Config)
Purpose: To parse the directive: namelib [<opts>] pfn<path> [<parms>]
<opts> one or more: [-lfn2pfn] [-lfncache[src]]
<opts> one or more: [-lfn2pfn] [-lfncache[src[+]]]
<path> the path of the filesystem library to be used.
<parms> optional parms to be passed
Expand All @@ -646,22 +646,24 @@ bool XrdOucPsx::ParseINet(XrdSysError *Eroute, XrdOucStream &Config)
bool XrdOucPsx::ParseNLib(XrdSysError *Eroute, XrdOucStream &Config)
{
char *val, parms[1024];
bool l2p = false, p2l = false, p2lsrc = false;
bool l2p = false, p2l = false, p2lsrc = false, p2lsgi = false;

// Parse options, if any
//
while((val = Config.GetWord()) && val[0])
{ if (!strcmp(val, "-lfn2pfn")) l2p = true;
else if (!strcmp(val, "-lfncache")) p2l = true;
else if (!strcmp(val, "-lfncachesrc")) p2l = p2lsrc = true;
{ if (!strcmp(val, "-lfn2pfn")) l2p = true;
else if (!strcmp(val, "-lfncache")) p2l = true;
else if (!strcmp(val, "-lfncachesrc")) p2l = p2lsrc = true;
else if (!strcmp(val, "-lfncachesrc+")) p2l = p2lsgi = true;
else break;
}

if (!l2p && !p2l) l2p = true;
xLfn2Pfn = l2p;
if (!p2l) xPfn2Lfn = xP2Loff;
else if (p2lsrc) xPfn2Lfn = xP2Lsrc;
else xPfn2Lfn = xP2Lon;
if (!p2l) xPfn2Lfn = xP2Loff;
else if (p2lsrc) xPfn2Lfn = xP2Lsrc;
else if (p2lsgi) xPfn2Lfn = xP2Lsgi;
else xPfn2Lfn = xP2Lon;

// Get the path
//
Expand Down
1 change: 1 addition & 0 deletions src/XrdOuc/XrdOucPsx.hh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ bool xNameLib;
static const int xP2Loff = 0;
static const int xP2Lon = 1;
static const int xP2Lsrc = 2;
static const int xP2Lsgi = 3;

XrdOucPsx(XrdVersionInfo *vInfo, const char *cfn,
XrdSysLogger *lp=0, XrdOucEnv *vp=0)
Expand Down
6 changes: 5 additions & 1 deletion src/XrdPosix/XrdPosixConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ extern int ddMaxTries;
extern XrdCl::DirListFlags::Flags dlFlag;
extern bool oidsOK;
extern bool p2lSRC;
extern bool p2lSGI;
};

/******************************************************************************/
Expand Down Expand Up @@ -367,7 +368,10 @@ bool XrdPosixConfig::SetConfig(XrdOucPsx &parms)
//
if (parms.xPfn2Lfn)
{XrdPosixGlobals::theN2N = parms.theN2N;
XrdPosixGlobals::p2lSRC = parms.xPfn2Lfn == parms.xP2Lsrc;
if (parms.xPfn2Lfn == parms.xP2Lsrc || parms.xPfn2Lfn == parms.xP2Lsgi)
{XrdPosixGlobals::p2lSRC = true;
XrdPosixGlobals::p2lSGI = parms.xPfn2Lfn == parms.xP2Lsrc;
} else XrdPosixGlobals::p2lSRC = XrdPosixGlobals::p2lSGI = false;
}

// Handle client settings
Expand Down
1 change: 1 addition & 0 deletions src/XrdPosix/XrdPosixXrootd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ int ddMaxTries= 180/30;
XrdCl::DirListFlags::Flags dlFlag = XrdCl::DirListFlags::None;
bool oidsOK = false;
bool p2lSRC = false;
bool p2lSGI = false;
};

int XrdPosixXrootd::baseFD = 0;
Expand Down
12 changes: 9 additions & 3 deletions src/XrdPosix/XrdPosixXrootdPath.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace XrdPosixGlobals
extern XrdOucName2Name *theN2N;
extern bool oidsOK;
extern bool p2lSRC;
extern bool p2lSGI;

ProtoTable protoTab[ptEnts] = {{"root://", 7}, {"xroot://", 8},
{"roots://", 8}, {"xroots://", 9}};
Expand Down Expand Up @@ -205,9 +206,10 @@ const char *XrdPosixXrootPath::P2L(const char *who,
}

// Allocate sufficient space for the pfn with possible extensions (e.g. "?src="
// and the whole url prefix)
// and the whole url prefix and possible cgi).
//
char *pfnBP = (char *)alloca(pfnLen + 5 *pfxLen + 1);
n = (XrdPosixGlobals::p2lSGI ? cgiLen : 0);
char *pfnBP = (char *)alloca(pfnLen + 5 + pfxLen + n + 1);

// Copy out the pfn. We know it will definitely fit.
//
Expand All @@ -219,7 +221,11 @@ const char *XrdPosixXrootPath::P2L(const char *who,
else {char *bP = pfnBP+pfnLen;
memcpy(bP, "?src=", 5); bP += 5;
strncpy(bP, inP, pfxLen);
*(bP+pfxLen) = 0;
bP += pfxLen;
if (XrdPosixGlobals::p2lSGI && cgiLen)
{if (*(quest+1) != '&') *bP++ = '&';
strcpy(bP, quest+1);
} else *bP = 0;
}

// Invoke the name2name translator if we have one
Expand Down

0 comments on commit d021e65

Please sign in to comment.