24#include "XrdNet/XrdNet.hh"
131 memcpy((
void *)&sid, (
const void *)&(
p->Request()->header.streamid[0]), 2);
159 if (cid >= (
int)
fClients.capacity()) {
219 XPDFORM(
msg,
"new capacity = %d, size = %d, ic = %d, xps = %p",
259 emsg =
"instance in use or undefined! protocol error";
304 std::vector<XrdProofdProofServ *>::iterator
ip;
309 if (
xps &&
xps->SrvPID() ==
p->Pid())
339 std::vector<XrdProofdProofServ *>::iterator
ip;
363 std::vector<XrdProofdProofServ *>::iterator
ip;
368 TRACE(
DBG,
"found potentially valid topmaster session: pid "<<
xps->SrvPID());
425 TRACE(
DBG,
"cid: "<< cid <<
", p: " <<
p);
430 if (cid >= 0 && cid < (
int)
fClients.size()) {
436 memcpy((
void *)&sid, (
const void *)&(
p->Request()->header.streamid[0]), 2);
462 if (cid->
P()->
Link()) {
521 if (!
xps || !(
xps->IsValid())) {
522 TRACE(
XERR,
" session undefined or invalid");
527 XrdOucString path(
xps->AdminPath());
528 if (path.length() <= 0) {
529 TRACE(
XERR,
"admin path is empty! - protocol error");
536 if (stat(path.c_str(), &
st0) != 0) {
537 TRACE(
XERR,
"cannot stat admin path: "<<path);
541 if (
now >=
st0.st_mtime && (
now -
st0.st_mtime) <= 1)
return 1;
542 TRACE(
ALL,
"admin path: "<<path<<
", mtime: "<<
st0.st_mtime <<
", now: "<<
now);
545 int pid =
xps->SrvPID();
549 if (
xps->VerifyProofServ(0) != 0) {
550 TRACE(
XERR,
"could not send verify request to proofsrv");
559 if (stat(path.c_str(), &
st1) == 0) {
560 if (
st1.st_mtime >
st0.st_mtime) {
565 TRACE(
HDBG,
"waiting "<<ns<<
" secs for session "<<pid<<
566 " to touch the admin path");
568 XPDFORM(
notmsg,
"verifying existing sessions, %d seconds ...", ns);
591 std::vector<XrdProofdProofServ *>::iterator
ip;
596 if (active) active->push_back(
xps);
598 if (
xps->SrvPID() > 0) {
599 if (
emsg.length() <= 0)
600 emsg =
"ignoring (apparently) non-responding session(s): ";
605 TRACE(
ALL,
"session "<<
xps->SrvPID()<<
" does not react: dead?");
610 TRACE(
HDBG,
"found: " << active->size() <<
" sessions");
622 XrdOucString out, buf;
625 std::list<XrdProofdProofServ *> active;
630 out += (
int) active.size();
631 std::list<XrdProofdProofServ *>::iterator
ia;
632 for (
ia = active.begin();
ia != active.end(); ++
ia) {
633 if ((
xps = *
ia) &&
xps->IsValid()) {
668 XrdOucString tag =
"-";
677 buf.erase(0, buf.rfind(
'/') + 1);
678 TRACE(
DBG,
"posting kSessionRemoval with: '"<<buf<<
"'");
680 TRACE(
XERR,
"problem posting the pipe; errno: "<<-
rc);
698 std::vector<XrdProofdProofServ *>::iterator
ip;
701 if (*
ip) (*ip)->Reset();
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 char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
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
R__EXTERN C unsigned int sleep(unsigned int seconds)
#define kXPD_ClientMaster
#define XrdSysMutexHelper
XrdProofdResponse * R() const
void SetP(XrdProofdProtocol *p)
XrdProofdProtocol * P() const
void SetSid(unsigned short sid)
static int GetUserInfo(const char *usr, XrdProofUI &ui)
Get information about user 'usr' in a thread safe way.
static int AssertDir(const char *path, XrdProofUI ui, bool changeown)
Make sure that 'path' exists and is owned by the entity described by 'ui'.
static int VerifyProcessByID(int pid, const char *pname="proofserv")
Check if a process named 'pname' and process 'pid' is still in the process table.
std::vector< XrdClientID * > fClients
virtual ~XrdProofdClient()
Destructor.
void TerminateSessions(int srvtype, XrdProofdProofServ *ref, const char *msg, XrdProofdPipe *pipe, bool changeown)
Terminate client sessions; IDs of signalled processes are added to sigpid.
int ReserveClientID(int cid)
Reserve a client ID.
int GetTopServers()
Return the number of valid proofserv topmaster sessions in the list.
XrdProofdProofServ * GetFreeServObj()
Get next free server ID.
int GetClientID(XrdProofdProtocol *p)
Get next free client ID.
XrdOucString ExportSessions(XrdOucString &emsg, XrdProofdResponse *r=0)
Return a string describing the existing sessions.
const char * Group() const
const char * User() const
int ResetClientSlot(int ic)
Reset slot at 'ic'.
void Broadcast(const char *msg)
Broadcast message 'msg' to the connected clients.
bool VerifySession(XrdProofdProofServ *xps, XrdProofdResponse *r=0)
Quick verification of session 'xps' to avoid attaching clients to non responding sessions.
void ResetSessions()
Reset this instance.
XrdProofdProofServ * GetServer(int psid)
Get from the vector server instance with ID psid.
std::vector< XrdProofdProofServ * > fProofServs
int Touch(bool reset=0)
Send a touch the connected clients: this will remotely touch the associated TSocket instance and sche...
void EraseServer(int psid)
Erase server with id psid from the list.
XrdProofdProofServ * GetServObj(int id)
Get server at 'id'. If needed, increase the vector size.
int SetClientID(int cid, XrdProofdProtocol *p)
Set slot cid to instance 'p'.
XrdProofdSandbox fSandbox
XrdProofdProtocol * GetProtocol(int ic)
Return protocol attached to client slot at 'ic'.
bool Match(const char *usr, const char *grp=0)
return TRUE if this instance matches 'id' (and 'grp', if defined)
void SkipSessionsCheck(std::list< XrdProofdProofServ * > *active, XrdOucString &emsg, XrdProofdResponse *r=0)
Skip the next sessions status check.
XrdProofdClient(XrdProofUI ui, bool master, bool changeown, XrdSysError *edest, const char *tmp, int rtime)
Constructor.
const char * AdminPath() const
int TerminateProofServ(bool changeown)
Terminate the associated process.
void Reset()
Reset this instance.
short int ProofProtocol() const
int Send(void)
Auxilliary Send method.
int GuessTag(XrdOucString &tag, int ridx=1)
Guess session tag completing 'tag' (typically "-<pid>") by scanning the active session file or the se...
int RemoveSession(const char *tag)
Move record for tag from the active sessions file to the old sessions file (<SandBox>/....
int changeown(const std::string &path, uid_t u, gid_t g)
Change the ownership of 'path' to the entity described by {u,g}.