MINOR: filters: Forward data only if the last filter forwards something

In flt_tcp_payload() and flt_http_payload(), if the last filter does not
forwarding anything, nothing is forwarded, not even the already filtered
data. For now, this patch is useless because the last filter is always sync with
the stream's offset. But it will be mandatory for a bugfix.

(cherry picked from commit 71179a3ea97ea46b28788dfab557c675ec3f3a1e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 93a2d142888f9a5ec1ca271f0fe6a2acc17b0d5d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

[Cf: the flt_tcp_payload() function does not exist. It was added in 2.1. So only
the http part was fixed]
diff --git a/src/filters.c b/src/filters.c
index 45da440..6c85e7c 100644
--- a/src/filters.c
+++ b/src/filters.c
@@ -783,7 +783,7 @@
 	struct filter *filter;
 	unsigned long long *strm_off = &FLT_STRM_OFF(s, msg->chn);
 	unsigned int out = co_data(msg->chn);
-	int ret = len - out;
+	int ret = 0, data = len - out;
 
 	list_for_each_entry(filter, &strm_flt(s)->filters, list) {
 		/* Call "data" filters only */
@@ -793,14 +793,19 @@
 			unsigned long long *flt_off = &FLT_OFF(filter, msg->chn);
 			unsigned int offset = *flt_off - *strm_off;
 
-			ret = FLT_OPS(filter)->http_payload(s, filter, msg, out + offset, ret - offset);
+			ret = FLT_OPS(filter)->http_payload(s, filter, msg, out + offset, data - offset);
 			if (ret < 0)
 				goto end;
 			*flt_off += ret;
-			ret += offset;
+			data = ret + offset;
 		}
 	}
-	*strm_off += ret;
+
+	/* Only forward data if the last filter decides to forward something */
+	if (ret > 0) {
+		ret = data;
+		*strm_off += ret;
+	}
  end:
 	return ret;
 }