MINOR: filters: Extract proxy stuff from the struct filter
Now, filter's configuration (.id, .conf and .ops fields) is stored in the
structure 'flt_conf'. So proxies own a flt_conf list instead of a filter
list. When a filter is attached to a stream, it gets a pointer on its
configuration. This avoids mixing the filter's context (owns by a stream) and
its configuration (owns by a proxy). It also saves 2 pointers per filter
instance.
diff --git a/include/proto/filters.h b/include/proto/filters.h
index e4061a7..f9b0fb0 100644
--- a/include/proto/filters.h
+++ b/include/proto/filters.h
@@ -29,6 +29,10 @@
#include <proto/channel.h>
+#define FLT_ID(flt) (flt)->config->id
+#define FLT_CONF(flt) (flt)->config->conf
+#define FLT_OPS(flt) (flt)->config->ops
+
/* Useful macros to access per-channel values. It can be safely used inside
* filters. */
#define CHN_IDX(chn) (((chn)->flags & CF_ISRESP) == CF_ISRESP)
diff --git a/include/types/filters.h b/include/types/filters.h
index c433078..8446946 100644
--- a/include/types/filters.h
+++ b/include/types/filters.h
@@ -28,6 +28,7 @@
struct proxy;
struct stream;
struct channel;
+struct flt_conf;
struct filter;
/* Descriptor for a "filter" keyword. The ->parse() function returns 0 in case
@@ -40,7 +41,7 @@
struct flt_kw {
const char *kw;
int (*parse)(char **args, int *cur_arg, struct proxy *px,
- struct filter *filter, char **err);
+ struct flt_conf *fconf, char **err);
};
/*
@@ -123,9 +124,9 @@
/*
* Callbacks to manage the filter lifecycle
*/
- int (*init) (struct proxy *p, struct filter *f);
- void (*deinit)(struct proxy *p, struct filter *f);
- int (*check) (struct proxy *p, struct filter *f);
+ int (*init) (struct proxy *p, struct flt_conf *fconf);
+ void (*deinit)(struct proxy *p, struct flt_conf *fconf);
+ int (*check) (struct proxy *p, struct flt_conf *fconf);
/*
* Stream callbacks
@@ -171,9 +172,18 @@
#define STRM_FLT_FL_HAS_FILTERS 0x0001 /* The stream has at least one filter */
/*
- * Structure representing the state of a filter. When attached to a proxy, only
- * <ops> and <conf> field (and optionnaly <id>) are set. All other fields are
- * used when the filter is attached to a stream.
+ * Structure representing the filter configuration, attached to a proxy and
+ * accessible from a filter when instantiated in a stream
+ */
+struct flt_conf {
+ const char *id; /* The filter id */
+ struct flt_ops *ops; /* The filter callbacks */
+ void *conf; /* The filter configuration */
+ struct list list; /* Next filter for the same proxy */
+};
+
+/*
+ * Structure reprensenting a filter instance attached to a stream
*
* 2D-Array fields are used to store info per channel. The first index stands
* for the request channel, and the second one for the response channel.
@@ -182,9 +192,7 @@
* access these values using FLT_NXT and FLT_FWD macros.
*/
struct filter {
- const char *id; /* The filter id */
- struct flt_ops *ops; /* The filter callbacks */
- void *conf; /* The filter configuration */
+ struct flt_conf *config; /* the filter's configuration */
void *ctx; /* The filter context (opaque) */
unsigned short flags; /* FLT_FL_* */
unsigned int next[2]; /* Offset, relative to buf->p, to the next byte to parse for a specific channel
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 71fd35d..79a3411 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -432,8 +432,7 @@
* this backend. If not specified or void, then the backend
* name is used
*/
-
- struct list filters;
+ struct list filter_configs; /* list of the filters that are declared on this proxy */
};
struct switching_rule {