MEDIUM: filters: Add pre and post analyzer callbacks
'channel_analyze' callback has been removed. Now, there are 2 callbacks to
surround calls to analyzers:
* channel_pre_analyze: Called BEFORE all filterable analyzers. it can be
called many times for the same analyzer, once at each loop until the
analyzer finishes its processing. This callback is resumable, it returns a
negative value if an error occurs, 0 if it needs to wait, any other value
otherwise.
* channel_post_analyze: Called AFTER all filterable analyzers. Here, AFTER
means when an analyzer finishes its processing. This callback is NOT
resumable, it returns a negative value if an error occurs, any other value
otherwise.
Pre and post analyzer callbacks are not automatically called. 'pre_analyzers'
and 'post_analyzers' bit fields in the filter structure must be set to the right
value using AN_* flags (see include/types/channel.h).
The flag AN_RES_ALL has been added (AN_REQ_ALL already exists) to ease the life
of filter developers. AN_REQ_ALL and AN_RES_ALL include all filterable
analyzers.
diff --git a/include/proto/filters.h b/include/proto/filters.h
index 7020285..c351f6e 100644
--- a/include/proto/filters.h
+++ b/include/proto/filters.h
@@ -114,7 +114,8 @@
void flt_http_reply(struct stream *s, short status, const struct chunk *msg);
int flt_start_analyze(struct stream *s, struct channel *chn, unsigned int an_bit);
-int flt_analyze(struct stream *s, struct channel *chn, unsigned int an_bit);
+int flt_pre_analyze(struct stream *s, struct channel *chn, unsigned int an_bit);
+int flt_post_analyze(struct stream *s, struct channel *chn, unsigned int an_bit);
int flt_analyze_http_headers(struct stream *s, struct channel *chn, unsigned int an_bit);
int flt_end_analyze(struct stream *s, struct channel *chn, unsigned int an_bit);
diff --git a/include/types/channel.h b/include/types/channel.h
index b31f493..dd50993 100644
--- a/include/types/channel.h
+++ b/include/types/channel.h
@@ -156,6 +156,7 @@
#define AN_RES_HTTP_PROCESS_FE 0x00040000 /* process frontend's HTTP part (same for now) */
#define AN_RES_STORE_RULES 0x00080000 /* table persistence matching */
#define AN_RES_HTTP_XFER_BODY 0x00100000 /* forward response body */
+#define AN_RES_ALL 0x001f0000 /* all of the response analysers */
#define AN_FLT_START_FE 0x01000000
#define AN_FLT_START_BE 0x02000000
diff --git a/include/types/filters.h b/include/types/filters.h
index e01e225..62fcfb1 100644
--- a/include/types/filters.h
+++ b/include/types/filters.h
@@ -77,10 +77,14 @@
* - channel_start_analyze: Called when a filter starts to analyze a channel.
* Returns a negative value if an error occurs, 0 if
* it needs to wait, any other value otherwise.
- * - channel_analyze : Called before each analyzer attached to a channel,
+ * - channel_pre_analyze : Called before each analyzer attached to a channel,
* expects analyzers responsible for data sending.
* Returns a negative value if an error occurs, 0 if
* it needs to wait, any other value otherwise.
+ * - channel_post_analyze: Called after each analyzer attached to a channel,
+ * expects analyzers responsible for data sending.
+ * Returns a negative value if an error occurs,
+ * any other value otherwise.
* - channel_end_analyze : Called when all other analyzers have finished their
* processing.
* Returns a negative value if an error occurs, 0 if
@@ -140,7 +144,8 @@
* Channel callbacks
*/
int (*channel_start_analyze)(struct stream *s, struct filter *f, struct channel *chn);
- int (*channel_analyze) (struct stream *s, struct filter *f, struct channel *chn, unsigned int an_bit);
+ int (*channel_pre_analyze) (struct stream *s, struct filter *f, struct channel *chn, unsigned int an_bit);
+ int (*channel_post_analyze) (struct stream *s, struct filter *f, struct channel *chn, unsigned int an_bit);
int (*channel_end_analyze) (struct stream *s, struct filter *f, struct channel *chn);
/*
@@ -202,6 +207,8 @@
* 0: request channel, 1: response channel */
unsigned int fwd[2]; /* Offset, relative to buf->p, to the next byte to forward for a specific channel
* 0: request channel, 1: response channel */
+ unsigned int pre_analyzers; /* bit field indicating analyzers to pre-process */
+ unsigned int post_analyzers; /* bit field indicating analyzers to post-process */
struct list list; /* Next filter for the same proxy/stream */
};