xrootd
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
XrdSsiShMam Class Reference

#include <XrdSsiShMam.hh>

Inheritance diagram for XrdSsiShMam:
Inheritance graph
[legend]
Collaboration diagram for XrdSsiShMam:
Collaboration graph
[legend]

Classes

struct  MemItem
 
class  XLockHelper
 

Public Types

enum  LockType { ROLock = 0 , RWLock = 1 }
 

Public Member Functions

bool AddItem (void *newdata, void *olddata, const char *key, int hash, bool replace=false)
 
bool Attach (int tout, bool isrw=false)
 
bool Create (XrdSsiShMat::CRZParms &parms)
 
bool Export ()
 
bool DelItem (void *data, const char *key, int hash)
 
void Detach ()
 Detach the map from the shared memory.
 
bool Enumerate (void *&jar, char *&key, void *&val)
 
bool Enumerate (void *&jar)
 
bool GetItem (void *data, const char *key, int hash)
 
int Info (const char *vname, char *buff=0, int blen=0)
 
bool Resize (XrdSsiShMat::CRZParms &parms)
 
bool Sync ()
 
bool Sync (bool dosync, bool syncdo)
 
bool Sync (int syncqsz)
 
 XrdSsiShMam (XrdSsiShMat::NewParms &parms)
 
 ~XrdSsiShMam ()
 
- Public Member Functions inherited from XrdSsiShMat
 XrdSsiShMat (NewParms &parms)
 Constructor (arguments the same as for New())
 
virtual ~XrdSsiShMat ()
 Destructor. Warning, your destructor should call your own Detach()!
 

Private Member Functions

bool ExportIt (bool fLocked)
 
int Find (MemItem *&theItem, MemItem *&prvItem, const char *key, int &hash)
 
bool Flush ()
 
int HashVal (const char *key)
 
bool Lock (bool doRW=false, bool nowait=false)
 
MemItemNewItem ()
 
bool ReMap (LockType iHave)
 
void RetItem (MemItem *iP)
 
void SetLocking (bool isrw)
 
void SwapMap (XrdSsiShMam &newMap)
 
void Snooze (int sec)
 
void UnLock (bool isrw)
 
void Updated (int mOff)
 
void Updated (int mOff, int mLen)
 
 Atomic (int) *shmIndex
 

Private Attributes

pthread_mutex_t lkMutex
 
pthread_rwlock_t myMutex
 
char * shmTemp
 
long long shmSize
 
char * shmBase
 
int shmSlots
 
int shmItemSz
 
int shmInfoSz
 
int verNum
 
int keyPos
 
int maxKLen
 
int shmFD
 
int timeOut
 
int lkCount
 
int syncOpt
 
int syncQWR
 
int syncLast
 
int syncQSZ
 
int accMode
 
bool isRW
 
bool lockRO
 
bool lockRW
 
bool reUse
 
bool multW
 
bool useAtomic
 
bool syncBase
 
bool syncOn
 

Additional Inherited Members

- Static Public Member Functions inherited from XrdSsiShMat
static XrdSsiShMatNew (NewParms &parms)
 
- Protected Attributes inherited from XrdSsiShMat
char * shmImpl
 
char * shmPath
 
char * shmType
 
int shmTypeSz
 
int shmHash
 

Member Enumeration Documentation

◆ LockType

Enumerator
ROLock 
RWLock 

Constructor & Destructor Documentation

◆ XrdSsiShMam()

XrdSsiShMam::XrdSsiShMam ( XrdSsiShMat::NewParms parms)

◆ ~XrdSsiShMam()

XrdSsiShMam::~XrdSsiShMam ( )
inline

References Detach(), lkMutex, and myMutex.

Member Function Documentation

◆ AddItem()

bool XrdSsiShMam::AddItem ( void *  newdata,
void *  olddata,
const char *  key,
int  hash,
bool  replace = false 
)
virtual

Add an item to the shared memory table.

Parameters
newdataPointer to the data to be added.
olddataPointer to the area where the replaced data, if any, is to be placed.
keyThe key associated with the data that is to be added.
hashThe hash of the key that is to be used to lookup the key. If the value is zero, an internal hash is computed.
replaceWhen true, if the key exists, the data associated with the key is replaced. When false, if the key exists, the addition fails with errno set to EEXIST.
Returns
true The addition/replacement succeeded. If the key was actually replaced errno is set to EEXIST else it is set to 0.
false The addition/replacement failed; errno indicates reason.

Implements XrdSsiShMat.

◆ Atomic()

XrdSsiShMam::Atomic ( int  )
private

◆ Attach()

bool XrdSsiShMam::Attach ( int  tout,
bool  isrw = false 
)
virtual

Attach this object to the shared memory associated with this object at creation time (see New() method). The attach operation waits until the shared memory file is available. At that time, the file is memory mapped.

Parameters
toutThe maximum number of seconds to wait for the shared memory file to become available. If tout is zero, then the file must be immediately available. If the value is negative then the attach waits as long as needed. When tout is reached the attach fails with errno set to ETIMEDOUT.
isrwWhen true the file is mapped to writable memory and allows updates to the table. If false, the shared memory is made read/only and may be significantly faster to access.
Returns
true - The shared memory was attached, the table can be used.
false - The shared memory could not be attached, errno holds reason.

Implements XrdSsiShMat.

◆ Create()

bool XrdSsiShMam::Create ( XrdSsiShMat::CRZParms parms)
virtual

Implements XrdSsiShMat.

◆ DelItem()

bool XrdSsiShMam::DelItem ( void *  data,
const char *  key,
int  hash 
)
virtual

Delete an item from the table.

Parameters
dataPointer to the area to receive the value of the deleted key. If the pointer is nil, then the key value is not returned.
keyPointer to the key of length <= MaxKLen.
hashThe hash of the key that is to be used to lookup the key. If the value is zero, an internal hash is computed.
Returns
true - The key and data have been deleted. This is always returned when data is nil.
false - The key and data either not deleted or the key does not exist and data was not nil. The errno value decribes why. Typical reason: the key was not found (errno == ENOENT).

Implements XrdSsiShMat.

◆ Detach()

void XrdSsiShMam::Detach ( )
virtual

Detach the map from the shared memory.

Implements XrdSsiShMat.

Referenced by ~XrdSsiShMam().

◆ Enumerate() [1/2]

bool XrdSsiShMam::Enumerate ( void *&  jar)
virtual

Terminate an active enumeration. An active enumeration is any enumeration where the previous form of Enumerate() did not return false. Terminating an active enumeration releases all of the enumeration resources allocated.

Parameters
jarThe opaque cookie initialized by a previous call to Enumerate() requesting the next key-value pair.
Returns
true The enumeration has been terminated and the jar was deleted and the jar pointer is set to zero. Keys are returned in arbitrary order and not all keys may be returned if the map is being actively updated.
false The jar pointer was zero; no enumeration was active.

Implements XrdSsiShMat.

◆ Enumerate() [2/2]

bool XrdSsiShMam::Enumerate ( void *&  jar,
char *&  key,
void *&  val 
)
virtual

Enumerate the keys and assocaited values.

Parameters
jarAn opaque cookie that tracks progress. It should be initialized to zero and otherwise not touched. The same jar must be used for all successive calls. The jar is deleted when false is returned (also see the next Enumerate method).
keyThe pointer variable where the location of the key is returned upon success.
valThe pointer variable where the location f the key values is to be returned upon success.
Returns
true A key and val pointers have been set. Keys are returned in arbitrary order and not all keys may be returned if the map is being actively updated.
false Key not returned; errno holds the reason. Typically, ENOENT there ae no more keys. Other errors may also be reflected. Whne false is returned the jar is deleted and the pointer to it set to zero.

Implements XrdSsiShMat.

◆ Export()

bool XrdSsiShMam::Export ( )
virtual

Export a newly created table (i.e. see Create()).

Returns
true - The table has been exported and is now visible to others.
false - The export failed, the errno value describes the reason.

Implements XrdSsiShMat.

◆ ExportIt()

bool XrdSsiShMam::ExportIt ( bool  fLocked)
private

◆ Find()

int XrdSsiShMam::Find ( MemItem *&  theItem,
MemItem *&  prvItem,
const char *  key,
int &  hash 
)
private

◆ Flush()

bool XrdSsiShMam::Flush ( )
private

◆ GetItem()

bool XrdSsiShMam::GetItem ( void *  data,
const char *  key,
int  hash 
)
virtual

Get an item from the table.

Parameters
dataPointer to an area to receive the value associated with key. If the pointer is nil, then the key value is not returned.
keyPointer to the key of length <= MaxKLen.
hashThe hash of the key that is to be used to lookup the key. If the value is zero, an internal hash is computed.
Returns
true - The key was found and if data was not nil, contains the value associated key.
false - The key not found; errno holds the reason (typically is ENOENT but may be some other reason).

Implements XrdSsiShMat.

◆ HashVal()

int XrdSsiShMam::HashVal ( const char *  key)
private

◆ Info()

int XrdSsiShMam::Info ( const char *  vname,
char *  buff = 0,
int  blen = 0 
)
virtual

Return information about the table.

Parameters
vnamePointer to the variable name whose value is wanted. A particular implementation may not support all variable and may support variables not listed here. These are for the default implementation unless otherwise noted. They are: hash - name of hash being used. impl - The table implementation being used. indexsz - Number of index entries indexused - Number of index entries in use keys - Number of keys in the bale. keys/indexused is the hash table collision factor keysfree - Number of keys that can still be added maxkeylen - Longest allowed key multw - If table supports multiple writers, else 0 reuse - If table allows object reuse, else 0 type - Name of the data type in the table. typesz - The number of bytes in the table's data type
buff- Pointer to the buffer to receive text values. Variables that return text are: hash, impl, and type. A buffer must be supplied in any of these variables are requested. If buff is nill or too small a -1 is returned with errno set to EMSGSIZE.
blenThe length of the buffer.
Returns
>=0 - The variable's value or the length of the text information.
< 0 - The variable's value could not be returned; errno has the error code describing the reason, typically ENOTSUP.

