Commit 6e70c97a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a supported iterator over shmlog allocations.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4848 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 69857eb8
......@@ -65,4 +65,10 @@ extern const char *VSL_tags[256];
void *VSL_Find_Alloc(struct VSL_data *vd, const char *class, const char *type,
const char *ident, unsigned *lenp);
struct shmalloc *vsl_iter0(struct VSL_data *vd);
struct shmalloc *vsl_itern(struct VSL_data *vd, struct shmalloc **pp);
#define VSL_FOREACH(var, vd) \
for((var) = vsl_iter0((vd)); (var) != NULL; vsl_itern((vd), &(var)))
#endif
......@@ -145,6 +145,8 @@ VSL_Open(struct VSL_data *vd)
return (1);
}
vd->vsl_end = (uint8_t *)vd->vsl_lh + slh.shm_size;
vd->alloc_seq = slh.alloc_seq;
return (0);
}
......@@ -164,13 +166,41 @@ VSL_Close(struct VSL_data *vd)
/*--------------------------------------------------------------------*/
struct shmalloc *
vsl_iter0(struct VSL_data *vd)
{
CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
if (vd->alloc_seq != vd->vsl_lh->alloc_seq)
return(NULL);
CHECK_OBJ_NOTNULL(&vd->vsl_lh->head, SHMALLOC_MAGIC);
return (&vd->vsl_lh->head);
}
struct shmalloc *
vsl_itern(struct VSL_data *vd, struct shmalloc **pp)
{
CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
if (vd->alloc_seq != vd->vsl_lh->alloc_seq)
return(NULL);
CHECK_OBJ_NOTNULL(*pp, SHMALLOC_MAGIC);
*pp = SHA_NEXT(*pp);
if ((void*)*pp >= vd->vsl_end)
return (NULL);
CHECK_OBJ_NOTNULL(*pp, SHMALLOC_MAGIC);
return (*pp);
}
/*--------------------------------------------------------------------*/
static struct shmalloc *
vsl_find_alloc(struct VSL_data *vd, const char *class, const char *type, const char *ident)
{
struct shmalloc *sha;
assert (vd->vsl_lh != NULL);
for(sha = &vd->vsl_lh->head; (void*)sha < vd->vsl_end; sha = SHA_NEXT(sha)) {
VSL_FOREACH(sha, vd) {
CHECK_OBJ_NOTNULL(sha, SHMALLOC_MAGIC);
if (strcmp(sha->class, class))
continue;
......
......@@ -41,6 +41,7 @@ struct VSL_data {
int vsl_fd;
struct shmloghead *vsl_lh;
void *vsl_end;
unsigned alloc_seq;
unsigned char *log_start;
unsigned char *log_end;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment