Author: joes
Date: Fri Jan 9 23:05:21 2009
New Revision: 733236
URL: http://svn.apache.org/viewvc?rev=733236&view=rev
Log:
clean up buggy apreq_hook_find_param().
Modified:
httpd/apreq/trunk/CHANGES
httpd/apreq/trunk/include/apreq_parser.h
httpd/apreq/trunk/include/apreq_version.h
httpd/apreq/trunk/library/module_cgi.c
httpd/apreq/trunk/library/parser.c
httpd/apreq/trunk/module/apache2/apreq_module_apache2.h
httpd/apreq/trunk/module/apache2/handle.c
Modified: httpd/apreq/trunk/CHANGES
URL:
http://svn.apache.org/viewvc/httpd/apreq/trunk/CHANGES?rev=733236&r1=733235&r2=733236&view=diff
==============================================================================
--- httpd/apreq/trunk/CHANGES (original)
+++ httpd/apreq/trunk/CHANGES Fri Jan 9 23:05:21 2009
@@ -4,6 +4,8 @@
@section v2_10 Changes with libapreq2-2.10 (under developement)
+- Clean up buggy apreq_hook_find_param().
+
- Perl Glue Build [Philip M. Gollucci]
config.status format changed format yet again in autoconf 2.62+.
Modified: httpd/apreq/trunk/include/apreq_parser.h
URL:
http://svn.apache.org/viewvc/httpd/apreq/trunk/include/apreq_parser.h?rev=733236&r1=733235&r2=733236&view=diff
==============================================================================
--- httpd/apreq/trunk/include/apreq_parser.h (original)
+++ httpd/apreq/trunk/include/apreq_parser.h Fri Jan 9 23:05:21 2009
@@ -267,15 +267,28 @@
APREQ_DECLARE_HOOK(apreq_hook_discard_brigade);
/**
+ * Context struct for the apreq_hook_find_param hook.
+ */
+typedef struct apreq_hook_find_param_ctx_t {
+ const char *name;
+ apreq_param_t *param;
+ apreq_hook_t **prev;
+} apreq_hook_find_param_ctx_t;
+
+
+/**
* Special purpose utility for locating a parameter
* during parsing. The hook's ctx shoud be initialized
- * to a const char *, which is a pointer to the desired
- * param name. The hook's ctx will be reassigned to the
- * first param found.
+ * to an apreq_hook_find_param_ctx_t *, with the name
+ * attribute set to the sought parameter name, the param
+ * attribute set to NULL, and the prev attribute set to
+ * the address of the previous hook. The param attribute
+ * will be reassigned to the first param found, and once
+ * that happens this hook is immediately removed from the chain.
*
* @remarks When used, this should always be the first hook
- * invoked, so add it manually as parser->hook instead of
- * using apreq_parser_add_hook.
+ * invoked, so add it manually with ctx->prev = &parser->hook
+ * instead of using apreq_parser_add_hook.
*/
APREQ_DECLARE_HOOK(apreq_hook_find_param);
Modified: httpd/apreq/trunk/include/apreq_version.h
URL:
http://svn.apache.org/viewvc/httpd/apreq/trunk/include/apreq_version.h?rev=733236&r1=733235&r2=733236&view=diff
==============================================================================
--- httpd/apreq/trunk/include/apreq_version.h (original)
+++ httpd/apreq/trunk/include/apreq_version.h Fri Jan 9 23:05:21 2009
@@ -59,10 +59,10 @@
* Minor API changes that do not cause binary compatibility problems.
* Should be reset to 0 when upgrading APREQ_MAJOR_VERSION
*/
-#define APREQ_MINOR_VERSION 6
+#define APREQ_MINOR_VERSION 7
/** patch level */
-#define APREQ_PATCH_VERSION 4
+#define APREQ_PATCH_VERSION 0
/**
* This symbol is defined for internal, "development" copies of libapreq.
Modified: httpd/apreq/trunk/library/module_cgi.c
URL:
http://svn.apache.org/viewvc/httpd/apreq/trunk/library/module_cgi.c?rev=733236&r1=733235&r2=733236&view=diff
==============================================================================
--- httpd/apreq/trunk/library/module_cgi.c (original)
+++ httpd/apreq/trunk/library/module_cgi.c Fri Jan 9 23:05:21 2009
@@ -439,6 +439,7 @@
struct cgi_handle *req = (struct cgi_handle *)handle;
const char *val;
apreq_hook_t *h;
+ apreq_hook_find_param_ctx_t *hook_ctx;
switch (req->body_status) {
@@ -467,6 +468,8 @@
/* Not seen yet, so we need to scan for
param while prefetching the body */
+ hook_ctx = apr_palloc(handle->pool, sizeof *hook_ctx);
+
if (req->find_param == NULL)
req->find_param = apreq_hook_make(handle->pool,
apreq_hook_find_param,
@@ -474,14 +477,15 @@
h = req->find_param;
h->next = req->parser->hook;
req->parser->hook = h;
- h->ctx = &name;
+ h->ctx = hook_ctx;
+ hook_ctx->name = name;
+ hook_ctx->param = NULL;
+ hook_ctx->prev = &req->parser->hook;
do {
cgi_read(handle, APREQ_DEFAULT_READ_BLOCK_SIZE);
- if (h->ctx != &name) {
- req->parser->hook = h->next;
- return h->ctx;
- }
+ if (hook_ctx->param != NULL)
+ return hook_ctx->param;
} while (req->body_status == APR_INCOMPLETE);
req->parser->hook = h->next;
@@ -651,7 +655,7 @@
}
#endif
-static APREQ_MODULE(cgi, 20050425);
+static APREQ_MODULE(cgi, 20090110);
APREQ_DECLARE(apreq_handle_t *)apreq_handle_cgi(apr_pool_t *pool)
{
Modified: httpd/apreq/trunk/library/parser.c
URL:
http://svn.apache.org/viewvc/httpd/apreq/trunk/library/parser.c?rev=733236&r1=733235&r2=733236&view=diff
==============================================================================
--- httpd/apreq/trunk/library/parser.c (original)
+++ httpd/apreq/trunk/library/parser.c Fri Jan 9 23:05:21 2009
@@ -339,15 +339,17 @@
return APR_SUCCESS;
}
+
APREQ_DECLARE_HOOK(apreq_hook_find_param)
{
- const char *key = *(const char **)hook->ctx;
+ apreq_hook_find_param_ctx_t *ctx = hook->ctx;
int is_final = (bb == NULL) || APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb));
apr_status_t s = (hook->next == NULL)
? APR_SUCCESS : apreq_hook_run(hook->next, param, bb);
- if (is_final && strcasecmp(key, param->v.name) == 0)
- hook->ctx = param;
-
+ if (is_final && strcasecmp(ctx->name, param->v.name) == 0) {
+ ctx->param = param;
+ ctx->prev[0]->next = hook->next;
+ }
return s;
}
Modified: httpd/apreq/trunk/module/apache2/apreq_module_apache2.h
URL:
http://svn.apache.org/viewvc/httpd/apreq/trunk/module/apache2/apreq_module_apache2.h?rev=733236&r1=733235&r2=733236&view=diff
==============================================================================
--- httpd/apreq/trunk/module/apache2/apreq_module_apache2.h (original)
+++ httpd/apreq/trunk/module/apache2/apreq_module_apache2.h Fri Jan 9 23:05:21
2009
@@ -158,7 +158,7 @@
* using this apache2 module
* @see APREQ_MODULE
*/
-#define APREQ_APACHE2_MMN 20051231
+#define APREQ_APACHE2_MMN 20090110
/** @} */
Modified: httpd/apreq/trunk/module/apache2/handle.c
URL:
http://svn.apache.org/viewvc/httpd/apreq/trunk/module/apache2/handle.c?rev=733236&r1=733235&r2=733236&view=diff
==============================================================================
--- httpd/apreq/trunk/module/apache2/handle.c (original)
+++ httpd/apreq/trunk/module/apache2/handle.c Fri Jan 9 23:05:21 2009
@@ -167,6 +167,7 @@
struct filter_ctx *ctx;
const char *val;
apreq_hook_t *h;
+ apreq_hook_find_param_ctx_t *hook_ctx;
if (f->ctx == NULL)
apreq_filter_make_context(f);
@@ -199,6 +200,7 @@
/* Not seen yet, so we need to scan for
param while prefetching the body */
+ hook_ctx = apr_palloc(handle->pool, sizeof *hook_ctx);
if (ctx->find_param == NULL)
ctx->find_param = apreq_hook_make(handle->pool,
@@ -206,15 +208,17 @@
NULL, NULL);
h = ctx->find_param;
h->next = ctx->parser->hook;
+ h->ctx = hook_ctx;
ctx->parser->hook = h;
- h->ctx = &name;
+ h->ctx = hook_ctx;
+ hook_ctx->name = name;
+ hook_ctx->param = NULL;
+ hook_ctx->prev = &ctx->parser->hook;
do {
apreq_filter_prefetch(f, APREQ_DEFAULT_READ_BLOCK_SIZE);
- if (h->ctx != &name) {
- ctx->parser->hook = h->next;
- return h->ctx;
- }
+ if (hook_ctx->param != NULL)
+ return hook_ctx->param;
} while (ctx->body_status == APR_INCOMPLETE);
ctx->parser->hook = h->next;