XRootD
Loading...
Searching...
No Matches
XrdW41Gate Class Reference
Collaboration diagram for XrdW41Gate:

Public Member Functions

 XrdW41Gate ()
 ~XrdW41Gate ()

Static Public Member Functions

static void Serialize (XrdOucTList *gfP, int Wait=1)
static int Wait41 (XrdOucTList *fP)

Detailed Description

Definition at line 65 of file XrdWait41.cc.

Constructor & Destructor Documentation

◆ XrdW41Gate()

XrdW41Gate::XrdW41Gate ( )
inline

Definition at line 73 of file XrdWait41.cc.

73{}

◆ ~XrdW41Gate()

XrdW41Gate::~XrdW41Gate ( )
inline

Definition at line 74 of file XrdWait41.cc.

74{}

Member Function Documentation

◆ Serialize()

void XrdW41Gate::Serialize ( XrdOucTList * gfP,
int Wait = 1 )
static

Definition at line 224 of file XrdWait41.cc.

225{
226 FLOCK_t lock_args;
227 int Act, rc;
228
229// Establish locking options
230//
231 bzero(&lock_args, sizeof(lock_args));
232 lock_args.l_type = F_WRLCK;
233 Act = (Wait ? F_SETLKW : F_SETLK);
234
235// Now perform the action
236//
237 do {rc = fcntl(gfP->val, Act, &lock_args);} while(rc == -1 && errno == EINTR);
238
239// Determine result
240//
241 if (rc != -1) rc = 0;
242 else {rc = errno;
243 std::cerr <<"Serialize: " <<XrdSysE2T(rc) <<" locking FD " <<gfP->text <<std::endl;
244 }
245
246// Reflect what happened here
247//
248 gateMutex.Lock();
249 if (rc || gateOpen) close(gfP->val);
250 else gateOpen = 1;
251 gateSem.Post();
252 gateMutex.UnLock();
253}
int fcntl(int fd, int cmd,...)
#define close(a)
Definition XrdPosix.hh:43
const char * XrdSysE2T(int errcode)
Definition XrdSysE2T.cc:104
#define FLOCK_t

References close, fcntl(), FLOCK_t, XrdOucTList::text, and XrdSysE2T().

Referenced by XrdWait41::GateWait().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wait41()

int XrdW41Gate::Wait41 ( XrdOucTList * fP)
static

Definition at line 259 of file XrdWait41.cc.

260{
261 static const int AMode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
262 pthread_t tid;
263 const char *eTxt;
264 int rc, Num = 0;
265
266// Run through the chain of files setting up a wait. We try to do a fast
267// redispatch in case we get a lock early.
268//
269 while(gfP)
270 {if (Num)
271 {gateMutex.Lock();
272 if (gateOpen) {gateMutex.UnLock(); return 1;}
273 gateMutex.UnLock();
274 }
275 if ((gfP->val = open(gfP->text, O_CREAT|O_RDWR, AMode)) < 0)
276 {eTxt = XrdSysE2T(errno);
277 std::cerr <<"Wait41: " <<eTxt <<" opening " <<gfP->text <<std::endl;
278 }
279 else if ((rc = XrdSysThread::Run(&tid, GateWait, (void *)gfP,
280 XRDSYSTHREAD_BIND, "Gate Wait")))
281 {eTxt = XrdSysE2T(errno);
282 std::cerr <<"Wait41: " <<eTxt <<" creating gate thread for "
283 <<gfP->text <<std::endl;
284 close(gfP->val);
285 } else Num++;
286 gfP = gfP->next;
287 }
288
289// At this point we will have to wait for the lock if we have any threads
290//
291 while(Num--)
292 {gateSem.Wait();
293 gateMutex.Lock();
294 if (gateOpen) {gateMutex.UnLock(); return 1;}
295 gateMutex.UnLock();
296 }
297
298// No such luck, every thread failed
299//
300 return 0;
301}
#define open
Definition XrdPosix.hh:71
#define XRDSYSTHREAD_BIND
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
void * GateWait(void *parg)
Definition XrdWait41.cc:99

References close, XrdWait41::GateWait(), open, XrdSysThread::Run(), XrdOucTList::text, XrdSysE2T(), and XRDSYSTHREAD_BIND.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: