You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-cvs@httpd.apache.org by jo...@apache.org on 2003/10/23 12:51:03 UTC
cvs commit: httpd-apreq-2/env/c-modules/apreq_access_test mod_apreq_access_test.c
joes 2003/10/23 03:51:03
Modified: env mod_apreq.c
env/c-modules/apreq_access_test mod_apreq_access_test.c
Log:
Track saw_eos condition to prevent extraneous calls to ap_get_brigade, which leads to problems caused by having multiple EOS buckets appear in the resulting brigades.
Revision Changes Path
1.30 +33 -26 httpd-apreq-2/env/mod_apreq.c
Index: mod_apreq.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/env/mod_apreq.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- mod_apreq.c 14 Oct 2003 18:53:30 -0000 1.29
+++ mod_apreq.c 23 Oct 2003 10:51:03 -0000 1.30
@@ -97,6 +97,7 @@
apr_bucket_brigade *bb;
apr_bucket_brigade *spool;
apr_status_t status;
+ unsigned saw_eos;
};
static const char filter_name[] = "APREQ";
@@ -226,11 +227,11 @@
request_rec *r = f->r;
apr_bucket_alloc_t *alloc = apr_bucket_alloc_create(r->pool);
struct filter_ctx *ctx = apr_palloc(r->pool, sizeof *ctx);
- f->ctx = ctx;
- ctx->bb = apr_brigade_create(r->pool, alloc);
- ctx->spool = apr_brigade_create(r->pool, alloc);
- ctx->status = APR_INCOMPLETE;
-
+ f->ctx = ctx;
+ ctx->bb = apr_brigade_create(r->pool, alloc);
+ ctx->spool = apr_brigade_create(r->pool, alloc);
+ ctx->status = APR_INCOMPLETE;
+ ctx->saw_eos = 0;
apreq_log(APREQ_DEBUG 0, r,
"apreq filter context created." );
}
@@ -309,8 +310,10 @@
*/
apreq_log(APREQ_DEBUG 0, r, "dropping stale apreq filter (%d)", f);
- req->parser = NULL;
- req->body = NULL;
+ if (req) {
+ req->parser = NULL;
+ req->body = NULL;
+ }
if (cfg->f == f) {
ctx->status = APR_SUCCESS;
cfg->f = NULL;
@@ -326,10 +329,11 @@
else {
apr_bucket_alloc_t *alloc = apr_bucket_alloc_create(r->pool);
ctx = apr_palloc(r->pool, sizeof *ctx);
- f->ctx = ctx;
- ctx->bb = apr_brigade_create(r->pool, alloc);
- ctx->spool = apr_brigade_create(r->pool, alloc);
- ctx->status = APR_INCOMPLETE;
+ f->ctx = ctx;
+ ctx->bb = apr_brigade_create(r->pool, alloc);
+ ctx->spool = apr_brigade_create(r->pool, alloc);
+ ctx->status = APR_INCOMPLETE;
+ ctx->saw_eos = 0;
apreq_log(APREQ_DEBUG 0, r,
"apreq filter is initialized (%d)", f);
}
@@ -362,19 +366,21 @@
default:
return APR_ENOTIMPL;
}
- apreq_log(APREQ_DEBUG ctx->status, r, "entering filter (%d)",
- r->input_filters == f);
+
req = apreq_request(r, NULL);
if (bb != NULL) {
- apr_bucket_brigade *tmp;
- rv = ap_get_brigade(f->next, bb, mode, block, readbytes);
- if (rv != APR_SUCCESS) {
- apreq_log(APREQ_ERROR rv, r, "get_brigade failed");
- return rv;
+ if (!ctx->saw_eos) {
+ apr_bucket_brigade *tmp;
+ rv = ap_get_brigade(f->next, bb, mode, block, readbytes);
+
+ if (rv != APR_SUCCESS) {
+ apreq_log(APREQ_ERROR rv, r, "get_brigade failed");
+ return rv;
+ }
+ tmp = apreq_copy_brigade(bb);
+ APR_BRIGADE_CONCAT(ctx->bb, tmp);
}
- tmp = apreq_copy_brigade(bb);
- APR_BRIGADE_CONCAT(ctx->bb, tmp);
if (!APR_BRIGADE_EMPTY(ctx->spool)) {
APR_BRIGADE_PREPEND(bb, ctx->spool);
@@ -388,21 +394,19 @@
if (APR_BUCKET_IS_EOS(e))
e = APR_BUCKET_NEXT(e);
ctx->spool = apr_brigade_split(bb, e);
- apreq_log(APREQ_DEBUG rv,r, "returning %d bytes from spool",
- readbytes);
}
}
if (ctx->status != APR_INCOMPLETE) {
if (APR_BRIGADE_EMPTY(ctx->spool)) {
- ap_remove_input_filter(f);
apreq_log(APREQ_DEBUG ctx->status,r,"removing filter(%d)",
r->input_filters == f);
+ ap_remove_input_filter(f);
}
return ctx->status;
}
}
- else {
+ else if (!ctx->saw_eos) {
/* prefetch read! */
apr_bucket_brigade *tmp = apr_brigade_create(r->pool,
apr_bucket_alloc_create(r->pool));
@@ -423,9 +427,12 @@
last = APR_BRIGADE_LAST(ctx->spool);
}
}
+ else
+ return ctx->status;
+
+ if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(ctx->bb)))
+ ctx->saw_eos = 1;
ctx->status = apreq_parse_request(req, ctx->bb);
- apreq_log(APREQ_DEBUG ctx->status, r, "leaving filter (%d)",
- r->input_filters == f);
return (ctx->status == APR_INCOMPLETE) ? APR_SUCCESS : ctx->status;
}
1.5 +2 -1 httpd-apreq-2/env/c-modules/apreq_access_test/mod_apreq_access_test.c
Index: mod_apreq_access_test.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/env/c-modules/apreq_access_test/mod_apreq_access_test.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- mod_apreq_access_test.c 1 Oct 2003 20:00:36 -0000 1.4
+++ mod_apreq_access_test.c 23 Oct 2003 10:51:03 -0000 1.5
@@ -101,7 +101,7 @@
static int apreq_access_checker(request_rec *r)
{
- apreq_request_t *req = apreq_request(r, NULL);
+ apreq_request_t *req;
apreq_param_t *param;
struct access_test_cfg *cfg = (struct access_test_cfg *)
ap_get_module_config(r->per_dir_config, &apreq_access_test_module);
@@ -109,6 +109,7 @@
if (!cfg || !cfg->param)
return DECLINED;
+ req = apreq_request(r, NULL);
param = apreq_param(req, cfg->param);
if (param) {
apreq_log(APREQ_DEBUG 0, r, "%s => %s", cfg->param, param->v.data);