BUG/MEDIUM: compression: Add a flag to know the filter is still processing data

Since the commit acfd71b97 ("BUG/MINOR: http-comp: Preserve
HTTP_MSGF_COMPRESSIONG flag on the response"), there is no more flag to know
when the compression ends. This means it is possible to finish the
compression several time if there are trailers.

So, we reintroduce almost the same mechanism but with a dedicated flag. So
now, there is a bits field in the compression filter context.

The commit above is marked to be backported as far as 2.0. Thus this patch
must also be backported as far as 2.0.

(cherry picked from commit 12554d00f6ed16324a0dfbafb5230f8f0136e4ba)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 734863ecfa1f8a620904fd9332e01673728c784b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c
index cdb9f04..91e4f8e 100644
--- a/src/flt_http_comp.c
+++ b/src/flt_http_comp.c
@@ -25,6 +25,8 @@
 #include <haproxy/stream.h>
 #include <haproxy/tools.h>
 
+#define COMP_STATE_PROCESSING 0x01
+
 const char *http_comp_flt_id = "compression filter";
 
 struct flt_ops comp_ops;
@@ -32,6 +34,7 @@
 struct comp_state {
 	struct comp_ctx  *comp_ctx;   /* compression context */
 	struct comp_algo *comp_algo;  /* compression algorithm if not NULL */
+	unsigned int      flags;      /* COMP_STATE_* */
 };
 
 /* Pools used to allocate comp_state structs */
@@ -93,6 +96,7 @@
 
 	st->comp_algo = NULL;
 	st->comp_ctx  = NULL;
+	st->flags     = 0;
 	filter->ctx   = st;
 
 	/* Register post-analyzer on AN_RES_WAIT_HTTP because we need to
@@ -135,6 +139,7 @@
 			if (!set_compression_response_header(st, s, msg))
 				goto end;
 			register_data_filter(s, msg->chn, filter);
+			st->flags |= COMP_STATE_PROCESSING;
 		}
 	}
 
@@ -213,7 +218,7 @@
 			case HTX_BLK_TLR:
 			case HTX_BLK_EOT:
 			case HTX_BLK_EOM:
-				if (msg->flags & HTTP_MSGF_COMPRESSING) {
+				if (st->flags & COMP_STATE_PROCESSING) {
 					if (htx_compression_buffer_init(htx, &trash) < 0) {
 						msg->chn->flags |= CF_WAKE_WRITE;
 						goto end;
@@ -231,6 +236,7 @@
 					}
 					/* We let the mux add last empty chunk and empty trailers */
 				}
+				st->flags &= ~COMP_STATE_PROCESSING;
 				/* fall through */
 
 			default: