00001 #ifndef __XRDSSITASKREAL_HH__
00002 #define __XRDSSITASKREAL_HH__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "XrdSsi/XrdSsiErrInfo.hh"
00033 #include "XrdSsi/XrdSsiEvent.hh"
00034 #include "XrdSsi/XrdSsiPacer.hh"
00035 #include "XrdSsi/XrdSsiStream.hh"
00036 #include "XrdSsi/XrdSsiResponder.hh"
00037
00038 class XrdSsiRequest;
00039 class XrdSsiSessReal;
00040 class XrdSysSemaphore;
00041
00042 class XrdSsiTaskReal : public XrdSsiEvent, public XrdSsiPacer,
00043 public XrdSsiResponder, public XrdSsiStream
00044 {
00045 public:
00046
00047 enum TaskStat {isPend=0, isWrite, isSync, isReady, isDone, isDead};
00048
00049 void Detach(bool force=false);
00050
00051 void Finished( XrdSsiRequest &rqstR,
00052 const XrdSsiRespInfo &rInfo,
00053 bool cancel=false);
00054
00055 void *Implementation() {return (void *)this;}
00056
00057 bool Kill();
00058
00059 inline
00060 int ID() {return tskID;}
00061
00062 inline
00063 void Init(XrdSsiRequest *rP, unsigned short tmo=0)
00064 {rqstP = rP, tStat = isPend; tmOut = tmo; wPost = 0;
00065 mhPend = false; defer = false;
00066 attList.next = attList.prev = this;
00067 if (mdResp) {delete mdResp; mdResp = 0;}
00068 }
00069
00070 void PostError();
00071
00072 void Redrive();
00073 const
00074 char *RequestID() {return rqstP->GetRequestID();}
00075
00076 void SchedError(XrdSsiErrInfo *eInfo=0);
00077
00078 void SendError();
00079
00080 bool SendRequest(const char *node);
00081
00082 int SetBuff(XrdSsiErrInfo &eRef, char *buff, int blen, bool &last);
00083
00084 bool SetBuff(XrdSsiErrInfo &eRef, char *buff, int blen);
00085
00086 void SetTaskID(uint32_t tid) {tskID = tid;}
00087
00088 bool XeqEvent(XrdCl::XRootDStatus *status, XrdCl::AnyObject **respP);
00089
00090 XrdSsiTaskReal(XrdSsiSessReal *sP)
00091 : XrdSsiEvent("TaskReal"),
00092 XrdSsiStream(XrdSsiStream::isPassive),
00093 sessP(sP), mdResp(0), wPost(0), tskID(0),
00094 mhPend(false), defer(false)
00095 {}
00096
00097 ~XrdSsiTaskReal() {if (mdResp) delete mdResp;}
00098
00099 struct dlQ {XrdSsiTaskReal *next; XrdSsiTaskReal *prev;};
00100 dlQ attList;
00101
00102 enum respType {isBad=0, isAlert, isData, isStream};
00103
00104 private:
00105
00106 bool Ask4Resp();
00107 respType GetResp(XrdCl::AnyObject **respP, char *&dbuf, int &dlen);
00108 bool RespErr(XrdCl::XRootDStatus *status);
00109 bool XeqEnd(bool getLock);
00110
00111 XrdSsiErrInfo errInfo;
00112 XrdSsiSessReal *sessP;
00113 XrdSsiRequest *rqstP;
00114 XrdCl::AnyObject *mdResp;
00115 XrdSysSemaphore *wPost;
00116 char *dataBuff;
00117 int dataRlen;
00118 TaskStat tStat;
00119 uint32_t tskID;
00120 unsigned short tmOut;
00121 bool mhPend;
00122 bool defer;
00123 };
00124 #endif