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