Commit 51573e0d authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

Add a non-blocking mode to the log reader.

git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1025 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 868edc53
...@@ -22,6 +22,7 @@ struct VSL_data; ...@@ -22,6 +22,7 @@ struct VSL_data;
struct VSL_data *VSL_New(void); struct VSL_data *VSL_New(void);
void VSL_Select(struct VSL_data *vd, unsigned tag); void VSL_Select(struct VSL_data *vd, unsigned tag);
int VSL_OpenLog(struct VSL_data *vd); 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_Dispatch(struct VSL_data *vd, vsl_handler *func, void *priv);
int VSL_NextLog(struct VSL_data *lh, unsigned char **pp); int VSL_NextLog(struct VSL_data *lh, unsigned char **pp);
int VSL_Arg(struct VSL_data *vd, int arg, const char *opt); int VSL_Arg(struct VSL_data *vd, int arg, const char *opt);
......
...@@ -42,6 +42,7 @@ struct VSL_data { ...@@ -42,6 +42,7 @@ struct VSL_data {
unsigned flags; unsigned flags;
#define F_SEEN_IX (1 << 0) #define F_SEEN_IX (1 << 0)
#define F_NON_BLOCKING (1 << 1)
unsigned char map[NFD]; unsigned char map[NFD];
#define M_CLIENT (1 << 0) #define M_CLIENT (1 << 0)
...@@ -165,6 +166,17 @@ VSL_OpenLog(struct VSL_data *vd) ...@@ -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 static int
vsl_nextlog(struct VSL_data *vd, unsigned char **pp) vsl_nextlog(struct VSL_data *vd, unsigned char **pp)
{ {
...@@ -191,6 +203,8 @@ vsl_nextlog(struct VSL_data *vd, unsigned char **pp) ...@@ -191,6 +203,8 @@ vsl_nextlog(struct VSL_data *vd, unsigned char **pp)
continue; continue;
} }
if (*p == SLT_ENDMARKER) { if (*p == SLT_ENDMARKER) {
if (vd->flags & F_NON_BLOCKING)
return (-1);
w += SLEEP_USEC; w += SLEEP_USEC;
usleep(SLEEP_USEC); usleep(SLEEP_USEC);
continue; continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment