From: Joe Orton Date: Mon, 3 Dec 2007 10:55:58 +0000 (+0000) Subject: Further to r599711; document new API guarantee for handling non-NULL X-Git-Tag: 2.3.0~1184 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8026ae588964b49614ccd4da2a20186a1d25a514;p=thirdparty%2Fapache%2Fhttpd.git Further to r599711; document new API guarantee for handling non-NULL request_rec pointer when adding connection filters; minor MMN bump: * server/util_filter.c (add_any_filter_handle): Set f->r for connection filters even if passed-in r is non-NULL. Style nit fix also. * include/util_filter.h (ap_add_output_filter, ap_add_output_filter_handle): Document new API guarantee. * include/ap_mmn.h: Minor MMN bump. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@600473 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/ap_mmn.h b/include/ap_mmn.h index d98cc2993b3..6238a84c41d 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -141,6 +141,8 @@ * public scoreboard API. * 20071108.1 (2.3.0-dev) Add the optional kept_body brigade to request_rec * 20071108.2 (2.3.0-dev) Add st and keep fields to struct util_ldap_connection_t + * 20071108.3 (2.3.0-dev) Add API guarantee for adding connection filters + * with non-NULL request_rec pointer (ap_add_*_filter*) */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ @@ -148,7 +150,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20071108 #endif -#define MODULE_MAGIC_NUMBER_MINOR 2 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 3 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/util_filter.h b/include/util_filter.h index c17ae41c487..2355c251922 100644 --- a/include/util_filter.h +++ b/include/util_filter.h @@ -411,6 +411,10 @@ AP_DECLARE(ap_filter_rec_t *) ap_get_input_filter_handle(const char *name); * @param ctx Context data to set in the filter * @param r The request to add this filter for (or NULL if it isn't associated with a request) * @param c The connection to add this filter for + * @note If adding a connection-level output filter (i.e. where the type + * is >= AP_FTYPE_CONNECTION) during processing of a request, the request + * object r must be passed in to ensure the filter chains are modified + * correctly. f->r will still be initialized as NULL in the new filter. */ AP_DECLARE(ap_filter_t *) ap_add_output_filter(const char *name, void *ctx, request_rec *r, conn_rec *c); @@ -421,7 +425,11 @@ AP_DECLARE(ap_filter_t *) ap_add_output_filter(const char *name, void *ctx, * * @param f The filter handle to add * @param r The request to add this filter for (or NULL if it isn't associated with a request) - * @param c The connection to add the fillter for + * @param c The connection to add the filter for + * @note If adding a connection-level output filter (i.e. where the type + * is >= AP_FTYPE_CONNECTION) during processing of a request, the request + * object r must be passed in to ensure the filter chains are modified + * correctly. f->r will still be initialized as NULL in the new filter. */ AP_DECLARE(ap_filter_t *) ap_add_output_filter_handle(ap_filter_rec_t *f, void *ctx, diff --git a/server/util_filter.c b/server/util_filter.c index 636b601d9fa..f2e5b5d2999 100644 --- a/server/util_filter.c +++ b/server/util_filter.c @@ -279,7 +279,7 @@ static ap_filter_t *add_any_filter_handle(ap_filter_rec_t *frec, void *ctx, ap_filter_t **p_filters, ap_filter_t **c_filters) { - apr_pool_t* p = frec->ftype < AP_FTYPE_CONNECTION && r ? r->pool : c->pool; + apr_pool_t *p = frec->ftype < AP_FTYPE_CONNECTION && r ? r->pool : c->pool; ap_filter_t *f = apr_palloc(p, sizeof(*f)); ap_filter_t **outf; @@ -309,7 +309,8 @@ static ap_filter_t *add_any_filter_handle(ap_filter_rec_t *frec, void *ctx, f->frec = frec; f->ctx = ctx; - f->r = r; + /* f->r must always be NULL for connection filters */ + f->r = frec->ftype < AP_FTYPE_CONNECTION ? r : NULL; f->c = c; f->next = NULL;