#include <XrdOucReqID.hh>
|
static int | Index (int KeyMax, const char *KeyVal, int KeyLen=0) |
|
Definition at line 41 of file XrdOucReqID.hh.
◆ XrdOucReqID() [1/2]
XrdOucReqID::XrdOucReqID |
( |
| ) |
|
Definition at line 53 of file XrdOucReqID.cc.
54{
55 char xbuff[256];
56 int eNow = static_cast<int>(time(0)), myPid = static_cast<int>(getpid());
57
58
59
60 snprintf(xbuff, sizeof(xbuff)-1, "%08X:%08x.%%d", myPid, eNow);
61 reqFMT = strdup(xbuff);
62 xbuff[8] = 0;
63 reqPFX = strdup(xbuff);
64 reqPFXlen = 8;
65 reqIntern = 0;
66 reqNum = 0;
67}
◆ XrdOucReqID() [2/2]
XrdOucReqID::XrdOucReqID |
( |
const XrdNetSockAddr * | myAddr, |
|
|
int | myPort = -1 ) |
Definition at line 71 of file XrdOucReqID.cc.
72{
73 char ybuff[256], xbuff[512];
74 unsigned int pHash;
75 int n, eNow = static_cast<unsigned int>(time(0));
76
77
78
80 n = sprintf(ybuff, "%04X%08X", myPort, eNow);
81 reqPFX = strdup(ybuff);
82 reqPFXlen = n;
83 reqIntern = n+1;
84
85
86
88
89
90
91 snprintf(xbuff, sizeof(xbuff)-1, "%s:%08x.%08x:%%d", ybuff, pHash, eNow);
92 reqFMT = strdup(xbuff);
93 reqNum = 0;
94}
static int Encode(const XrdNetSockAddr *sadr, char *buff, int blen, int port=-1)
static uint32_t CRC32(const unsigned char *data, int count)
References XrdOucCRC::CRC32(), and XrdNetUtils::Encode().
◆ ~XrdOucReqID()
XrdOucReqID::~XrdOucReqID |
( |
| ) |
|
|
inline |
◆ ID()
char * XrdOucReqID::ID |
( |
char * | buff, |
|
|
int | blen ) |
Definition at line 139 of file XrdOucReqID.cc.
140{
141 int myNum;
142
143
144
145 myMutex.Lock();
146 myNum = (reqNum += 1);
147 myMutex.UnLock();
148
149
150
151 snprintf(buff, blen-1, reqFMT, myNum);
152 return buff+reqIntern;
153}
Referenced by XrdOssSys::Stage_QT().
◆ Index()
int XrdOucReqID::Index |
( |
int | KeyMax, |
|
|
const char * | KeyVal, |
|
|
int | KeyLen = 0 ) |
|
static |
Definition at line 159 of file XrdOucReqID.cc.
160{
161 unsigned int pHash;
162
163
164
166 (KeyLen ? KeyLen : strlen(KeyVal)));
167 return (int)(pHash % KeyMax);
168}
References XrdOucCRC::CRC32().
◆ isMine()
char * XrdOucReqID::isMine |
( |
char * | reqid, |
|
|
int & | hport, |
|
|
char * | hname, |
|
|
int | hlen ) |
Definition at line 100 of file XrdOucReqID.cc.
101{
102 XrdNetAddr theAddr;
103 XrdNetSockAddr IP;
104 const char *theHost;
105 int thePort;
106 char *cp;
107
108
109
110 if (!strncmp(reqPFX,reqid,reqPFXlen) && (cp = index(reqid,':'))) return cp+1;
111
112
113
114 hport = 0;
115 if (!hlen) return 0;
116
117
118
120 if (thePort <= 0) return 0;
121
122
123
125 || !(theHost = theAddr.
Name())
126 || strlen(theHost) >= (unsigned int)hlen) return 0;
127
128
129
130 strcpy(hname, theHost);
131 hport = thePort;
132 return 0;
133}
const char * Name(const char *eName=0, const char **eText=0)
const char * Set(const char *hSpec, int pNum=PortInSpec)
static int Decode(XrdNetSockAddr *sadr, const char *buff, int blen)
References XrdNetSockAddr::Addr, XrdNetUtils::Decode(), XrdNetAddrInfo::Name(), and XrdNetAddr::Set().
◆ PFX()
char * XrdOucReqID::PFX |
( |
| ) |
|
|
inline |
The documentation for this class was generated from the following files: