Mailing List Archive

r1025 - in trunk/varnish-cache: include lib/libvarnishapi
Author: des
Date: 2006-09-16 16:50:09 +0200 (Sat, 16 Sep 2006)
New Revision: 1025

Modified:
trunk/varnish-cache/include/varnishapi.h
trunk/varnish-cache/lib/libvarnishapi/shmlog.c
Log:
Add a non-blocking mode to the log reader.

Modified: trunk/varnish-cache/include/varnishapi.h
===================================================================
--- trunk/varnish-cache/include/varnishapi.h 2006-09-16 14:21:04 UTC (rev 1024)
+++ trunk/varnish-cache/include/varnishapi.h 2006-09-16 14:50:09 UTC (rev 1025)
@@ -22,6 +22,7 @@
struct VSL_data *VSL_New(void);
void VSL_Select(struct VSL_data *vd, unsigned tag);
int VSL_OpenLog(struct VSL_data *vd);
+void VSL_NonBlocking(struct VSL_data *vd, int nb);
int VSL_Dispatch(struct VSL_data *vd, vsl_handler *func, void *priv);
int VSL_NextLog(struct VSL_data *lh, unsigned char **pp);
int VSL_Arg(struct VSL_data *vd, int arg, const char *opt);

Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2006-09-16 14:21:04 UTC (rev 1024)
+++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2006-09-16 14:50:09 UTC (rev 1025)
@@ -42,6 +42,7 @@

unsigned flags;
#define F_SEEN_IX (1 << 0)
+#define F_NON_BLOCKING (1 << 1)

unsigned char map[NFD];
#define M_CLIENT (1 << 0)
@@ -165,6 +166,17 @@

/*--------------------------------------------------------------------*/

+void
+VSL_NonBlocking(struct VSL_data *vd, int nb)
+{
+ if (nb)
+ vd->flags |= F_NON_BLOCKING;
+ else
+ vd->flags &= ~F_NON_BLOCKING;
+}
+
+/*--------------------------------------------------------------------*/
+
static int
vsl_nextlog(struct VSL_data *vd, unsigned char **pp)
{
@@ -191,6 +203,8 @@
continue;
}
if (*p == SLT_ENDMARKER) {
+ if (vd->flags & F_NON_BLOCKING)
+ return (-1);
w += SLEEP_USEC;
usleep(SLEEP_USEC);
continue;