Loading...
Searching...
No Matches
XrdFfsDent.cc File Reference
`#include "XrdFfs/XrdFfsDent.hh"`
Include dependency graph for XrdFfsDent.cc:

Go to the source code of this file.

## Classes

struct | XrdFfsDentcache

## Macros

#define | XrdFfsDent_NDENTCACHES 20

## Functions

void | XrdFfsDent_cache_destroy ()
int | XrdFfsDent_cache_fill (char *dname, char ***dnarray, int nents)
void | XrdFfsDent_cache_init ()
int | XrdFfsDent_cache_search (char *dname, char *dentname)
int | XrdFfsDent_cstr_cmp (const void *a, const void *b)
int | XrdFfsDent_dentcache_expired (struct XrdFfsDentcache *cache)
void | XrdFfsDent_dentcache_fill (struct XrdFfsDentcache *cache, char *dname, char ***dnarray, int nents)
void | XrdFfsDent_dentcache_free (struct XrdFfsDentcache *cache)
int | XrdFfsDent_dentcache_invalid (struct XrdFfsDentcache *cache)
int | XrdFfsDent_dentcache_search (struct XrdFfsDentcache *cache, char *dname, char *dentname)
void | XrdFfsDent_names_add (struct XrdFfsDentnames **p, char *name)
void | XrdFfsDent_names_del (struct XrdFfsDentnames **p)
int | XrdFfsDent_names_extract (struct XrdFfsDentnames **p, char ***dnarray)
void | XrdFfsDent_names_join (struct XrdFfsDentnames **p, struct XrdFfsDentnames **n)

## Variables

struct XrdFfsDentcache | XrdFfsDentCaches [XrdFfsDent_NDENTCACHES]
pthread_mutex_t | XrdFfsDentCaches_mutex = PTHREAD_MUTEX_INITIALIZER

## Class Documentation

## XrdFfsDentcache

struct XrdFfsDentcache

Definition at line 132 of file XrdFfsDent.cc.

Collaboration diagram for XrdFfsDentcache:

Class Members
char * | dirname |
char ** | dnarray |
time_t | life |
unsigned int | nents |
time_t | t0 |

## Macro Definition Documentation

## XrdFfsDent_NDENTCACHES

#define XrdFfsDent_NDENTCACHES 20

Definition at line 203 of file XrdFfsDent.cc.

Referenced by XrdFfsDent_cache_destroy(), XrdFfsDent_cache_fill(), XrdFfsDent_cache_init(), and XrdFfsDent_cache_search().

## Function Documentation

## XrdFfsDent_cache_destroy()

void XrdFfsDent_cache_destroy | ( |  | ) |

Definition at line 261 of file XrdFfsDent.cc.

{
int i;
for (i = 0; i < XrdFfsDent_NDENTCACHES; i++)
XrdFfsDent_dentcache_free(&XrdFfsDentCaches[i]);
}
XrdFfsDent_NDENTCACHES
#define XrdFfsDent_NDENTCACHES
Definition XrdFfsDent.cc:203
XrdFfsDentCaches
struct XrdFfsDentcache XrdFfsDentCaches[XrdFfsDent_NDENTCACHES]
Definition XrdFfsDent.cc:204
XrdFfsDent_dentcache_free
void XrdFfsDent_dentcache_free(struct XrdFfsDentcache *cache)
Definition XrdFfsDent.cc:154

References XrdFfsDent_dentcache_free(), XrdFfsDent_NDENTCACHES, and XrdFfsDentCaches.

Here is the call graph for this function:

## XrdFfsDent_cache_fill()

int XrdFfsDent_cache_fill | ( | char * | dname,
|  | char *** | dnarray,
|  | int | nents )

Definition at line 219 of file XrdFfsDent.cc.

{
int i;
pthread_mutex_lock(&XrdFfsDentCaches_mutex);
for (i = 0; i < XrdFfsDent_NDENTCACHES; i++)
{
if (XrdFfsDent_dentcache_search(&XrdFfsDentCaches[i], dname, NULL) != 0)
{
XrdFfsDent_dentcache_free(&XrdFfsDentCaches[i]);
XrdFfsDent_dentcache_fill(&XrdFfsDentCaches[i], dname, dnarray, nents);
pthread_mutex_unlock(&XrdFfsDentCaches_mutex);
return 1;
}
}
for (i = 0; i < XrdFfsDent_NDENTCACHES; i++)
{
if (XrdFfsDent_dentcache_expired(&XrdFfsDentCaches[i]) || XrdFfsDent_dentcache_invalid(&XrdFfsDentCaches[i]))
{
XrdFfsDent_dentcache_free(&XrdFfsDentCaches[i]);
XrdFfsDent_dentcache_fill(&XrdFfsDentCaches[i], dname, dnarray, nents);
pthread_mutex_unlock(&XrdFfsDentCaches_mutex);
return 1;
}
}
pthread_mutex_unlock(&XrdFfsDentCaches_mutex);
return 0;
}
XrdFfsDent_dentcache_invalid
int XrdFfsDent_dentcache_invalid(struct XrdFfsDentcache *cache)
Definition XrdFfsDent.cc:176
XrdFfsDentCaches_mutex
pthread_mutex_t XrdFfsDentCaches_mutex
Definition XrdFfsDent.cc:205
XrdFfsDent_dentcache_search
int XrdFfsDent_dentcache_search(struct XrdFfsDentcache *cache, char *dname, char *dentname)
Definition XrdFfsDent.cc:183
XrdFfsDent_dentcache_expired
int XrdFfsDent_dentcache_expired(struct XrdFfsDentcache *cache)
Definition XrdFfsDent.cc:169
XrdFfsDent_dentcache_fill
void XrdFfsDent_dentcache_fill(struct XrdFfsDentcache *cache, char *dname, char ***dnarray, int nents)
Definition XrdFfsDent.cc:140

References XrdFfsDentcache::dnarray, XrdFfsDentcache::nents, XrdFfsDent_dentcache_expired(), XrdFfsDent_dentcache_fill(), XrdFfsDent_dentcache_free(), XrdFfsDent_dentcache_invalid(), XrdFfsDent_dentcache_search(), XrdFfsDent_NDENTCACHES, XrdFfsDentCaches, and XrdFfsDentCaches_mutex.

Here is the call graph for this function:

## XrdFfsDent_cache_init()

void XrdFfsDent_cache_init | ( |  | ) |

Definition at line 207 of file XrdFfsDent.cc.

{
int i;
for (i = 0; i < XrdFfsDent_NDENTCACHES; i++)
{
XrdFfsDentCaches[i].t0 = 0;
XrdFfsDentCaches[i].nents = 0;
XrdFfsDentCaches[i].dirname = strdup("");
XrdFfsDentCaches[i].dnarray = NULL;
}
}

References XrdFfsDent_NDENTCACHES, and XrdFfsDentCaches.

Referenced by XrdFfsMisc_xrd_init().

Here is the caller graph for this function:

## XrdFfsDent_cache_search()

int XrdFfsDent_cache_search | ( | char * | dname,
|  | char * | dentname )

Definition at line 247 of file XrdFfsDent.cc.

{
int i, rval = 0;
pthread_mutex_lock(&XrdFfsDentCaches_mutex);
for (i = 0; i < XrdFfsDent_NDENTCACHES; i++)
if (XrdFfsDent_dentcache_search(&XrdFfsDentCaches[i], dname, dentname) == 1)
{
rval = 1;
break;
}
pthread_mutex_unlock(&XrdFfsDentCaches_mutex);
return rval;
}

References XrdFfsDent_dentcache_search(), XrdFfsDent_NDENTCACHES, XrdFfsDentCaches, and XrdFfsDentCaches_mutex.

Referenced by XrdFfsPosix_statall().

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

## XrdFfsDent_cstr_cmp()

int XrdFfsDent_cstr_cmp | ( | const void * | a,
|  | const void * | b )

Definition at line 39 of file XrdFfsDent.cc.

{
const char **aa = (const char **)a;
const char **bb = (const char **)b;
return strcmp(*aa, *bb);
}

Referenced by XrdFfsDent_dentcache_search(), and XrdFfsDent_names_extract().

Here is the caller graph for this function:

## XrdFfsDent_dentcache_expired()

int XrdFfsDent_dentcache_expired | ( | struct XrdFfsDentcache * | cache | ) |

Definition at line 169 of file XrdFfsDent.cc.

{
time_t t1;
t1 = time(NULL);
return (((t1 - cache->t0) < cache->life)? 0 : 1);
}
XrdFfsDentcache::t0
time_t t0
Definition XrdFfsDent.cc:133
XrdFfsDentcache::life
time_t life
Definition XrdFfsDent.cc:134

References XrdFfsDentcache::life, and XrdFfsDentcache::t0.

Referenced by XrdFfsDent_cache_fill().

Here is the caller graph for this function:

## XrdFfsDent_dentcache_fill()

void XrdFfsDent_dentcache_fill | ( | struct XrdFfsDentcache * | cache,
|  | char * | dname,
|  | char *** | dnarray,
|  | int | nents )

Definition at line 140 of file XrdFfsDent.cc.

{
int i;
cache->dirname = strdup(dname);
cache->nents = nents;
cache->t0 = time(NULL);
cache->life = nents / 10 ;
cache->dnarray = (char**) malloc(sizeof(char*) * nents);
for (i = 0; i < nents; i++)
cache->dnarray[i] = strdup((*dnarray)[i]);
}
XrdFfsDentcache::dnarray
char ** dnarray
Definition XrdFfsDent.cc:137
XrdFfsDentcache::nents
unsigned int nents
Definition XrdFfsDent.cc:135
XrdFfsDentcache::dirname
char * dirname
Definition XrdFfsDent.cc:136

References XrdFfsDentcache::dirname, XrdFfsDentcache::dnarray, XrdFfsDentcache::life, XrdFfsDentcache::nents, and XrdFfsDentcache::t0.

Referenced by XrdFfsDent_cache_fill().

Here is the caller graph for this function:

## XrdFfsDent_dentcache_free()

void XrdFfsDent_dentcache_free | ( | struct XrdFfsDentcache * | cache | ) |

Definition at line 154 of file XrdFfsDent.cc.

{
int i;
for (i = 0; i < (int)cache->nents; i++)
{
free(cache->dnarray[i]);
}
cache->nents = 0;
free(cache->dnarray);
free(cache->dirname);
cache->dnarray = NULL;
cache->dirname = NULL;
}

References XrdFfsDentcache::dirname, XrdFfsDentcache::dnarray, and XrdFfsDentcache::nents.

Referenced by XrdFfsDent_cache_destroy(), and XrdFfsDent_cache_fill().

Here is the caller graph for this function:

## XrdFfsDent_dentcache_invalid()

int XrdFfsDent_dentcache_invalid | ( | struct XrdFfsDentcache * | cache | ) |

Definition at line 176 of file XrdFfsDent.cc.

{
time_t t1;
t1 = time(NULL);
return (((t1 - cache->t0) < 28700)? 0 : 1); // after 8 hours (28800 sec), the redirector no longer remembers
}

References XrdFfsDentcache::t0.

Referenced by XrdFfsDent_cache_fill(), and XrdFfsDent_dentcache_search().

Here is the caller graph for this function:

## XrdFfsDent_dentcache_search()

int XrdFfsDent_dentcache_search | ( | struct XrdFfsDentcache * | cache,
|  | char * | dname,
|  | char * | dentname )

Definition at line 183 of file XrdFfsDent.cc.

{
char path[1024];
strcpy(path, dname);
if (dentname != NULL && path[strlen(path) -1] != '/')
strcat(path,"/");
if (dentname != NULL) strcat(path, dentname);
if (XrdFfsDent_dentcache_invalid(cache))
return 0;
else if (strlen(cache->dirname) == strlen(path) && strcmp(cache->dirname, path) == 0)
return 1;
else if (strlen(cache->dirname) != strlen(dname) || strcmp(cache->dirname, dname) != 0)
return 0;
else if (bsearch(&dentname, cache->dnarray, cache->nents, sizeof(char*), XrdFfsDent_cstr_cmp) != NULL)
return 1;
else
return 0;
}
XrdFfsDent_cstr_cmp
int XrdFfsDent_cstr_cmp(const void *a, const void *b)
Definition XrdFfsDent.cc:39

References XrdFfsDentcache::dirname, XrdFfsDentcache::dnarray, XrdFfsDentcache::nents, XrdFfsDent_cstr_cmp(), and XrdFfsDent_dentcache_invalid().

Referenced by XrdFfsDent_cache_fill(), and XrdFfsDent_cache_search().

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

## XrdFfsDent_names_add()

void XrdFfsDent_names_add | ( | struct XrdFfsDentnames ** | p,
|  | char * | name )

Definition at line 56 of file XrdFfsDent.cc.

{
struct XrdFfsDentnames *n = (struct XrdFfsDentnames*)malloc(sizeof(struct XrdFfsDentnames));
n->name = strdup(name);
n->next = *p;
*p = n;
return;
}
XrdFfsDentnames::next
struct XrdFfsDentnames * next
Definition XrdFfsDent.hh:41
XrdFfsDentnames::name
char * name
Definition XrdFfsDent.hh:40
XrdFfsDentnames
Definition XrdFfsDent.hh:39

References XrdFfsDentnames::name, and XrdFfsDentnames::next.

Referenced by XrdFfsPosix_x_readdirall().

Here is the caller graph for this function:

## XrdFfsDent_names_del()

void XrdFfsDent_names_del | ( | struct XrdFfsDentnames ** | p | ) |

Definition at line 49 of file XrdFfsDent.cc.

{
(*p)->name = NULL;
(*p)->next = NULL;
free(*p);
}

Referenced by XrdFfsDent_names_extract().

Here is the caller graph for this function:

## XrdFfsDent_names_extract()

int XrdFfsDent_names_extract | ( | struct XrdFfsDentnames ** | p,
|  | char *** | dnarray )

Definition at line 100 of file XrdFfsDent.cc.

{
struct XrdFfsDentnames *x, *y;
int i = 0;
y = *p;
while (y != NULL)
{
i++;
y = y->next;
}
/* be careful, old dnarray is lost */
*dnarray = (char**) malloc(sizeof(char*) * i);
x = *p;
y = *p;
i = 0;
while (y != NULL)
{
(*dnarray)[i++] = y->name;
y = y->next;
XrdFfsDent_names_del(&x);
x = y;
}
qsort((*dnarray), i, sizeof(char*), XrdFfsDent_cstr_cmp);
*p = NULL;
return i;
}
XrdFfsDent_names_del
void XrdFfsDent_names_del(struct XrdFfsDentnames **p)
Definition XrdFfsDent.cc:49

References XrdFfsDentnames::name, XrdFfsDentnames::next, XrdFfsDent_cstr_cmp(), and XrdFfsDent_names_del().

Here is the call graph for this function:

## XrdFfsDent_names_join()

void XrdFfsDent_names_join | ( | struct XrdFfsDentnames ** | p,
|  | struct XrdFfsDentnames ** | n )

Definition at line 78 of file XrdFfsDent.cc.

{
struct XrdFfsDentnames *t, *l = 0;
if ( *p != NULL )
{
t = *p;
while ( t != NULL )
{
l = t;
t = t->next;
}
l->next = *n;
}
else
*p = *n;
}

References XrdFfsDentnames::next.

## Variable Documentation

## XrdFfsDentCaches

struct XrdFfsDentcache XrdFfsDentCaches[XrdFfsDent_NDENTCACHES]

Definition at line 204 of file XrdFfsDent.cc.

Referenced by XrdFfsDent_cache_destroy(), XrdFfsDent_cache_fill(), XrdFfsDent_cache_init(), and XrdFfsDent_cache_search().

## XrdFfsDentCaches_mutex

pthread_mutex_t XrdFfsDentCaches_mutex = PTHREAD_MUTEX_INITIALIZER

Definition at line 205 of file XrdFfsDent.cc.

Referenced by XrdFfsDent_cache_fill(), and XrdFfsDent_cache_search().