[master] 3136e23 Don't forget to handle OIS_ERROR

Poul-Henning Kamp phk at FreeBSD.org
Wed Dec 18 13:10:14 CET 2013


commit 3136e23c611da56ea1537241517d8077667cf4a5
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Dec 18 12:09:56 2013 +0000

    Don't forget to handle OIS_ERROR
    
    Hit by:	scoof

diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c
index 79090fd..65c25d5 100644
--- a/bin/varnishd/cache/cache_http1_deliver.c
+++ b/bin/varnishd/cache/cache_http1_deliver.c
@@ -170,16 +170,24 @@ v1d_WriteDirObj(struct req *req)
 	oi = ObjIterBegin(req->wrk, req->obj);
 	XXXAN(oi);
 
-	while (1) {
+	do {
 		ois = ObjIter(oi, &ptr, &len);
-		if (ois == OIS_DONE) {
+		switch(ois) {
+		case OIS_DONE:
 			AZ(len);
 			break;
-		}
-		if (VDP_bytes(req,
-		     ois == OIS_DATA ? VDP_NULL : VDP_FLUSH,  ptr, len))
+		case OIS_ERROR:
 			break;
-	}
+		case OIS_DATA:
+		case OIS_STREAM:
+			if (VDP_bytes(req,
+			     ois == OIS_DATA ? VDP_NULL : VDP_FLUSH,  ptr, len))
+				ois = OIS_ERROR;
+			break;
+		default:
+			WRONG("Wrong OIS value");
+		}
+	} while (ois == OIS_DATA || ois == OIS_STREAM);
 	(void)VDP_bytes(req, VDP_FINISH,  NULL, 0);
 	ObjIterEnd(&oi);
 }



More information about the varnish-commit mailing list