XRootD
Loading...
Searching...
No Matches
XrdOfsTPCJob Class Reference

#include <XrdOfsTPCJob.hh>

+ Inheritance diagram for XrdOfsTPCJob:
+ Collaboration diagram for XrdOfsTPCJob:

Public Member Functions

 XrdOfsTPCJob (const char *Url, const char *Org, const char *Lfn, const char *Pfn, const char *Cks, short lfnLoc[2], const char *Spr, const char *Tpr)
 
 ~XrdOfsTPCJob ()
 
void Del ()
 
XrdOfsTPCJobDone (XrdOfsTPCProg *pgmP, const char *eTxt, int rc)
 
int Sync (XrdOucErrInfo *eRR)
 
- Public Member Functions inherited from XrdOfsTPC
 XrdOfsTPC ()
 
 XrdOfsTPC (const char *Url, const char *Org, const char *Lfn, const char *Pfn, const char *Cks=0, const char *Spr=0, const char *Tpr=0)
 
virtual ~XrdOfsTPC ()
 

Additional Inherited Members

- Static Public Member Functions inherited from XrdOfsTPC
static const char * AddAuth (const char *auth, const char *avar)
 
static void Allow (char *vDN, char *vGN, char *vHN, char *vVO)
 
static int Authorize (XrdOfsTPC **theTPC, Facts &Args, int isPLE=0)
 
static const char * credPath ()
 
static void Init ()
 
static void Init (XrdAccAuthorize *accP)
 
static void Require (const char *Auth, int RType)
 
static int Restrict (const char *Path)
 
static int Start ()
 
static int Validate (XrdOfsTPC **theTPC, Facts &Args)
 
- Public Attributes inherited from XrdOfsTPC
XrdOfsTPCInfo Info
 
- Static Public Attributes inherited from XrdOfsTPC
static const int reqALL = 0
 
static const int reqDST = 1
 
static const int reqORG = 2
 
- Static Protected Member Functions inherited from XrdOfsTPC
static int Death (Facts &Args, const char *eMsg, int eCode, int nomsg=0)
 
static int Fatal (Facts &Args, const char *eMsg, int eCode, int nomsg=0)
 
static int genOrg (const XrdSecEntity *client, char *Buff, int Blen)
 
static int getTTL (XrdOucEnv *Env)
 
static int Screen (Facts &Args, XrdOucTList *tP, int wasEnc=0)
 
static char * Verify (const char *Who, const char *Name, char *Buf, int Blen)
 
- Protected Attributes inherited from XrdOfsTPC
char inQ
 
char Refs
 
- Static Protected Attributes inherited from XrdOfsTPC
static XrdOfsTPCAllowALList = 0
 
static XrdOucTListAuthDst = 0
 
static XrdOucTListAuthOrg = 0
 
static char * cPath = 0
 
static XrdAccAuthorizefsAuth = 0
 
static XrdOucPListAnchorRPList
 

Detailed Description

Definition at line 38 of file XrdOfsTPCJob.hh.

Constructor & Destructor Documentation

◆ XrdOfsTPCJob()

XrdOfsTPCJob::XrdOfsTPCJob ( const char * Url,
const char * Org,
const char * Lfn,
const char * Pfn,
const char * Cks,
short lfnLoc[2],
const char * Spr,
const char * Tpr )

Definition at line 56 of file XrdOfsTPCJob.cc.

60 : XrdOfsTPC(Url, Org, Lfn, Pfn, Cks, Spr, Tpr),
61 Next(0), myProg(0), eCode(0), Status(isWaiting)
62{ lfnPos[0] = lfnLoc[0]; lfnPos[1] = lfnLoc[1]; }

◆ ~XrdOfsTPCJob()

XrdOfsTPCJob::~XrdOfsTPCJob ( )
inline

Definition at line 53 of file XrdOfsTPCJob.hh.

53{}

Member Function Documentation

◆ Del()

void XrdOfsTPCJob::Del ( )
virtual

Reimplemented from XrdOfsTPC.

Definition at line 68 of file XrdOfsTPCJob.cc.

69{
70 XrdOfsTPCJob *pP = 0;
71 bool tpcCan = false;
72
73// Remove from queue if we are still in the queue
74//
75 jobMutex.Lock();
76 if (inQ)
77 {if (this == jobQ) jobQ = Next;
78 else {pP = jobQ;
79 while(pP && pP->Next != this) pP = pP->Next;
80 if (pP) pP->Next = Next;
81 }
82 if (this == jobLast) jobLast = pP;
83 inQ = 0; tpcCan = true;
84 } else if (Status == isRunning && myProg)
85 {myProg->Cancel(); tpcCan = true;}
86
87 if (tpcCan && Info.cbP)
88 {Refs++; // Make sure this object cannot get deleted
89 Info.Reply(SFS_ERROR, ECANCELED, "destination file prematurely closed",
90 &jobMutex); // Mutex is unlocked upon return!
91 jobMutex.Lock();
92 Refs--; // Undo the extra ref increase
93 }
94
95// Delete the element if possible
96//
97 if (Refs <= 1) {jobMutex.UnLock(); delete this;}
98 else {Refs--; jobMutex.UnLock();}
99}
#define SFS_ERROR
XrdOucCallBack * cbP
void Reply(int rC, int eC, const char *eMsg, XrdSysMutex *mP=0)
XrdOfsTPCInfo Info
Definition XrdOfsTPC.hh:109

