r4837 - in trunk/varnish-cache: bin/varnishadm bin/varnishd include lib/libvarnishapi
phk at varnish-cache.org
phk at varnish-cache.org
Thu May 20 10:42:08 CEST 2010
Author: phk
Date: 2010-05-20 10:42:07 +0200 (Thu, 20 May 2010)
New Revision: 4837
Modified:
trunk/varnish-cache/bin/varnishadm/varnishadm.c
trunk/varnish-cache/bin/varnishd/common.h
trunk/varnish-cache/bin/varnishd/mgt_cli.c
trunk/varnish-cache/bin/varnishd/mgt_shmem.c
trunk/varnish-cache/include/shmlog.h
trunk/varnish-cache/include/varnishapi.h
trunk/varnish-cache/lib/libvarnishapi/vsl.c
Log:
Make the shmlog-alloc's id threepart: class+type+ident to make things
simpler down the road.
Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.c
===================================================================
--- trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-05-20 08:05:27 UTC (rev 4836)
+++ trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-05-20 08:42:07 UTC (rev 4837)
@@ -247,13 +247,13 @@
assert(VSL_Arg(vsd, 'n', n_arg));
if (!VSL_Open(vsd)) {
if (T_arg == NULL) {
- p = VSL_Find_Alloc(vsd, "Arg", "-T", NULL);
+ p = VSL_Find_Alloc(vsd, "Arg", "-T", "", NULL);
if (p != NULL) {
T_arg = strdup(p);
}
}
if (S_arg == NULL) {
- p = VSL_Find_Alloc(vsd, "Arg", "-S", NULL);
+ p = VSL_Find_Alloc(vsd, "Arg", "-S", "", NULL);
if (p != NULL) {
S_arg = strdup(p);
}
Modified: trunk/varnish-cache/bin/varnishd/common.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/common.h 2010-05-20 08:05:27 UTC (rev 4836)
+++ trunk/varnish-cache/bin/varnishd/common.h 2010-05-20 08:42:07 UTC (rev 4837)
@@ -39,7 +39,7 @@
void VCA_tweak_waiter(struct cli *cli, const char *arg);
/* mgt_shmem.c */
-void *mgt_SHM_Alloc(unsigned size, const char *type, const char *ident);
+void *mgt_SHM_Alloc(unsigned size, const char *class, const char *type, const char *ident);
extern struct varnish_stats *VSL_stats;
extern struct shmloghead *loghead;
extern uint8_t *vsl_log_start;
Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-05-20 08:05:27 UTC (rev 4836)
+++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-05-20 08:42:07 UTC (rev 4837)
@@ -511,7 +511,7 @@
/* Save in shmem */
i = strlen(S_arg);
- p = mgt_SHM_Alloc(i + 1, "Arg", "-S");
+ p = mgt_SHM_Alloc(i + 1, "Arg", "-S", "");
AN(p);
strcpy(p, S_arg);
@@ -546,7 +546,7 @@
/* Save in shmem */
i = strlen(T_arg);
- p = mgt_SHM_Alloc(i + 1, "Arg", "-T");
+ p = mgt_SHM_Alloc(i + 1, "Arg", "-T", "");
AN(p);
strcpy(p, T_arg);
Modified: trunk/varnish-cache/bin/varnishd/mgt_shmem.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_shmem.c 2010-05-20 08:05:27 UTC (rev 4836)
+++ trunk/varnish-cache/bin/varnishd/mgt_shmem.c 2010-05-20 08:42:07 UTC (rev 4837)
@@ -64,7 +64,7 @@
/*--------------------------------------------------------------------*/
void *
-mgt_SHM_Alloc(unsigned size, const char *type, const char *ident)
+mgt_SHM_Alloc(unsigned size, const char *class, const char *type, const char *ident)
{
struct shmalloc *sha, *sha2;
unsigned seq;
@@ -99,6 +99,7 @@
MEMORY_BARRIER();
sha->len = size;
+ bprintf(sha->class, "%s", class);
bprintf(sha->type, "%s", type);
bprintf(sha->ident, "%s", ident);
MEMORY_BARRIER();
@@ -300,15 +301,15 @@
bprintf(loghead->head.type, "%s", "Free");
MEMORY_BARRIER();
- VSL_stats = mgt_SHM_Alloc(sizeof *VSL_stats, VSL_TYPE_STAT, "");
+ VSL_stats = mgt_SHM_Alloc(sizeof *VSL_stats, VSL_CLASS_STAT, "", "");
AN(VSL_stats);
- pp = mgt_SHM_Alloc(sizeof *pp, "Params", "");
+ pp = mgt_SHM_Alloc(sizeof *pp, "Params", "", "");
AN(pp);
*pp = *params;
params = pp;
- vsl_log_start = mgt_SHM_Alloc(s1, VSL_TYPE_LOG, "");
+ vsl_log_start = mgt_SHM_Alloc(s1, VSL_CLASS_LOG, "", "");
AN(vsl_log_start);
vsl_log_end = vsl_log_start + s1;
vsl_log_nxt = vsl_log_start + 1;
Modified: trunk/varnish-cache/include/shmlog.h
===================================================================
--- trunk/varnish-cache/include/shmlog.h 2010-05-20 08:05:27 UTC (rev 4836)
+++ trunk/varnish-cache/include/shmlog.h 2010-05-20 08:42:07 UTC (rev 4837)
@@ -51,15 +51,16 @@
#define SHMALLOC_MAGIC 0x43907b6e /* From /dev/random */
unsigned magic;
unsigned len;
+ char class[8];
char type[8];
- char ident[8];
+ char ident[16];
};
#define SHA_NEXT(sha) ((void*)((uintptr_t)(sha) + (sha)->len))
#define SHA_PTR(sha) ((void*)((uintptr_t)((sha) + 1)))
struct shmloghead {
-#define SHMLOGHEAD_MAGIC 4185512500U /* From /dev/random */
+#define SHMLOGHEAD_MAGIC 4185512501U /* From /dev/random */
unsigned magic;
unsigned hdrsize;
@@ -78,7 +79,8 @@
struct shmalloc head;
};
-#define VSL_TYPE_LOG "Log"
+#define VSL_CLASS_LOG "Log"
+#define VSL_CLASS_STAT "Stat"
/*
* Record format is as follows:
Modified: trunk/varnish-cache/include/varnishapi.h
===================================================================
--- trunk/varnish-cache/include/varnishapi.h 2010-05-20 08:05:27 UTC (rev 4836)
+++ trunk/varnish-cache/include/varnishapi.h 2010-05-20 08:42:07 UTC (rev 4837)
@@ -62,8 +62,7 @@
struct varnish_stats *VSL_OpenStats(struct VSL_data *vd);
const char *VSL_Name(struct VSL_data *vd);
extern const char *VSL_tags[256];
-void *VSL_Find_Alloc(struct VSL_data *vd, const char *type, const char *ident,
- unsigned *lenp);
+void *VSL_Find_Alloc(struct VSL_data *vd, const char *class, const char *type,
+ const char *ident, unsigned *lenp);
-
#endif
Modified: trunk/varnish-cache/lib/libvarnishapi/vsl.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsl.c 2010-05-20 08:05:27 UTC (rev 4836)
+++ trunk/varnish-cache/lib/libvarnishapi/vsl.c 2010-05-20 08:42:07 UTC (rev 4837)
@@ -165,15 +165,17 @@
/*--------------------------------------------------------------------*/
static struct shmalloc *
-vsl_find_alloc(struct VSL_data *vd, const char *type, const char *ident)
+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)) {
CHECK_OBJ_NOTNULL(sha, SHMALLOC_MAGIC);
- if (strcmp(sha->type, type))
+ if (strcmp(sha->class, class))
continue;
+ if (type != NULL && strcmp(sha->type, type))
+ continue;
if (ident != NULL && strcmp(sha->ident, ident))
continue;
return (sha);
@@ -184,7 +186,7 @@
/*--------------------------------------------------------------------*/
void *
-VSL_Find_Alloc(struct VSL_data *vd, const char *type, const char *ident,
+VSL_Find_Alloc(struct VSL_data *vd, const char *class, const char *type, const char *ident,
unsigned *lenp)
{
struct shmalloc *sha;
@@ -192,7 +194,7 @@
CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
if (VSL_Open(vd))
return (NULL);
- sha = vsl_find_alloc(vd, type, ident);
+ sha = vsl_find_alloc(vd, class, type, ident);
if (sha == NULL)
return (NULL);
if (lenp != NULL)
@@ -210,7 +212,7 @@
CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
if (VSL_Open(vd))
return (NULL);
- sha = vsl_find_alloc(vd, VSL_TYPE_STAT, "");
+ sha = vsl_find_alloc(vd, VSL_CLASS_STAT, "", "");
assert(sha != NULL);
return (SHA_PTR(sha));
}
@@ -226,7 +228,7 @@
CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
if (VSL_Open(vd))
return (-1);
- sha = vsl_find_alloc(vd, VSL_TYPE_LOG, "");
+ sha = vsl_find_alloc(vd, VSL_CLASS_LOG, "", "");
assert(sha != NULL);
vd->log_start = SHA_PTR(sha);
More information about the varnish-commit
mailing list