28#include "XrdOuc/XrdOucStream.hh"
30#include "XrdVersion.hh"
31#include "Xrd/XrdBuffer.hh"
32#include "Xrd/XrdScheduler.hh"
59 "xproofd protocol anchor");
81#define XPDCOND(n,ns) ((n == -1 && ns == -1) || (n > 0 && n >= ns))
84#define XPDSETSTRING(n,ns,c,s) \
85 { if (XPDCOND(n,ns)) { \
86 SafeFree(c); c = strdup(s.c_str()); ns = n; }}
90#define XPDADOPTSTRING(n,ns,c,s) \
92 XPDSETSTRING(n, ns, t, s); \
93 if (t && strlen(t)) { \
100#define XPDSETINT(n,ns,i,s) \
101 { if (XPDCOND(n,ns)) { \
102 i = strtol(s.c_str(),0,10); ns = n; }}
156 XrdOucString port(val);
157 if (
d->fName ==
"xrd.protocol") {
158 port = cfg->GetWord();
159 port.replace(
"xproofd:",
"");
160 }
else if (
d->fName !=
"port") {
163 if (port.length() > 0) {
170#if (ROOTXRDVERS >= 300030000)
206 if (
pcfg.fPort > 0) {
265 msg +=
" new capacity: ";
273 msg +=
"; new size: ";
307 if (dlen <= 0)
lp->setEtext(
"Match: handshake not received");
312 emsg =
"rootd-file serving not supported any-longer";
314 if (
emsg.length() > 0) {
315 lp->setEtext(
emsg.c_str());
317 lp->setEtext(
"link transfered");
321 TRACE(
XERR,
"peeked incomplete or empty information! (dlen: "<<dlen<<
" bytes)");
332 TRACE(
ALL,
"matched xrootd protocol on link: serving a file");
334 TRACE(
XERR,
"failed to match any known or enabled protocol");
341 lp->setEtext(
"Match: handshake failed");
349 lp->setEtext(
"Match: reread failed");
366 if (
xpp->GetData(
"dummy",(
char *)&dum[0],
sizeof(dum)) != 0) {
382 static char statfmt[] =
"<stats id=\"xproofd\"><num>%ld</num></stats>";
417 std::vector<XrdProofdResponse *>::iterator
ii =
fResponses.begin();
456 fgProtStack.Set((pi->ConnMax/3 ? pi->ConnMax/3 : 30), 60*60);
480 if (
fgMgr->Config(0))
return 0;
481 mp =
"global manager created";
486 " build "<<
XrdVERSION<<
" successfully loaded");
534 return fLink->setEtext(
"Process: protocol data length error");
631 const char *
srvtype[6] = {
"ANY",
"MasterWorker",
"MasterMaster",
632 "ClientMaster",
"Internal",
"Admin"};
655 TRACE(
REQ,
"External disconnection of protocol associated with pid "<<
fPid);
659 discpath.replace(
"/cid",
"/disconnected");
673 fgMgr->SessionMgr()->DisconnectFromProofServ(
fPid);
675 TRACE(
REQ,
"Non-destroyed proofserv processes attached to this protocol ("<<
this<<
676 "), setting reconnect time");
677 fgMgr->SessionMgr()->SetReconnectTime(
true);
679 fgMgr->SessionMgr()->CheckActiveSessions(0);
682 <<(
fgMgr ?
fgMgr->SessionMgr() : (
void *) -1)<<
")")
694 fgMgr->SessionMgr()->DeleteFromSessions(buf.c_str());
696 fgMgr->SessionMgr()->MvSession(buf.c_str());
742 ") = insufficient memory");
745 ", buff: "<<(
void *)(
argp->buff)<<
", bsize:"<<
argp->bsize);
778 XrdOucString
emsg =
"link read error: errno: ";
816 if (!
argp)
return -1;
837 XPDFORM(
msg,
"EXT: server ID: %d, problems sending: %d bytes to server",
850 XPDFORM(
msg,
"INT: client ID: %d, problems sending: %d bytes to client",
892 if (!
argp)
return -1;
929 static const char *
crecv[5] = {
"master proofserv",
"top master",
930 "client",
"undefined",
"any"};
956 XPDFORM(
msg,
"EXT: sending %d bytes to proofserv (psid: %d, xps: %p, status: %d,"
980 XPDFORM(
msg,
"INT: sending %d bytes to client/master (psid: %d, xps: %p, status: %d)",
1000 xps->DeleteStartMsg();
1017 "SendMsg: INT: session is reconnecting: retry later");
1024 "SendMsg: INT: session is reconnecting: retry later");
1033 int ii =
xps->SrvType();
1054 unsigned int rc = 0;
1083 if (!
xps->Response()) {
1084 response->Send(
kXP_InvalidRequest,
"Urgent: session response object undefined - do nothing");
1089 int len = 3 *
sizeof(kXR_int32);
1090 char *buf =
new char[
len];
1095 itmp =
static_cast<kXR_int32
>(
htonl(int1));
1096 memcpy(buf +
sizeof(kXR_int32), &
itmp,
sizeof(kXR_int32));
1098 itmp =
static_cast<kXR_int32
>(
htonl(int2));
1099 memcpy(buf + 2 *
sizeof(kXR_int32), &
itmp,
sizeof(kXR_int32));
1103 "Urgent: could not propagate request to proofsrv");
1148 XPDFORM(
msg,
"xps: %p, link ID: %s, proofsrv PID: %d",
1149 xps,
xps->Response()->TraceID(),
xps->SrvPID());
1155 "Interrupt: could not propagate interrupt code to proofsrv");
1210 kXR_int32
checkfq =
fgMgr->SessionMgr()->CheckFrequency();
1219 XrdOucString path(
xps->AdminPath());
1220 if (path.length() <= 0) {
1223 response->Send(
kXP_ServerError,
"EXT: admin path is empty! - protocol error");
1233 if (stat(path.c_str(), &
st0) != 0) {
1241 int pid =
xps->SrvPID();
1247 if (
xps->VerifyProofServ(1) != 0) {
1250 response->Send(
kXP_ServerError,
"EXT: could not verify reuqest to proofsrv");
1257 if (stat(path.c_str(), &
st1) == 0) {
1258 if (
st1.st_mtime >
st0.st_mtime) {
1265 " to touch the admin path");
1284 int len =
sizeof(kXR_int32);
1285 char *buf =
new char[
len];
1287 kXR_int32
ifw = (kXR_int32)0;
1293 }
else if (
psid > -1) {
1315 int pid = (
xps) ?
xps->SrvPID() : -1;
1317 TRACE(
XERR,
"undefined session or process id");
1324 buf.c_str()) != 0) {
1325 TRACE(
XERR,
"problem posting the prority manager pipe");
1331 TRACE(
DBG,
"posting the scheduler pipe");
1333 TRACE(
XERR,
"problem posting the scheduler pipe");
1340 TRACE(
XERR,
"problem posting the session manager pipe");
1365 apath.replace(
"/activesessions/",
"/terminatedsessions/");
1366 apath.replace(
".status",
"");
1370 const char *
type =
Internal() ?
"internal" :
"external";
1395 if (
fgMgr->NetMgr()) {
1396 fgMgr->NetMgr()->BroadcastCtrlC(
Client()->User());
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define TRACE(Flag, Args)
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
R__EXTERN C unsigned int sleep(unsigned int seconds)
#define kXPD_ClientMaster
#define kXPD_startprocess
int DoDirectiveClass(XrdProofdDirective *, char *val, XrdOucStream *cfg, bool rcf)
Generic class directive processor.
static XrdSysLogger gMainLogger
XrdProtocol * XrdgetProtocol(const char *, char *parms, XrdProtocol_Config *pi)
This protocol is meant to live in a shared library.
int XrdgetProtocolPort(const char *, char *, XrdProtocol_Config *pi)
This function is called early on to determine the port we need to use.
struct ResetCtrlcGuard ResetCtrlcGuard_t
XrdOucTrace * XrdProofdTrace
#define XPD_SETRESPV(p, x)
#define XPD_SETRESP(p, x)
#define TRACESET(act, on)
R__EXTERN XrdOucTrace * XrdProofdTrace
#define TRACET(tid, act, x)
#define XrdSysMutexHelper
XrdProofdProtocol * objectItem()
void setItem(XrdProofdProtocol *ival)
static int Touch(const char *path, int opt=0)
Set access (opt == 1), modify (opt =2 ) or access&modify (opt = 0, default) times of path to current ...
static int VerifyProcessByID(int pid, const char *pname="proofserv")
Check if a process named 'pname' and process 'pid' is still in the process table.
static const char * ProofRequestTypes(int type)
Translates the proof request type in a human readable string.
const char * User() const
XrdProofdProofServ * GetServer(int psid)
Get from the vector server instance with ID psid.
int Touch(bool reset=0)
Send a touch the connected clients: this will remotely touch the associated TSocket instance and sche...
void Register(const char *dname, XrdProofdDirective *d)
XrdProofdProtCfg(const char *cfg, XrdSysError *edest=0)
Constructor.
void RegisterDirectives()
Register directives for configuration.
int DoDirective(XrdProofdDirective *, char *, XrdOucStream *, bool)
Parse directives.
static int Configure(char *parms, XrdProtocol_Config *pi)
Protocol configuration tool Function: Establish configuration at load time.
void Recycle(XrdLink *lp, int x, const char *y)
Recycle call. Release the instance and give it back to the stack.
int SendMsg()
Handle a request to forward a message to another process.
int SendData(XrdProofdProofServ *xps, kXR_int32 sid=-1, XrdSrvBuffer **buf=0, bool sb=0)
Send data over the open link. Segmentation is done here, if required.
XrdProofdResponse * Response(kXR_unt16 rid)
Get response instance corresponding to stream ID 'sid'.
XrdProofdResponse * GetNewResponse(kXR_unt16 rid)
Create new response instance for stream ID 'sid'.
static XrdSysRecMutex fgBMutex
static void PostSession(int on, const char *u, const char *g, XrdProofdProofServ *xps)
Post change of session status.
static XrdSysError fgEDest
XrdProofdClient * fPClient
int SendDataN(XrdProofdProofServ *xps, XrdSrvBuffer **buf=0, bool sb=0)
Send data over the open client links of session 'xps'.
static XpdObjectQ fgProtStack
XrdProtocol * Match(XrdLink *lp)
Check whether the request matches this protocol.
XrdProofdProtocol(XrdProtocol_Config *pi=0)
Protocol constructor.
static XrdProofdManager * fgMgr
XrdProofdClient * Client() const
int Process2()
Local processing method: here the request is dispatched to the appropriate method.
int CtrlC()
Set and propagate a Ctrl-C request.
int Stats(char *buff, int blen, int do_sync)
Return statistics info about the protocol.
static XrdBuffManager * fgBPool
std::vector< XrdProofdResponse * > fResponses
XrdSysRecMutex fCtrlcMutex
XrdSecProtocol * fAuthProt
void Reset()
Reset static and local vars.
int Process(XrdLink *lp)
Process the information received on the active link.
static XrdSysLogger * fgLogger
int Interrupt()
Handle an interrupt request.
static XrdBuffer * GetBuff(int quantum, XrdBuffer *argp=0)
Allocate a buffer to handle quantum bytes; if argp points to an existing buffer, its size is checked ...
void TouchAdminPath()
Recording time of the last request on this instance.
int Urgent()
Handle generic request of a urgent message to be forwarded to the server.
static int fgEUidAtStartup
const char * TraceID() const
XrdSecEntity * fSecClient
unsigned char fClntCapVer
int GetData(const char *dtype, char *buff, int blen)
Get data from the open link.
static void ReleaseBuff(XrdBuffer *argp)
Release a buffer previously allocated via GetBuff.
int Ping()
Handle a ping request.
void Set(XrdLink *l)
Set the link to be used by this response.
int Send(void)
Auxilliary Send method.
static int ChangePerm(uid_t uid, gid_t gid)
ResetCtrlcGuard(XrdProofdProtocol *p, int t)
struct ClientRequestHdr header
struct XPClientProofRequest proof
struct XPClientInterruptRequest interrupt
struct XPClientSendRcvRequest sendrcv