[master] f49e3b6 VSLQ_SetCursor method

Martin Blix Grydeland martin at varnish-software.com
Thu Apr 9 15:16:28 CEST 2015


commit f49e3b697afe139d4048b86d9b7a9b75e5c325fd
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Tue Mar 31 17:29:12 2015 +0200

    VSLQ_SetCursor method
    
    This sets the input cursor to be used by the query.

diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h
index 3a09054..d87b304 100644
--- a/include/vapi/vsl.h
+++ b/include/vapi/vsl.h
@@ -486,6 +486,18 @@ void VSLQ_Delete(struct VSLQ **pvslq);
 	 * Any cursor owned by the query will be deleted.
 	 */
 
+void VSLQ_SetCursor(struct VSLQ *vslq, struct VSL_cursor **cp);
+	/*
+	 * Set the cursor to use.
+	 *
+	 * Any previous cursor owned by the query will be deleted. Will
+	 * call VSLQ_Flush.
+	 *
+	 * Arguments:
+	 *      vslq: The VSLQ query
+	 *        cp: Pointer to the cursor to use or NULL
+	 */
+
 int VSLQ_Dispatch(struct VSLQ *vslq, VSLQ_dispatch_f *func, void *priv);
 	/*
 	 * Process log and call func for each set matching the specified
diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map
index 0a9cd7d..f96c9c1 100644
--- a/lib/libvarnishapi/libvarnishapi.map
+++ b/lib/libvarnishapi/libvarnishapi.map
@@ -128,4 +128,5 @@ LIBVARNISHAPI_1.3 {
 LIBVARNISHAPI_1.4 {
   global:
 	VNUM;
+	VSLQ_SetCursor;
 } LIBVARNISHAPI_1.0;
diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c
index 0aa68a9..1e4a617 100644
--- a/lib/libvarnishapi/vsl_dispatch.c
+++ b/lib/libvarnishapi/vsl_dispatch.c
@@ -1130,6 +1130,26 @@ VSLQ_Delete(struct VSLQ **pvslq)
 	FREE_OBJ(vslq);
 }
 
+void
+VSLQ_SetCursor(struct VSLQ *vslq, struct VSL_cursor **cp)
+{
+
+	CHECK_OBJ_NOTNULL(vslq, VSLQ_MAGIC);
+
+	if (vslq->c != NULL) {
+		(void)VSLQ_Flush(vslq, NULL, NULL);
+		AZ(vslq->n_outstanding);
+		VSL_DeleteCursor(vslq->c);
+		vslq->c = NULL;
+	}
+
+	if (cp != NULL) {
+		AN(*cp);
+		vslq->c = *cp;
+		*cp = NULL;
+	}
+}
+
 /* Regard each log line as a single transaction, feed it through the query
    and do the callback */
 static int



More information about the varnish-commit mailing list