Skip to content

Commit

Permalink
Add a VSL_COPT_TAILSTOP cursor option to the VSM cursor
Browse files Browse the repository at this point in the history
If this option is set, the cursor will return EOF when reaching the log tail.
  • Loading branch information
mbgrydeland committed Oct 10, 2013
1 parent fa0f8b4 commit 7aec15c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 5 additions & 3 deletions include/vapi/vsl.h
Expand Up @@ -201,8 +201,9 @@ void VSL_ResetError(struct VSL_data *vsl);
* Reset any error message.
*/

#define VSL_COPT_TAIL (1 << 0)
#define VSL_COPT_BATCH (1 << 1)
#define VSL_COPT_TAIL (1 << 0)
#define VSL_COPT_BATCH (1 << 1)
#define VSL_COPT_TAILSTOP (1 << 2)
struct VSL_cursor *VSL_CursorVSM(struct VSL_data *vsl, struct VSM_data *vsm,
unsigned options);
/*
Expand All @@ -212,6 +213,7 @@ struct VSL_cursor *VSL_CursorVSM(struct VSL_data *vsl, struct VSM_data *vsm,
* Options:
* VSL_COPT_TAIL Start cursor at log tail
* VSL_COPT_BATCH Return batch records
* VSL_COPT_TAILSTOP Return EOF when reaching the log tail
*
* Return values:
* non-NULL: Pointer to cursor
Expand Down Expand Up @@ -267,7 +269,7 @@ int VSL_Next(struct VSL_cursor *c);
* Return values:
* 1: Cursor points to next log record
* 0: End of log
* -1: End of file (-r) (XXX / -k arg exhausted / "done")
* -1: End of file
* -2: Remote abandoned or closed
* -3: Overrun
* -4: I/O read error - see errno
Expand Down
6 changes: 5 additions & 1 deletion lib/libvarnishapi/vsl_cursor.c
Expand Up @@ -164,7 +164,11 @@ vslc_vsm_next(struct VSL_cursor *cursor)
c->next.ptr = c->head->log;
continue;
}
return (0);
if (c->options & VSL_COPT_TAILSTOP)
/* EOF */
return (-1);
else
return (0);
}

if (c->next.ptr == c->head->log)
Expand Down

0 comments on commit 7aec15c

Please sign in to comment.