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
#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, ...)
{