Loading...
Searching...
No Matches
XrdSutFileLocker Class Reference

`#include <XrdSutAux.hh>`

Collaboration diagram for XrdSutFileLocker:

## Public Types

enum | ELockType { kShared = 0 , kExcl = 1 }

## Public Member Functions

| XrdSutFileLocker (int fd, ELockType lock)
| ~XrdSutFileLocker ()
bool | IsValid () const

## Detailed Description

Definition at line 238 of file XrdSutAux.hh.

## Member Enumeration Documentation

## ELockType

enum XrdSutFileLocker::ELockType

Enumerator
kShared |
kExcl |

Definition at line 243 of file XrdSutAux.hh.

{ kShared = 0, kExcl = 1 };
XrdSutFileLocker::kShared
@ kShared
Definition XrdSutAux.hh:243
XrdSutFileLocker::kExcl
@ kExcl
Definition XrdSutAux.hh:243

## Constructor & Destructor Documentation

## XrdSutFileLocker()

XrdSutFileLocker::XrdSutFileLocker | ( | int | fd,
|  | ELockType | lock )

Definition at line 615 of file XrdSutAux.cc.

{
// Constructor: locks the file in 'lock' mode.
// Use IsValid() to test success.
valid = 0;
fdesk = fd;
// Exclusive lock of the whole file
int lockmode = (lock == XrdSutFileLocker::kExcl) ? (F_WRLCK | F_RDLCK)
: F_RDLCK;
struct flock flck;
memset(&flck, 0, sizeof(flck));
flck.l_type = lockmode;
flck.l_whence = SEEK_SET;
if (fcntl(fdesk, F_SETLK, &flck) != 0)
// Failure
return;
// Success
valid = 1;
}

References kExcl.

## ~XrdSutFileLocker()

XrdSutFileLocker::~XrdSutFileLocker | ( |  | ) |

Definition at line 638 of file XrdSutAux.cc.

{
// Destructor: unlocks the file if locked.
if (fdesk < 0 || !IsValid())
return;
//
// Unlock the file
struct flock flck = {F_UNLCK, SEEK_SET, 0, 0, 0};
memset(&flck, 0, sizeof(flck));
flck.l_type = F_UNLCK;
flck.l_whence = SEEK_SET;
fcntl(fdesk, F_SETLK, &flck);
}
XrdSutFileLocker::IsValid
bool IsValid() const
Definition XrdSutAux.hh:246

References IsValid().

Here is the call graph for this function:

## Member Function Documentation

## IsValid()

bool XrdSutFileLocker::IsValid | ( |  | ) | const

inline

Definition at line 246 of file XrdSutAux.hh.

{ return valid; }

Referenced by ~XrdSutFileLocker(), and XrdCryptosslX509ChainToFile().

Here is the caller graph for this function:

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

- XrdSutAux.hh
- XrdSutAux.cc