[master] 16b84c2 use s?size_t for req_bodybytes and VRB_Cache

Nils Goroll nils.goroll at uplex.de
Wed Mar 4 17:24:56 CET 2015


commit 16b84c2a0c560da2765068dba1d4458b4706f586
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Mar 4 16:49:59 2015 +0100

    use s?size_t for req_bodybytes and VRB_Cache
    
    The VRT side of things still needs attention

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index d20222c..183fc7a 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -587,7 +587,7 @@ struct req {
 	enum sess_close		doclose;
 	double			d_ttl;
 
-	uint64_t		req_bodybytes;	/* Parsed req bodybytes */
+	ssize_t		req_bodybytes;	/* Parsed req bodybytes */
 
 	uint16_t		err_code;
 	const char		*err_reason;
@@ -760,7 +760,7 @@ void V1P_Process(struct req *req, struct busyobj *bo, int fd);
 
 /* cache_req_body.c */
 int VRB_Ignore(struct req *req);
-int VRB_Cache(struct req *req, ssize_t maxsize);
+ssize_t VRB_Cache(struct req *req, ssize_t maxsize);
 ssize_t VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv);
 void VRB_Free(struct req *req);
 
diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c
index c897153..c73db54 100644
--- a/bin/varnishd/cache/cache_req_body.c
+++ b/bin/varnishd/cache/cache_req_body.c
@@ -191,7 +191,7 @@ VRB_Free(struct req *req)
  * off to prevent parallelism.
  */
 
-int
+ssize_t
 VRB_Cache(struct req *req, ssize_t maxsize)
 {
 	ssize_t l, yet;
@@ -220,6 +220,7 @@ VRB_Cache(struct req *req, ssize_t maxsize)
 	vfc = req->htc->vfc;
 
 	if (req->htc->content_length > maxsize) {
+		// XXX #1664
 		req->req_body_status = REQ_BODY_FAIL;
 		(void)VFP_Error(vfc, "Request body too big to cache");
 		return (-1);
@@ -240,6 +241,7 @@ VRB_Cache(struct req *req, ssize_t maxsize)
 		return (-1);
 	}
 
+	AZ(req->req_bodybytes);
 	AN(req->htc);
 	yet = req->htc->content_length;
 	if (yet < 0)
@@ -265,7 +267,7 @@ VRB_Cache(struct req *req, ssize_t maxsize)
 	VFP_Close(vfc);
 
 	if (vfps == VFP_END) {
-
+		assert(req->req_bodybytes >= 0);
 		if (req->req_bodybytes != req->htc->content_length) {
 			/* We must update also the "pristine" req.* copy */
 			http_Unset(req->http0, H_Content_Length);
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 6148b2b..6851bc0 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -475,6 +475,8 @@ VRT_ban_string(VRT_CTX, const char *str)
 
 /*--------------------------------------------------------------------
  *
+ * XXX this really should be ssize_t VRT_CacheReqBody(VRT_CTX, size_t)
+ * - change with next VRT major bump
  */
 
 int
diff --git a/include/vrt.h b/include/vrt.h
index 3e3589e..d5a579c 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -37,6 +37,9 @@
  * Whenever something is added, increment MINOR version
  * Whenever something is deleted or changed in a way which is not
  * binary/load-time compatible, increment MAJOR version
+ *
+ * changes to consider with next VRT_MAJOR_VERSION bump:
+ * - cache_vrt.c: -> ssize_t VRT_CacheReqBody(VRT_CTX, size_t)
  */
 
 #define VRT_MAJOR_VERSION	2U



More information about the varnish-commit mailing list