]> err.no Git - varnish/commitdiff
Add a VSLR() variant which logs a byte range without spending time in
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 24 Mar 2006 10:22:47 +0000 (10:22 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 24 Mar 2006 10:22:47 +0000 (10:22 +0000)
sprintf

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@67 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_shmlog.c

index 0ec110dd57587c3f375d190581f08a36262cb60e..249089de23eae5d81032a152aebb6e382c7356ed 100644 (file)
@@ -9,15 +9,20 @@ struct sess {
        char            rcv[VCA_RXBUFSIZE + 1];
        char            addr[VCA_ADDRBUFSIZE];
        unsigned        rcv_len;
-       struct event    rd_e;
+       struct event    *rd_e;
+       struct sessmem  *mem;
 };
 
 /* cache_acceptor.c */
 void *vca_main(void *arg);
 
+/* cache_httpd.c */
+void HttpdAnalyze(struct sess *sp);
+
 /* cache_shmlog.c */
 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, ...);
 #endif
 
index 562b437def528a760e7809ef27885f39e231e86d..aa2ad9bdca5dcaa64a1ea91d9134c85abfa6e40f 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <assert.h>
+#include <string.h>
 #include <stdarg.h>
 #include <sys/mman.h>
 
 static struct shmloghead *loghead;
 static unsigned char *logstart, *logend;
 
+/*
+ * This variant copies a byte-range directly to the log, without
+ * taking the detour over sprintf()
+ */
+void
+VSLR(enum shmlogtag tag, unsigned id, const char *b, const char *e)
+{
+       va_list ap;
+       unsigned char *p, *q;
+
+       assert(b != NULL);
+       if (e == NULL)
+               e = strchr(b, '\0');
+       assert(e != NULL);
+
+       /* Truncate */
+       if (e - b > 255)
+               e = b + 255;
+
+       /* XXX: Lock */
+       q = NULL;
+       p = logstart + loghead->ptr;
+       assert(p < logend);
+
+       /* Wrap if necessary */
+       if (p + 4 + (e - b) > logend) {
+               q = p;
+               p = logstart;
+               *p = SLT_ENDMARKER;
+       }
+       p[1] = e - b;
+       p[2] = id >> 8;
+       p[3] = id & 0xff;
+       memcpy(p + 4, b, e - b);
+       p[0] = tag;
+
+       if (q != NULL)
+               *q = SLT_WRAPMARKER;
+
+       loghead->ptr = (p + 4 + (e - b)) - logstart;
+       
+       /* XXX: Unlock */
+
+       va_end(ap);
+}
+
+
 void
 VSL(enum shmlogtag tag, unsigned id, const char *fmt, ...)
 {