References XrdOfsTPCProg::Cancel(), XrdOfsTPCInfo::cbP, XrdOfsTPC::Info, XrdOfsTPC::inQ, XrdSysMutex::Lock(), XrdOfsTPC::Refs, XrdOfsTPCInfo::Reply(), SFS_ERROR, and XrdSysMutex::UnLock().

+ Here is the call graph for this function:

◆ Done()

XrdOfsTPCJob * XrdOfsTPCJob::Done ( XrdOfsTPCProg * pgmP,
const char * eTxt,
int rc )

Definition at line 105 of file XrdOfsTPCJob.cc.

106{
107 XrdSysMutexHelper jobMon(&jobMutex);
108 XrdOfsTPCJob *jP;
109
110// Indicate job status
111//
112 eCode = rc; Status = isDone;
113 if (Info.Key) free(Info.Key);
114 Info.Key = (rc ? strdup(eTxt) : 0);
115
116// Check if we need to do a callback
117//
118 if (Info.cbP)
119 {if (rc) Info.Reply(SFS_ERROR, rc, eTxt);
120 else Info.Reply(SFS_OK, 0, "");
121 }
122
123// Check if anyone is waiting for a program
124//
125 if ((jP = jobQ))
126 {if (jP == jobLast) jobQ = jobLast = 0;
127 else jobQ = jP->Next;
128 jP->myProg = pgmP; jP->Refs++; jP->inQ = 0; jP->Status = isRunning;
129 if (jP->Info.cbP) jP->Info.Reply(SFS_OK, 0, "");
130 }
131
132// Free up this job and return the next job, if any
133//
134 myProg = 0;
135 if (Refs <= 1) delete this;
136 else Refs--;
137 return jP;
138}
#define SFS_OK

References XrdOfsTPCInfo::cbP, XrdOfsTPC::Info, XrdOfsTPC::inQ, XrdOfsTPCInfo::Key, XrdOfsTPC::Refs, XrdOfsTPCInfo::Reply(), SFS_ERROR, and SFS_OK.

Referenced by XrdOfsTPCProg::Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Sync()

int XrdOfsTPCJob::Sync ( XrdOucErrInfo * eRR)
virtual

Reimplemented from XrdOfsTPC.

Definition at line 144 of file XrdOfsTPCJob.cc.

145{
146 static const int cbWaitTime = 1800;
147 XrdSysMutexHelper jobMon(&jobMutex);
148 int rc;
149
150// If we are running then simply wait for the copy to complete
151//
152 if (Status == isRunning)
153 {if (Info.SetCB(eRR)) return SFS_ERROR;
154 eRR->setErrCode(cbWaitTime);
155 Info.Engage();
156 return SFS_STARTED;
157 }
158
159// If we are done then return what we have (this can't change)
160//
161 if (Status == isDone)
162 {if (eCode) {eRR->setErrInfo(eCode, Info.Key); return SFS_ERROR;}
163 return SFS_OK;
164 }
165
166// The only thing left is that we are an unstarted job, so try to start it.
167//
168 if (inQ) {myProg = 0; rc = 0;}
169 else if ((myProg = XrdOfsTPCProg::Start(this, rc)))
170 {Refs++; Status = isRunning; return SFS_OK;}
171
172// We could not allocate a program to this job. Check if this is due to an err
173//
174 if (rc)
175 {OfsEroute.Emsg("TPC", rc, "create tpc job thread");
176 Status = isDone;
177 eCode = ECANCELED;
178 if (Info.Key) free(Info.Key);
179 Info.Key = strdup("Copy failed; resources unavailable.");
180 return Info.Fail(eRR, "resources unavailable", ECANCELED);
181 }
182
183// No programs available, place this job in callback mode
184//
185 if (Info.SetCB(eRR)) return SFS_ERROR;
186 if (jobLast) {jobLast->Next = this; jobLast = this;}
187 else jobQ = jobLast = this;
188 inQ = 1;
189 eRR->setErrCode(cbWaitTime);
190 Info.Engage();
191 return SFS_STARTED;
192}
XrdSysError OfsEroute(0)
#define SFS_STARTED
int SetCB(XrdOucErrInfo *eRR)
int Fail(XrdOucErrInfo *eRR, const char *eMsg, int eCode)
static XrdOfsTPCProg * Start(XrdOfsTPCJob *jP, int &rc)
int setErrInfo(int code, const char *emsg)
int setErrCode(int code)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)

References XrdSysError::Emsg(), XrdOfsTPCInfo::Engage(), XrdOfsTPCInfo::Fail(), XrdOfsTPC::Info, XrdOfsTPC::inQ, XrdOfsTPCInfo::Key, OfsEroute, XrdOfsTPC::Refs, XrdOfsTPCInfo::SetCB(), XrdOucErrInfo::setErrCode(), XrdOucErrInfo::setErrInfo(), SFS_ERROR, SFS_OK, SFS_STARTED, and XrdOfsTPCProg::Start().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: