Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow redirection of write requests #19

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading