xrootd
Loading...
Searching...
No Matches
XrdSutCacheEntry.hh
Go to the documentation of this file.
1#ifndef __SUT_CACHEENTRY_H
2#define __SUT_CACHEENTRY_H
3/******************************************************************************/
4/* */
5/* X r d S u t C a c h e E n t r y . h h */
6/* */
7/* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* Produced by Gerri Ganis for CERN */
9/* */
10/* This file is part of the XRootD software suite. */
11/* */
12/* XRootD is free software: you can redistribute it and/or modify it under */
13/* the terms of the GNU Lesser General Public License as published by the */
14/* Free Software Foundation, either version 3 of the License, or (at your */
15/* option) any later version. */
16/* */
17/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20/* License for more details. */
21/* */
22/* You should have received a copy of the GNU Lesser General Public License */
23/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25/* */
26/* The copyright holder's institutional names and contributor's names may not */
27/* be used to endorse or promote products derived from this software without */
28/* specific prior written permission of the institution or contributor. */
29/******************************************************************************/
30
31#include "XProtocol/XPtypes.hh"
33
34/******************************************************************************/
35/* */
36/* Class defining the basic cache entry */
37/* */
38/******************************************************************************/
39
41 kCE_inactive = -2, // -2 inactive: eliminated at next trim
42 kCE_disabled, // -1 disabled, cannot be enabled
43 kCE_allowed, // 0 empty creds, can be enabled
44 kCE_expired, // 1 enabled, creds to be changed at next used
45 kCE_ok, // 2 enabled and OK
46 kCE_special // 3 special (non-creds) entry
47};
48
49//
50// Buffer used internally by XrdGCEntry
51//
53public:
54 char *buf;
56 XrdSutCacheEntryBuf(char *b = 0, kXR_int32 l = 0);
58
59 virtual ~XrdSutCacheEntryBuf() { if (len > 0 && buf) delete[] buf; }
60
61 void SetBuf(const char *b = 0, kXR_int32 l = 0);
62};
63
64//
65// Generic cache entry: it stores a
66//
67// name
68// status 2 bytes
69// cnt 2 bytes
70// mtime 4 bytes
71// buf1, buf2, buf3, buf4
72//
73// The buffers are generic buffers to store bufferized info
74//
76public:
77 char *name;
78 short status;
79 short cnt; // counter
80 kXR_int32 mtime; // time of last modification / creation
85 XrdSysRWLock rwmtx; // Locked when reference is outstanding
86 XrdSutCacheEntry(const char *n = 0, short st = 0, short cn = 0,
87 kXR_int32 mt = 0);
89 virtual ~XrdSutCacheEntry() { if (name) delete[] name; }
90 kXR_int32 Length() const { return (buf1.len + buf2.len + 2*sizeof(short) +
91 buf3.len + buf4.len + 5*sizeof(kXR_int32)); }
92 void Reset();
93 void SetName(const char *n = 0);
94 char *AsString() const;
95
97};
98
100{
101public:
102
103inline void ReadLock(XrdSysRWLock *lock = 0)
104 { if (lock) Set(lock);
105 rwlock->ReadLock();
106 };
107
108inline void WriteLock(XrdSysRWLock *lock = 0)
109 { if (lock) Set(lock);
110 rwlock->WriteLock();
111 };
112
113inline void Set(XrdSysRWLock *lock)
114 {if (rwlock) {if (rwlock != lock) rwlock->UnLock();
115 else return;
116 }
117 rwlock = lock;
118 };
119
120inline void UnLock(bool reset = true) {if (rwlock) {rwlock->UnLock(); if (reset) rwlock = 0; }}
121
123
125protected:
127};
128
129#endif
int kXR_int32
Definition XPtypes.hh:89
kCEntryStatus
Definition XrdSutCacheEntry.hh:40
@ kCE_special
Definition XrdSutCacheEntry.hh:46
@ kCE_ok
Definition XrdSutCacheEntry.hh:45
@ kCE_allowed
Definition XrdSutCacheEntry.hh:43
@ kCE_disabled
Definition XrdSutCacheEntry.hh:42
@ kCE_inactive
Definition XrdSutCacheEntry.hh:41
@ kCE_expired
Definition XrdSutCacheEntry.hh:44
Definition XrdSutCacheEntry.hh:100
void UnLock(bool reset=true)
Definition XrdSutCacheEntry.hh:120
void WriteLock(XrdSysRWLock *lock=0)
Definition XrdSutCacheEntry.hh:108
void ReadLock(XrdSysRWLock *lock=0)
Definition XrdSutCacheEntry.hh:103
XrdSysRWLock * rwlock
Definition XrdSutCacheEntry.hh:126
void Set(XrdSysRWLock *lock)
Definition XrdSutCacheEntry.hh:113
~XrdSutCERef()
Definition XrdSutCacheEntry.hh:124
XrdSutCERef()
Definition XrdSutCacheEntry.hh:122
Definition XrdSutCacheEntry.hh:52
kXR_int32 len
Definition XrdSutCacheEntry.hh:55
char * buf
Definition XrdSutCacheEntry.hh:54
XrdSutCacheEntryBuf(char *b=0, kXR_int32 l=0)
virtual ~XrdSutCacheEntryBuf()
Definition XrdSutCacheEntry.hh:59
void SetBuf(const char *b=0, kXR_int32 l=0)
XrdSutCacheEntryBuf(const XrdSutCacheEntryBuf &b)
Definition XrdSutCacheEntry.hh:75
short status
Definition XrdSutCacheEntry.hh:78
XrdSysRWLock rwmtx
Definition XrdSutCacheEntry.hh:85
char * AsString() const
void SetName(const char *n=0)
virtual ~XrdSutCacheEntry()
Definition XrdSutCacheEntry.hh:89
XrdSutCacheEntry(const XrdSutCacheEntry &e)
char * name
Definition XrdSutCacheEntry.hh:77
short cnt
Definition XrdSutCacheEntry.hh:79
XrdSutCacheEntry & operator=(const XrdSutCacheEntry &pfe)
kXR_int32 Length() const
Definition XrdSutCacheEntry.hh:90
kXR_int32 mtime
Definition XrdSutCacheEntry.hh:80
XrdSutCacheEntryBuf buf2
Definition XrdSutCacheEntry.hh:82
XrdSutCacheEntryBuf buf4
Definition XrdSutCacheEntry.hh:84
XrdSutCacheEntryBuf buf1
Definition XrdSutCacheEntry.hh:81
XrdSutCacheEntry(const char *n=0, short st=0, short cn=0, kXR_int32 mt=0)
XrdSutCacheEntryBuf buf3
Definition XrdSutCacheEntry.hh:83
Definition XrdSysPthread.hh:330
void ReadLock()
Definition XrdSysPthread.hh:342
void WriteLock()
Definition XrdSysPthread.hh:343
void UnLock()
Definition XrdSysPthread.hh:348