MINOR: cache/htx: Don't use the same cache on HTX and legacy HTTP proxies

It is not possible to mix the format of messages stored in a cache. So we reject
the configurations with a cache used by an HTX proxy and a legacy HTTP proxy in
same time.
diff --git a/src/cache.c b/src/cache.c
index 1bf996b..e0905ef 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -37,6 +37,9 @@
 #include <common/initcall.h>
 
 /* flt_cache_store */
+#define CACHE_F_LEGACY_HTTP 0x00000001 /* The cache is used to store raw HTTP
+					* messages (legacy implementation) */
+#define CACHE_F_HTX         0x00000002 /* The cache is used to store HTX messages */
 
 static const char *cache_store_flt_id = "cache store filter";
 
@@ -51,6 +54,7 @@
 	unsigned int maxblocks;
 	unsigned int maxobjsz;   /* max-object-size (in bytes) */
 	char id[33];             /* cache name */
+	unsigned int flags;      /* CACHE_F_* */
 };
 
 /*
@@ -882,6 +886,7 @@
 			tmp_cache_config->maxage = 60;
 			tmp_cache_config->maxblocks = 0;
 			tmp_cache_config->maxobjsz = 0;
+			tmp_cache_config->flags = 0;
 		}
 	} else if (strcmp(args[0], "total-max-size") == 0) {
 		unsigned long int maxsize;
@@ -1035,6 +1040,9 @@
 				if (!strcmp(cache->id, cache_ptr)) {
 					/* don't free there, it's still used in the filter conf */
 					cache_ptr = cache;
+					cache->flags |= ((curproxy->options2 & PR_O2_USE_HTX)
+							 ? CACHE_F_HTX
+							 : CACHE_F_LEGACY_HTTP);
 					break;
 				}
 			}
@@ -1060,6 +1068,9 @@
 				if (!strcmp(cache->id, cache_ptr)) {
 					free(cache_ptr);
 					cache_ptr = cache;
+					cache->flags |= ((curproxy->options2 & PR_O2_USE_HTX)
+							 ? CACHE_F_HTX
+							 : CACHE_F_LEGACY_HTTP);
 					break;
 				}
 			}
@@ -1086,6 +1097,9 @@
 					/* there can be only one filter per cache, so we free it there */
 					free(cache_ptr);
 					cache_ptr = cache;
+					cache->flags |= ((curproxy->options2 & PR_O2_USE_HTX)
+							 ? CACHE_F_HTX
+							 : CACHE_F_LEGACY_HTTP);
 					break;
 				}
 			}
@@ -1098,6 +1112,18 @@
 			fconf->conf = cache_ptr;
 		}
 	}
+
+	/* Check if the cache is used by HTX and legacy HTTP proxies in same
+	 * time
+	 */
+	list_for_each_entry(cache, &caches, list) {
+		if ((cache->flags & (CACHE_F_HTX|CACHE_F_LEGACY_HTTP)) == (CACHE_F_HTX|CACHE_F_LEGACY_HTTP)) {
+			ha_alert("Cache '%s': cannot be used by HTX and legacy HTTP proxies in same time.\n",
+				 cache->id);
+			err++;
+		}
+	}
+
 	return err;
 }