[master] 7aec15c Add a VSL_COPT_TAILSTOP cursor option to the VSM cursor

Martin Blix Grydeland martin at varnish-cache.org
Thu Oct 10 16:48:39 CEST 2013


commit 7aec15caa27fc9d3cdd6ffe43d91367e5d42c447
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Thu Oct 10 15:36:29 2013 +0200

    Add a VSL_COPT_TAILSTOP cursor option to the VSM cursor
    
    If this option is set, the cursor will return EOF when reaching the log tail.

diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h
index 03d6e6c..a68e41f 100644
--- a/include/vapi/vsl.h
+++ b/include/vapi/vsl.h
@@ -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);
        /*
@@ -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
@@ -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
diff --git a/lib/libvarnishapi/vsl_cursor.c b/lib/libvarnishapi/vsl_cursor.c
index f15c686..d37a454 100644
--- a/lib/libvarnishapi/vsl_cursor.c
+++ b/lib/libvarnishapi/vsl_cursor.c
@@ -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)



More information about the varnish-commit mailing list