Skip to content

Commit

Permalink
Merge pull request #19 from alex-rg/add_redirection
Browse files Browse the repository at this point in the history
feat: allow redirection of write requests
  • Loading branch information
Jo-stfc authored Nov 12, 2024
2 parents 441fd05 + 286bb3a commit b2c60d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/XrdXrootd/XrdXrootdConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,8 @@ int XrdXrootdProtocol::xred(XrdOucStream &Config)
{"rm", RD_rm},
{"rmdir", RD_rmdir},
{"stat", RD_stat},
{"trunc", RD_trunc}
{"trunc", RD_trunc},
{"write", RD_open2}
};
static const int rHLen = 264;
char rHost[2][rHLen], *hP[2], *val;
Expand Down
30 changes: 22 additions & 8 deletions src/XrdXrootd/XrdXrootdXeq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,7 @@ int XrdXrootdProtocol::do_Open()
mode = (int)ntohs(Request.open.mode);
opts = (int)ntohs(Request.open.options);


// Map the mode and options
//
mode = mapMode(mode) | S_IRUSR | S_IWUSR; usage = 'r';
Expand Down Expand Up @@ -1458,15 +1459,28 @@ 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]);
}
if (doDig)
{
popt = XROOTDXP_NOLK; opC = 0;
}
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_open2].Host[rdType] && ('w' == usage || strchr(op, 'd')))
ropt = RD_open2;
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
//
Expand Down

0 comments on commit b2c60d3

Please sign in to comment.