From: des Date: Thu, 28 Jun 2007 10:25:47 +0000 (+0000) Subject: Expose the instance name associated with the currently open VSL file. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3560d85ae586cac8380d2f9c7582f4dcbe225a39;p=varnish Expose the instance name associated with the currently open VSL file. This is a bletcherous hack - the entire API needs cleaning up. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1588 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/include/varnishapi.h b/varnish-cache/include/varnishapi.h index 519cfef7..4460d4ea 100644 --- a/varnish-cache/include/varnishapi.h +++ b/varnish-cache/include/varnishapi.h @@ -56,6 +56,7 @@ int VSL_Dispatch(struct VSL_data *vd, vsl_handler *func, void *priv); int VSL_NextLog(struct VSL_data *lh, unsigned char **pp); int VSL_Arg(struct VSL_data *vd, int arg, const char *opt); struct varnish_stats *VSL_OpenStats(const char *varnish_name); +const char *VSL_Name(void); extern const char *VSL_tags[256]; /* instance.c */ diff --git a/varnish-cache/lib/libvarnishapi/shmlog.c b/varnish-cache/lib/libvarnishapi/shmlog.c index 3c2d0976..2bc9afe0 100644 --- a/varnish-cache/lib/libvarnishapi/shmlog.c +++ b/varnish-cache/lib/libvarnishapi/shmlog.c @@ -90,6 +90,7 @@ struct VSL_data { static int vsl_fd; static struct shmloghead *vsl_lh; +static char vsl_name[PATH_MAX]; static int vsl_nextlog(struct VSL_data *vd, unsigned char **pp); @@ -108,13 +109,13 @@ vsl_shmem_map(const char *varnish_name) { int i; struct shmloghead slh; - char name[PATH_MAX], dirname[PATH_MAX], logname[PATH_MAX]; + char dirname[PATH_MAX], logname[PATH_MAX]; if (vsl_lh != NULL) return (0); - if (varnish_instance(varnish_name, name, - sizeof name, dirname, sizeof dirname) != 0) { + if (varnish_instance(varnish_name, vsl_name, + sizeof vsl_name, dirname, sizeof dirname) != 0) { fprintf(stderr, "Invalid instance name: %s\n", strerror(errno)); return (1); @@ -495,3 +496,9 @@ VSL_OpenStats(const char *varnish_name) return (&vsl_lh->stats); } +const char * +VSL_Name(void) +{ + + return (vsl_name); +}