r67 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Fri Mar 24 11:22:47 CET 2006


Author: phk
Date: 2006-03-24 11:22:47 +0100 (Fri, 24 Mar 2006)
New Revision: 67

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_shmlog.c
Log:
Add a VSLR() variant which logs a byte range without spending time in
sprintf


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2006-03-24 09:45:39 UTC (rev 66)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2006-03-24 10:22:47 UTC (rev 67)
@@ -9,15 +9,20 @@
 	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
 

Modified: trunk/varnish-cache/bin/varnishd/cache_shmlog.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_shmlog.c	2006-03-24 09:45:39 UTC (rev 66)
+++ trunk/varnish-cache/bin/varnishd/cache_shmlog.c	2006-03-24 10:22:47 UTC (rev 67)
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <assert.h>
+#include <string.h>
 #include <stdarg.h>
 #include <sys/mman.h>
 
@@ -14,7 +15,55 @@
 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, ...)
 {
 	va_list ap;




More information about the varnish-commit mailing list