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 <stdio.h>
00033
00034 #include "XrdSsi/XrdSsiErrInfo.hh"
00035 #include "XrdSsi/XrdSsiEvent.hh"
00036 #include "XrdSsi/XrdSsiPacer.hh"
00037 #include "XrdSsi/XrdSsiStream.hh"
00038 #include "XrdSsi/XrdSsiResponder.hh"
00039
00040 class XrdSsiRequest;
00041 class XrdSsiSessReal;
00042 class XrdSysSemaphore;
00043
00044 class XrdSsiTaskReal : public XrdSsiEvent, public XrdSsiPacer,
00045 public XrdSsiResponder, public XrdSsiStream
00046 {
00047 public:
00048
00049 enum TaskStat {isPend=0, isWrite, isSync, isReady, isDone, isDead};
00050
00051 void Detach(bool force=false);
00052
00053 void Finished( XrdSsiRequest &rqstR,
00054 const XrdSsiRespInfo &rInfo,
00055 bool cancel=false);
00056
00057 void *Implementation() {return (void *)this;}
00058
00059 bool Kill();
00060
00061 inline
00062 int ID() {return tskID;}
00063
00064 inline
00065 void Init(XrdSsiRequest *rP, unsigned short tmo=0)
00066 {rqstP = rP, tStat = isPend; tmOut = tmo; wPost = 0;
00067 mhPend = false; defer = false;
00068 attList.next = attList.prev = this;
00069 if (mdResp) {delete mdResp; mdResp = 0;}
00070 }
00071
00072 void PostError();
00073
00074 void Redrive();
00075 const
00076 char *RequestID() {return rqstP->GetRequestID();}
00077
00078 void SchedError(XrdSsiErrInfo *eInfo=0);
00079
00080 void SendError();
00081
00082 bool SendRequest(const char *node);
00083
00084 int SetBuff(XrdSsiErrInfo &eRef, char *buff, int blen, bool &last);
00085
00086 bool SetBuff(XrdSsiErrInfo &eRef, char *buff, int blen);
00087
00088 void SetTaskID(uint32_t tid, uint32_t sid)
00089 {tskID = tid;
00090 snprintf(tident, sizeof(tident), "T %u#%u", sid, tid);
00091 }
00092
00093 bool XeqEvent(XrdCl::XRootDStatus *status, XrdCl::AnyObject **respP);
00094
00095 XrdSsiTaskReal(XrdSsiSessReal *sP)
00096 : XrdSsiStream(XrdSsiStream::isPassive),
00097 sessP(sP), mdResp(0), wPost(0), tskID(0),
00098 mhPend(false), defer(false)
00099 {}
00100
00101 ~XrdSsiTaskReal() {if (mdResp) delete mdResp;}
00102
00103 struct dlQ {XrdSsiTaskReal *next; XrdSsiTaskReal *prev;};
00104 dlQ attList;
00105
00106 enum respType {isBad=0, isAlert, isData, isStream};
00107
00108 private:
00109
00110 bool Ask4Resp();
00111 respType GetResp(XrdCl::AnyObject **respP, char *&dbuf, int &dlen);
00112 bool RespErr(XrdCl::XRootDStatus *status);
00113 bool XeqEnd(bool getLock);
00114
00115 XrdSsiErrInfo errInfo;
00116 XrdSsiSessReal *sessP;
00117 XrdSsiRequest *rqstP;
00118 XrdCl::AnyObject *mdResp;
00119 XrdSysSemaphore *wPost;
00120 char *dataBuff;
00121 int dataRlen;
00122 TaskStat tStat;
00123 uint32_t tskID;
00124 unsigned short tmOut;
00125 bool mhPend;
00126 bool defer;
00127 };
00128 #endif