/******************************************************************************/
/* */
/* X r d S s i T a s k R e a l . c c */
/* */
/* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */
/* Produced by Andrew Hanushevsky for Stanford University under contract */
/* DE-AC02-76-SFO0515 with the Department of Energy */
/* */
/* This file is part of the XRootD software suite. */
/* */
/* XRootD is free software: you can redistribute it and/or modify it under */
/* the terms of the GNU Lesser General Public License as published by the */
/* Free Software Foundation, either version 3 of the License, or (at your */
/* option) any later version. */
/* */
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public License */
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
/* COPYING (GPL license). If not, see . */
/* */
/* The copyright holder's institutional names and contributor's names may not */
/* be used to endorse or promote products derived from this software without */
/* specific prior written permission of the institution or contributor. */
/******************************************************************************/
#include
#include
#include "XrdSsi/XrdSsiAtomics.hh"
#include "XrdSsi/XrdSsiRequest.hh"
#include "XrdSsi/XrdSsiRRAgent.hh"
#include "XrdSsi/XrdSsiRRInfo.hh"
#include "XrdSsi/XrdSsiScale.hh"
#include "XrdSsi/XrdSsiSessReal.hh"
#include "XrdSsi/XrdSsiTaskReal.hh"
#include "XrdSsi/XrdSsiTrace.hh"
#include "XrdSsi/XrdSsiUtils.hh"
#include "XrdSys/XrdSysError.hh"
#include "XrdSys/XrdSysHeaders.hh"
#include "Xrd/XrdScheduler.hh"
using namespace XrdSsi;
/******************************************************************************/
/* L o c a l M a c r o s */
/******************************************************************************/
#define DUMPIT(x,y) XrdSsiUtils::b2x(x,y,hexBuff,sizeof(hexBuff),dotBuff)<SendError();
delete this;
}
SchedEmsg(XrdSsiTaskReal *tP) : taskP(tP) {}
~SchedEmsg() {}
private:
XrdSsiTaskReal *taskP;
};
}
/******************************************************************************/
/* Private: A s k 4 R e s p */
/******************************************************************************/
// Called with session mutex locked and returns with it unlocked!
bool XrdSsiTaskReal::Ask4Resp()
{
EPNAME("Ask4Resp");
XrdCl::XRootDStatus epStatus;
XrdSsiRRInfo rInfo;
XrdCl::Buffer qBuff(sizeof(unsigned long long));
// Disable read recovery
//
sessP->epFile.SetProperty(pName, pValue);
// Compose request to wait for the response
//
rInfo.Id(tskID); rInfo.Cmd(XrdSsiRRInfo::Rwt);
memcpy(qBuff.GetBuffer(), rInfo.Data(), sizeof(long long));
// Do some debugging
//
DEBUG("Calling fcntl id=" <epFile.Fcntl(qBuff, (ResponseHandler *)this, tmOut);
// Dianose any errors. If any occurred we simply return an error response but
// otherwise let this go as it really is not a logic error.
//
if (!epStatus.IsOK()) return RespErr(&epStatus);
mhPend = true;
defer = false;
tStat = isSync;
sessP->UnLock();
return true;
}
/******************************************************************************/
/* D e t a c h */
/******************************************************************************/
void XrdSsiTaskReal::Detach(bool force)
{ tStat = isDead;
if (force) sessP = &voidSession;
}
/******************************************************************************/
/* F i n i s h e d */
/******************************************************************************/
// Note that if we are called then Finished() must have been called while we
// were still in the open phase.
void XrdSsiTaskReal::Finished(XrdSsiRequest &rqstR,
const XrdSsiRespInfo &rInfo, bool cancel)
{
EPNAME("TaskReqFin");
XrdSsiMutexMon rHelp(sessP->MutexP());
// Do some debugging
//
DEBUG("Request="<<&rqstR<<" cancel="<Get(buffP);
if (!buffP || !(cdP = buffP->GetBuffer()))
{DEBUG("Responding with stream id=" <GetSize()) < sizeof(XrdSsiRRInfoAttn)) return isBad;
mdP = (XrdSsiRRInfoAttn *)cdP;
mdL = ntohl(mdP->mdLen);
pxL = ntohs(mdP->pfxLen);
dbL = n - mdL - pxL;
if (pxL < sizeof(XrdSsiRRInfoAttn) || dbL < 0) return isBad;
// This may be an alert message, check for that now
//
if (mdP->tag == XrdSsiRRInfoAttn::alrtResp)
{char hexBuff[16],dotBuff[4];
dbuff = cdP+pxL; dbL = mdL;
DEBUG("Posting " <