Skip to content

Commit

Permalink
[SSI] Allow zero length requests to be passed to servers. Fixes #640
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 authored and simonmichal committed Jan 17, 2018
1 parent 8f8ff1b commit cd77637
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/XrdSsi/XrdSsiFileSess.cc
Expand Up @@ -657,6 +657,7 @@ XrdSfsXferSize XrdSsiFileSess::write(XrdSfsFileOffset offset, // In
static const char *epname = "write";
XrdSsiRRInfo rInfo(offset);
unsigned int reqID = rInfo.Id();
int reqPass;

// Check if we are reading a request segment and handle that. This assumes that
// writes to different requests cannot be interleaved (which they can't be).
Expand All @@ -668,11 +669,16 @@ XrdSfsXferSize XrdSsiFileSess::write(XrdSfsFileOffset offset, // In
if (rTab.LookUp(reqID))
return XrdSsiUtils::Emsg(epname, EADDRINUSE, "write", gigID, *eInfo);

// The offset contains the actual size of the request, make sure it's OK
// The offset contains the actual size of the request, make sure it's OK. Note
// that it can be zero and by convention the blen must be one if so.
//
reqSize = rInfo.Size();
if (reqSize <= 0 || reqSize > maxRSZ || reqSize < blen)
return XrdSsiUtils::Emsg(epname, EFBIG, "write", gigID, *eInfo);
reqPass = reqSize = rInfo.Size();
if (reqSize < blen)
{if (reqSize || blen != 1)
return XrdSsiUtils::Emsg(epname, EPROTO, "write", gigID, *eInfo);
reqSize = 1;
} else if (reqSize < 0 || reqSize > maxRSZ)
return XrdSsiUtils::Emsg(epname, EFBIG, "write", gigID, *eInfo);

// Indicate we are in the progress of collecting the request arguments
//
Expand All @@ -695,7 +701,7 @@ XrdSfsXferSize XrdSsiFileSess::write(XrdSfsFileOffset offset, // In
Log.Emsg(epname, "Xio.Swap() return error status of ", etxt);
return XrdSsiUtils::Emsg(epname, ENOMEM, "write", gigID, *eInfo);
}
if (!NewRequest(reqID, 0, bRef, blen))
if (!NewRequest(reqID, 0, bRef, reqPass))
return XrdSsiUtils::Emsg(epname, ENOMEM, "write", gigID, *eInfo);
return blen;
}
Expand All @@ -712,7 +718,7 @@ XrdSfsXferSize XrdSsiFileSess::write(XrdSfsFileOffset offset, // In
if (!reqLeft)
{oucBuff->SetLen(reqSize);

if (!NewRequest(reqID, oucBuff, 0, reqSize))
if (!NewRequest(reqID, oucBuff, 0, reqPass))
return XrdSsiUtils::Emsg(epname, ENOMEM, "write", gigID, *eInfo);
oucBuff = 0;
} else oucBuff->SetLen(blen, blen);
Expand Down
2 changes: 1 addition & 1 deletion src/XrdSsi/XrdSsiRRInfo.hh
Expand Up @@ -40,7 +40,7 @@ public:

static const unsigned int idMax = 16777215;

enum Opc {Rxq = 0, Rwt = 1, Can = 2};
enum Opc {Rxq = 0, Rwt = 1, Can = 2, Rxz = 3};

inline void Cmd(Opc cmd)
{reqCmd = static_cast<unsigned char>(cmd);}
Expand Down
9 changes: 9 additions & 0 deletions src/XrdSsi/XrdSsiTaskReal.cc
Expand Up @@ -482,6 +482,15 @@ bool XrdSsiTaskReal::SendRequest(const char *node)
rrInfo.Size(reqBlen);
tStat = isWrite;

// If we are writing a zero length message, we must handle this as a separate
// type of operation as zero length messages are normally deep-sixed.
//
if (!reqBlen)
{reqBuff = &zedData;
reqBlen = 1;
rrInfo.Cmd(XrdSsiRRInfo::Rxz);
}

// Issue the write
//
Status = sessP->epFile.Write(rrInfo.Info(), (uint32_t)reqBlen, reqBuff,
Expand Down

0 comments on commit cd77637

Please sign in to comment.