r5207 - trunk/varnish-cache/doc/sphinx/reference

phk at varnish-cache.org phk at varnish-cache.org
Tue Sep 14 13:06:33 CEST 2010


Author: phk
Date: 2010-09-14 13:06:33 +0200 (Tue, 14 Sep 2010)
New Revision: 5207

Modified:
   trunk/varnish-cache/doc/sphinx/reference/vmod.rst
Log:
Update with details on procedures



Modified: trunk/varnish-cache/doc/sphinx/reference/vmod.rst
===================================================================
--- trunk/varnish-cache/doc/sphinx/reference/vmod.rst	2010-09-14 09:12:22 UTC (rev 5206)
+++ trunk/varnish-cache/doc/sphinx/reference/vmod.rst	2010-09-14 11:06:33 UTC (rev 5207)
@@ -43,19 +43,29 @@
 	Meta meta_function
 	Function STRING toupper(STRING_LIST)
 	Function STRING tolower(PRIV_VCL, STRING_LIST)
+	Function VOID set_ip_tos(INT)
 
 The first line gives the name of the module, nothing special there.
 
 The second line specifies an optional "Meta" function, which will
 be called whenever a VCL program which imports this VMOD is loaded
 or unloaded.  You probably will not need such a function, so we will
-postpone that subject until later.
+postpone that subject until further down.
 
-The next two lines specify the functions in the VMOD, along with the
+The next three lines specify two functions in the VMOD, along with the
 types of the arguments, and that is probably where the hardest bit
 of writing a VMOD is to be found, so we will talk about that at length
 in a moment.
 
+Notice that the third function returns VOID, that makes it a "procedure"
+in VCL lingo, meaning that it cannot be used in expressions, right
+side of assignments and such places.  Instead it can be used as a
+primary action, something functions which return a value can not::
+
+	sub vcl_recv {
+		std.set_ip_tos(32);
+	}
+
 Running vmod.py on the vmod.vcc file, produces an "vcc_if.c" and
 "vcc_if.h" files, which you must use to build your shared library
 file.
@@ -186,6 +196,12 @@
 	When the last VCL program that uses the module is discarded
 	the shared library containing the module will be dlclosed().
 
+VOID
+	C-type: void
+
+	Can only be used for return-value, which makes the function a VCL
+	procedure.
+
 IP, BOOL, HEADER
 	XXX: these types are not released for use in vmods yet.
 




More information about the varnish-commit mailing list