Author: joes
Date: Tue Mar 15 07:37:32 2005
New Revision: 157552
URL: http://svn.apache.org/viewcvs?view=rev&rev=157552
Log:
Resync cgi_body_get with apache2_body_get,
mimicing the changes in r157544 and r157551.
This patch ensures worst-case O(n) behavior
for cgi as well.
Modified:
httpd/apreq/branches/multi-env-unstable/library/module_cgi.c
Modified: httpd/apreq/branches/multi-env-unstable/library/module_cgi.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/library/module_cgi.c?view=diff&r1=157551&r2=157552
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/library/module_cgi.c (original)
+++ httpd/apreq/branches/multi-env-unstable/library/module_cgi.c Tue Mar 15
07:37:32 2005
@@ -54,6 +54,7 @@
apreq_parser_t *parser;
apreq_hook_t *hook_queue;
+ apreq_hook_t *find_param;
const char *temp_dir;
apr_size_t brigade_limit;
@@ -456,9 +457,18 @@
{
struct cgi_handle *handle = (struct cgi_handle *)env;
const char *val;
+ apreq_hook_t *h;
switch (handle->body_status) {
+ case APR_SUCCESS:
+
+ val = apr_table_get(handle->body, name);
+ if (val != NULL)
+ return apreq_value_to_param(val);
+ return NULL;
+
+
case APR_EINIT:
init_body(env);
@@ -466,35 +476,49 @@
return NULL;
cgi_read(env, APREQ_DEFAULT_READ_BLOCK_SIZE);
+
case APR_INCOMPLETE:
val = apr_table_get(handle->body, name);
if (val != NULL)
return apreq_value_to_param(val);
- do {
- /* riff on Duff's device */
- cgi_read(env, APREQ_DEFAULT_READ_BLOCK_SIZE);
-
- case APR_SUCCESS:
+ /* Not seen yet, so we need to scan for
+ param while prefetching the body */
- val = apr_table_get(handle->body, name);
- if (val != NULL)
- return apreq_value_to_param(val);
+ if (handle->find_param == NULL)
+ handle->find_param = apreq_hook_make(handle->pool,
+ apreq_hook_find_param,
+ NULL, NULL);
+ h = handle->find_param;
+ h->next = handle->parser->hook;
+ handle->parser->hook = h;
+ *(const char **)&h->ctx = name;
+ do {
+ cgi_read(env, APREQ_DEFAULT_READ_BLOCK_SIZE);
+ if (h->ctx != name) {
+ handle->parser->hook = h->next;
+ return h->ctx;
+ }
} while (handle->body_status == APR_INCOMPLETE);
- break;
+ handle->parser->hook = h->next;
+ return NULL;
+
default:
- if (handle->body != NULL) {
- val = apr_table_get(handle->body, name);
- if (val != NULL)
- return apreq_value_to_param(val);
- }
+ if (handle->body == NULL)
+ return NULL;
+
+ val = apr_table_get(handle->body, name);
+ if (val != NULL)
+ return apreq_value_to_param(val);
+ return NULL;
}
+ /* not reached */
return NULL;
}