XRootD
Loading...
Searching...
No Matches
XrdPosixObject.hh
Go to the documentation of this file.
1#ifndef __XRDPOSIXOBJECT_HH__
2#define __XRDPOSIXOBJECT_HH__
3/******************************************************************************/
4/* */
5/* X r d P o s i x O b j e c t . h h */
6/* */
7/* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* All Rights Reserved */
9/* Produced by Andrew Hanushevsky for Stanford University under contract */
10/* DE-AC02-76-SFO0515 with the Department of Energy */
11/* */
12/* This file is part of the XRootD software suite. */
13/* */
14/* XRootD is free software: you can redistribute it and/or modify it under */
15/* the terms of the GNU Lesser General Public License as published by the */
16/* Free Software Foundation, either version 3 of the License, or (at your */
17/* option) any later version. */
18/* */
19/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22/* License for more details. */
23/* */
24/* You should have received a copy of the GNU Lesser General Public License */
25/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27/* */
28/* The copyright holder's institutional names and contributor's names may not */
29/* be used to endorse or promote products derived from this software without */
30/* specific prior written permission of the institution or contributor. */
31/******************************************************************************/
32
33#include <sys/types.h>
34
35#include "XrdOuc/XrdOucECMsg.hh"
38
39class XrdPosixDir;
40class XrdPosixFile;
41
43{
44public:
45
46 bool AssignFD(bool isStream=false);
47
48static bool CanStream() {return baseFD == 0 && freeFD < 255;}
49
50static XrdPosixDir *Dir (int fildes, bool glk=false);
51
52static XrdPosixFile *File(int fildes, bool glk=false);
53
54 int FDNum() {return fdNum;}
55
57
58static int Init(int numfd);
59
60 void Lock(bool wr=true)
61 {if (wr) objMutex.WriteLock();
62 else objMutex.ReadLock();
63 }
64
74
75static void Release(XrdPosixObject *oP, bool needlk=true);
76
77static XrdPosixDir *ReleaseDir( int fildes);
78
79static XrdPosixFile *ReleaseFile(int fildes);
80
81static void Shutdown();
82
84
85static bool Valid(int fd)
86 {return fd >= baseFD && fd <= (highFD+baseFD)
87 && myFiles && myFiles[fd-baseFD];}
88
89virtual bool Who(XrdPosixDir **dirP) {return false;}
90
91virtual bool Who(XrdPosixFile **fileP) {return false;}
92
93 XrdPosixObject() : ecMsg("[posix]"),fdNum(-1),refCnt(0) {}
94virtual ~XrdPosixObject() {if (fdNum >= 0) Release(this);}
95
97
98protected:
101 int fdNum;
103
104private:
105
106static XrdSysMutex fdMutex;
107static XrdPosixObject **myFiles;
108static int lastFD;
109static int highFD;
110static int baseFD;
111static int freeFD;
112static int posxFD;
113static int devNull;
114};
115#endif
XrdOucString Dir
XrdOucString File
#define AtomicInc(x)
#define AtomicBeg(Mtx)
#define AtomicDec(x)
#define AtomicEnd(Mtx)
#define AtomicRet(mtx, x)
virtual bool Who(XrdPosixFile **fileP)
XrdSysRecMutex updMutex
static void Release(XrdPosixObject *oP, bool needlk=true)
static void Shutdown()
bool AssignFD(bool isStream=false)
virtual ~XrdPosixObject()
static XrdPosixDir * ReleaseDir(int fildes)
XrdSysRWLock objMutex
static int Init(int numfd)
virtual bool Who(XrdPosixDir **dirP)
static XrdPosixFile * ReleaseFile(int fildes)
static bool Valid(int fd)
static bool CanStream()
XrdOucECMsg ecMsg
XrdOucECMsg * getECMsg()
void Lock(bool wr=true)