Implements XrdSsiShMat.

◆ Lock()

bool XrdSsiShMam::Lock ( bool  doRW = false,
bool  nowait = false 
)
private

◆ NewItem()

MemItem * XrdSsiShMam::NewItem ( )
private

◆ ReMap()

bool XrdSsiShMam::ReMap ( LockType  iHave)
private

◆ Resize()

bool XrdSsiShMam::Resize ( XrdSsiShMat::CRZParms parms)
virtual

Resize a shared memory segment and associated file specified at object instantiation (see New() method). Resizing is implementation specific but may involve creating a new table and exporting it.

Parameters
parmsResize parameters. See the CRZParms struct for details. For resize, zero values or unspecified flags use the existing table values.
Returns
true - The shared memory was resized, the table can be used.
false - The shared memory could not be resized, errno holds reason.

Implements XrdSsiShMat.

◆ RetItem()

void XrdSsiShMam::RetItem ( MemItem iP)
private

◆ SetLocking()

void XrdSsiShMam::SetLocking ( bool  isrw)
private

◆ Snooze()

void XrdSsiShMam::Snooze ( int  sec)
private

◆ SwapMap()

void XrdSsiShMam::SwapMap ( XrdSsiShMam newMap)
private

◆ Sync() [1/3]

bool XrdSsiShMam::Sync ( )
virtual

Synchronize all modified pages to the associated backing file.

Returns
true - Operation completed successfully.
false - Operation failed; errno holds the error code explaining why.

Implements XrdSsiShMat.

◆ Sync() [2/3]

bool XrdSsiShMam::Sync ( bool  dosync,
bool  syncdo 
)
virtual

Turn memry synchronization on or off.

Parameters
dosyncWhen true, modified table pages are written back to the backing file. The synchronous or async nature of the write is controlled by the second parameter. When false, memory-file synchronization is turned off (initial setting).
syncdoWhen true, synchronization is done in the forground. That is, a call triggering a sync will not return until complete. When false, synchronization is done in the background.
Returns
true - Operation completed successfully.
false - Operation failed; errno holds the error code explaining why.

Implements XrdSsiShMat.

◆ Sync() [3/3]

bool XrdSsiShMam::Sync ( int  synqsz)
virtual

Set the sync defer queue size.

Parameters
synqszThe maximum number of modified pages before flushing.
Returns
true - Operation completed successfully.
false - Operation failed; errno holds the error code explaining why.

Implements XrdSsiShMat.

◆ UnLock()

void XrdSsiShMam::UnLock ( bool  isrw)
private

◆ Updated() [1/2]

void XrdSsiShMam::Updated ( int  mOff)
private

◆ Updated() [2/2]

void XrdSsiShMam::Updated ( int  mOff,
int  mLen 
)
private

Member Data Documentation

◆ accMode

int XrdSsiShMam::accMode
private

◆ isRW

bool XrdSsiShMam::isRW
private

◆ keyPos

int XrdSsiShMam::keyPos
private

◆ lkCount

int XrdSsiShMam::lkCount
private

◆ lkMutex

pthread_mutex_t XrdSsiShMam::lkMutex
private

Referenced by ~XrdSsiShMam().

◆ lockRO

bool XrdSsiShMam::lockRO
private

◆ lockRW

bool XrdSsiShMam::lockRW
private

◆ maxKLen

int XrdSsiShMam::maxKLen
private

◆ multW

bool XrdSsiShMam::multW
private

◆ myMutex

pthread_rwlock_t XrdSsiShMam::myMutex
private

◆ reUse

bool XrdSsiShMam::reUse
private

◆ shmBase

char* XrdSsiShMam::shmBase
private

◆ shmFD

int XrdSsiShMam::shmFD
private

◆ shmInfoSz

int XrdSsiShMam::shmInfoSz
private

◆ shmItemSz

int XrdSsiShMam::shmItemSz
private

◆ shmSize

long long XrdSsiShMam::shmSize
private

◆ shmSlots

int XrdSsiShMam::shmSlots
private

◆ shmTemp

char* XrdSsiShMam::shmTemp
private

◆ syncBase

bool XrdSsiShMam::syncBase
private

◆ syncLast

int XrdSsiShMam::syncLast
private

◆ syncOn

bool XrdSsiShMam::syncOn
private

◆ syncOpt

int XrdSsiShMam::syncOpt
private

◆ syncQSZ

int XrdSsiShMam::syncQSZ
private

◆ syncQWR

int XrdSsiShMam::syncQWR
private

◆ timeOut

int XrdSsiShMam::timeOut
private

◆ useAtomic

bool XrdSsiShMam::useAtomic
private

◆ verNum

int XrdSsiShMam::verNum
private

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