]> err.no Git - varnish/commitdiff
Add a non-blocking mode to the log reader.
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 16 Sep 2006 14:50:09 +0000 (14:50 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 16 Sep 2006 14:50:09 +0000 (14:50 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1025 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/include/varnishapi.h
varnish-cache/lib/libvarnishapi/shmlog.c

index 772fedd633db402775636f5b7c05e11612ab88f7..a6734b122a8230810b761498d717cff7e1bffe5d 100644 (file)
@@ -22,6 +22,7 @@ struct VSL_data;
 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);
index aef5ad3fd10e2ae6c5709f278939ba6ead622b0e..f25c58669bf3f78798266009e4d0a05a814bf211 100644 (file)
@@ -42,6 +42,7 @@ struct VSL_data {
 
        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 @@ VSL_OpenLog(struct VSL_data *vd)
 
 /*--------------------------------------------------------------------*/
 
+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 @@ vsl_nextlog(struct VSL_data *vd, unsigned char **pp)
                        continue;
                }
                if (*p == SLT_ENDMARKER) {
+                       if (vd->flags & F_NON_BLOCKING)
+                               return (-1);
                        w += SLEEP_USEC;
                        usleep(SLEEP_USEC);
                        continue;