[master] f5b92e2 Make VDP_DeliverObj() return a simple int status code

Poul-Henning Kamp phk at FreeBSD.org
Thu Dec 10 01:23:28 CET 2015


commit f5b92e27478874a46b71d4aa0c3e35bdaa31f396
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Dec 9 22:20:16 2015 +0000

    Make VDP_DeliverObj() return a simple int status code

diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c
index 0e84bae..9de94dd 100644
--- a/bin/varnishd/cache/cache_deliver_proc.c
+++ b/bin/varnishd/cache/cache_deliver_proc.c
@@ -114,10 +114,11 @@ VDP_close(struct req *req)
 
 /*--------------------------------------------------------------------*/
 
-enum objiter_status
+int
 VDP_DeliverObj(struct req *req)
 {
 	enum objiter_status ois;
+	int err = 0;
 	ssize_t len;
 	void *oi;
 	void *ptr;
@@ -134,6 +135,7 @@ VDP_DeliverObj(struct req *req)
 			AZ(len);
 			break;
 		case OIS_ERROR:
+			err = -1;
 			break;
 		case OIS_DATA:
 		case OIS_STREAM:
@@ -147,5 +149,5 @@ VDP_DeliverObj(struct req *req)
 	} while (ois == OIS_DATA || ois == OIS_STREAM);
 	(void)VDP_bytes(req, VDP_FLUSH, NULL, 0);
 	ObjIterEnd(req->objcore, &oi);
-	return (ois);
+	return (err);
 }
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index 016bcb0..aba9d65 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -108,7 +108,7 @@ struct vdp_entry {
 int VDP_bytes(struct req *, enum vdp_action act, const void *ptr, ssize_t len);
 void VDP_push(struct req *, vdp_bytes *func, void *priv, int bottom);
 void VDP_close(struct req *req);
-enum objiter_status VDP_DeliverObj(struct req *req);
+int VDP_DeliverObj(struct req *req);
 
 vdp_bytes VDP_gunzip;
 vdp_bytes VDP_ESI;
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index 0135ed8..99ac91f 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -81,7 +81,7 @@ v1d_error(struct req *req, const char *msg)
 void __match_proto__(vtr_deliver_f)
 V1D_Deliver(struct req *req, struct busyobj *bo, int sendbody)
 {
-	enum objiter_status ois;
+	int err = 0;
 
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	CHECK_OBJ_ORNULL(bo, BUSYOBJ_MAGIC);
@@ -125,16 +125,15 @@ V1D_Deliver(struct req *req, struct busyobj *bo, int sendbody)
 	if (DO_DEBUG(DBG_FLUSH_HEAD))
 		(void)V1L_Flush(req->wrk);
 
-	ois = OIS_DONE;
 	if (sendbody && req->resp_len != 0) {
 		if (req->res_mode & RES_CHUNKED)
 			V1L_Chunked(req->wrk);
-		ois = VDP_DeliverObj(req);
-		if (ois == OIS_DONE && (req->res_mode & RES_CHUNKED))
+		err = VDP_DeliverObj(req);
+		if (!err && (req->res_mode & RES_CHUNKED))
 			V1L_EndChunk(req->wrk);
 	}
 
-	if ((V1L_FlushRelease(req->wrk) || ois != OIS_DONE) && req->sp->fd >= 0)
+	if ((V1L_FlushRelease(req->wrk) || err) && req->sp->fd >= 0)
 		SES_Close(req->sp, SC_REM_CLOSE);
 	AZ(req->wrk->v1l);
 	VDP_close(req);



More information about the varnish-commit mailing list