#include <string.h>
#include <stdarg.h>
#include <sys/mman.h>
+#include <pthread.h>
#include "libvarnish.h"
#include "shmlog.h"
static struct shmloghead *loghead;
static unsigned char *logstart, *logend;
+static pthread_mutex_t vsl_mutex;
/*
* This variant copies a byte-range directly to the log, without
if (e - b > 255)
e = b + 255;
- /* XXX: Lock */
+ AZ(pthread_mutex_lock(&vsl_mutex));
q = NULL;
p = logstart + loghead->ptr;
assert(p < logend);
loghead->ptr = (p + 4 + (e - b)) - logstart;
- /* XXX: Unlock */
+ AZ(pthread_mutex_unlock(&vsl_mutex));
}
va_start(ap, fmt);
- /* XXX: Lock */
+ AZ(pthread_mutex_lock(&vsl_mutex));
q = NULL;
p = logstart + loghead->ptr;
assert(p < logend);
loghead->ptr = (p + 4 + n) - logstart;
- /* XXX: Unlock */
+ AZ(pthread_mutex_unlock(&vsl_mutex));
va_end(ap);
}
logstart = (unsigned char *)loghead + loghead->start;
logend = logstart + loghead->size;
VSL_stats = &loghead->stats;
+ AZ(pthread_mutex_init(&vsl_mutex, NULL));
}
/*--------------------------------------------------------------------*/