From: phk Date: Tue, 25 Sep 2007 06:56:23 +0000 (+0000) Subject: Polish shmlog: X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bea1330e8736b4235562b63488f30a67480bc6c;p=varnish Polish shmlog: The id argument is a file descriptor, so it should be typed "int". We must have a fmt argument. Use pdiff. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2017 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 7e9cef55..56b9c77c 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -508,10 +508,10 @@ void SES_Charge(struct sess *sp); void VSL_Init(void); #ifdef SHMLOGHEAD_MAGIC -void VSLR(enum shmlogtag tag, unsigned id, const char *b, const char *e); -void VSL(enum shmlogtag tag, unsigned id, const char *fmt, ...); -void WSLR(struct worker *w, enum shmlogtag tag, unsigned id, const char *b, const char *e); -void WSL(struct worker *w, enum shmlogtag tag, unsigned id, const char *fmt, ...); +void VSLR(enum shmlogtag tag, int id, const char *b, const char *e); +void VSL(enum shmlogtag tag, int id, const char *fmt, ...); +void WSLR(struct worker *w, enum shmlogtag tag, int id, const char *b, const char *e); +void WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...); void WSL_Flush(struct worker *w); #define INCOMPL() do { \ VSL(SLT_Debug, 0, "INCOMPLETE AT: %s(%d)", __func__, __LINE__); \ diff --git a/varnish-cache/bin/varnishd/shmlog.c b/varnish-cache/bin/varnishd/shmlog.c index 7e11cee5..23a01172 100644 --- a/varnish-cache/bin/varnishd/shmlog.c +++ b/varnish-cache/bin/varnishd/shmlog.c @@ -83,7 +83,7 @@ vsl_wrap(void) /*--------------------------------------------------------------------*/ void -VSLR(enum shmlogtag tag, unsigned id, const char *b, const char *e) +VSLR(enum shmlogtag tag, int id, const char *b, const char *e) { unsigned char *p; unsigned l; @@ -93,7 +93,7 @@ VSLR(enum shmlogtag tag, unsigned id, const char *b, const char *e) e = strchr(b, '\0'); /* Truncate */ - l = e - b; + l = pdiff(b, e); if (l > 255) { l = 255; e = b + l; @@ -126,12 +126,13 @@ VSLR(enum shmlogtag tag, unsigned id, const char *b, const char *e) /*--------------------------------------------------------------------*/ void -VSL(enum shmlogtag tag, unsigned id, const char *fmt, ...) +VSL(enum shmlogtag tag, int id, const char *fmt, ...) { va_list ap; unsigned char *p; unsigned n; + AN(fmt); va_start(ap, fmt); if (strchr(fmt, '%') == NULL) { @@ -150,11 +151,9 @@ VSL(enum shmlogtag tag, unsigned id, const char *fmt, ...) p = logstart + loghead->ptr; n = 0; - if (fmt != NULL) { - n = vsnprintf((char *)(p + 4), 256, fmt, ap); - if (n > 255) - n = 255; /* we truncate long fields */ - } + n = vsnprintf((char *)(p + 4), 256, fmt, ap); + if (n > 255) + n = 255; /* we truncate long fields */ p[1] = n & 0xff; p[2] = (id >> 8) & 0xff; p[3] = id & 0xff; @@ -181,7 +180,7 @@ WSL_Flush(struct worker *w) if (w->wlp == w->wlog) return; - l = w->wlp - w->wlog; + l = pdiff(w->wlog, w->wlp); LOCKSHM(&vsl_mtx); VSL_stats->shm_writes++; VSL_stats->shm_records += w->wlr; @@ -201,7 +200,7 @@ WSL_Flush(struct worker *w) /*--------------------------------------------------------------------*/ void -WSLR(struct worker *w, enum shmlogtag tag, unsigned id, const char *b, const char *e) +WSLR(struct worker *w, enum shmlogtag tag, int id, const char *b, const char *e) { unsigned char *p; unsigned l; @@ -211,7 +210,7 @@ WSLR(struct worker *w, enum shmlogtag tag, unsigned id, const char *b, const cha e = strchr(b, '\0'); /* Truncate */ - l = e - b; + l = pdiff(b, e); if (l > 255) { l = 255; e = b + l; @@ -239,12 +238,13 @@ WSLR(struct worker *w, enum shmlogtag tag, unsigned id, const char *b, const cha /*--------------------------------------------------------------------*/ void -WSL(struct worker *w, enum shmlogtag tag, unsigned id, const char *fmt, ...) +WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...) { va_list ap; unsigned char *p; unsigned n; + AN(fmt); va_start(ap, fmt); if (strchr(fmt, '%') == NULL) { @@ -260,11 +260,9 @@ WSL(struct worker *w, enum shmlogtag tag, unsigned id, const char *fmt, ...) p = w->wlp; n = 0; - if (fmt != NULL) { - n = vsnprintf((char *)(p + 4), 256, fmt, ap); - if (n > 255) - n = 255; /* we truncate long fields */ - } + n = vsnprintf((char *)(p + 4), 256, fmt, ap); + if (n > 255) + n = 255; /* we truncate long fields */ p[1] = n & 0xff; p[2] = (id >> 8) & 0xff; p[3] = id & 0xff;