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/06/30 22:42:15 UTC
cvs commit: httpd-apreq-2/src apreq.c apreq.h apreq_env.h apreq_params.c apreq_params.h
joes 2003/06/30 13:42:15
Modified: . Makefile.am
build test_config.pl
env Makefile.am mod_apreq.c
env/t TEST.PL
glue/perl/xsbuilder/maps apreq_functions.map
src apreq.c apreq.h apreq_env.h apreq_params.c
apreq_params.h
Log:
Phase out test_config.pl script. Rework prefetch code in mod_apreq.c and move apreq_brigade_copy function from apreq_params.c to apreq.c
Revision Changes Path
1.11 +9 -0 httpd-apreq-2/Makefile.am
Index: Makefile.am
===================================================================
RCS file: /home/cvs/httpd-apreq-2/Makefile.am,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Makefile.am 28 Jun 2003 22:25:07 -0000 1.10
+++ Makefile.am 30 Jun 2003 20:42:14 -0000 1.11
@@ -5,9 +5,18 @@
APRDIR=`@APR_CONFIG@ --srcdir`
APUDOX = (cd $(APUDIR); cat - docs/doxygen.conf | doxygen -)
APRDOX = (cd $(APRDIR); cat - docs/doxygen.conf | doxygen -)
+COOKIE_POD=glue/perl/blib/lib/Apache/Cookie.pod
+REQUEST_POD=glue/perl/blib/lib/Apache/Request.pod
docs: src env glue build/doxygen.conf
doxygen build/doxygen.conf
+
+pod2html: Request.html Cookie.html
+
+Cookie.html: Makefile.am $(COOKIE_POD)
+ pod2html <$(COOKIE_POD) | perl -0777 -pe 's(^[\S\s]+<body.+|</body>[\S\s]+$$)()gi' > Cookie.html
+Request.html: Makefile.am $(REQUEST_POD)
+ pod2html <$(REQUEST_POD)| perl -0777 -pe 's(^[\S\s]+<body.+|</body>[\S\s]+$$)()gi' > Request.html
apr_tags:
-mkdir docs
1.5 +6 -8 httpd-apreq-2/build/test_config.pl
Index: test_config.pl
===================================================================
RCS file: /home/cvs/httpd-apreq-2/build/test_config.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- test_config.pl 16 Jun 2003 09:37:45 -0000 1.4
+++ test_config.pl 30 Jun 2003 20:42:14 -0000 1.5
@@ -11,11 +11,15 @@
use File::Find qw(finddepth);
use Apache::TestTrace;
-
use Apache::Test;
use Apache::TestConfigC;
-use base qw/Apache::TestConfig/;
+use base 'Apache::TestConfig';
+Apache::TestMM::filter_args();
+Apache::TestMM::generate_script("t/TEST");
+__END__
+bless my $cfg = Apache::Test->config();
+$cfg->cmodules_configure;
sub cmodules_write_makefile {
my($self, $mod) = @_;
@@ -44,10 +48,4 @@
close $fh or die "close $makefile: $!";
}
-Apache::TestMM::filter_args();
-Apache::TestMM::generate_script("t/TEST");
-
-$Apache::TestTrace::Level = 'debug';
-bless my $cfg = Apache::Test->config();
-$cfg->cmodules_configure;
1.10 +5 -9 httpd-apreq-2/env/Makefile.am
Index: Makefile.am
===================================================================
RCS file: /home/cvs/httpd-apreq-2/env/Makefile.am,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Makefile.am 11 Jun 2003 23:02:32 -0000 1.9
+++ Makefile.am 30 Jun 2003 20:42:14 -0000 1.10
@@ -1,7 +1,6 @@
INCLUDES = -I../src -I@APACHE2_INCLUDES@
-TEST_VERBOSITY_LEVEL = 0
-TEST_CONFIG_SCRIPT = ../build/test_config.pl
+TEST_CONFIG_SCRIPT = package Apache::TestMM; filter_args(); generate_script("t/TEST")
lib_LIBRARIES = libapreq_cgi.a
noinst_LTLIBRARIES = mod_apreq.la
@@ -19,20 +18,17 @@
install-exec-local: mod_apreq.la
@APACHE2_APXS@ -i -a -n apreq mod_apreq.la
-t/TEST test_config : Makefile $(TEST_CONFIG_SCRIPT)
- @PERL@ $(TEST_CONFIG_SCRIPT) -apxs @APACHE2_APXS@
+t/TEST : Makefile.am
+ @PERL@ -MApache::TestMM -e '$(TEST_CONFIG_SCRIPT)' -- -apxs @APACHE2_APXS@
-run_tests : cmodules
- @PERL@ t/TEST -verbose=$(TEST_VERBOSITY_LEVEL) $(TEST_FILES)
+run_tests : t/TEST
+ @PERL@ t/TEST
test :: all run_tests
test_clean : cmodules_clean
-@PERL@ t/TEST -clean
-rm -rf t/conf t/htdocs t/logs t/modules t/TEST
-
-cmodules: test_config
- cd c-modules && $(MAKE) all
cmodules_clean:
-cd c-modules && $(MAKE) clean
1.18 +68 -106 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.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- mod_apreq.c 27 Jun 2003 18:23:18 -0000 1.17
+++ mod_apreq.c 30 Jun 2003 20:42:14 -0000 1.18
@@ -92,7 +92,9 @@
/** Tracks the filter state */
struct filter_ctx {
apr_bucket_brigade *bb;
+ apr_bucket_brigade *spool;
apr_off_t bytes_seen;
+ ap_input_mode_t mode;
apr_status_t status;
};
@@ -210,7 +212,7 @@
/**
* Reads data directly into the parser.
*@bug This function is badly broken. It needs to use
- * SPECULATIVE mode when doing readsin pre-content-handler
+ * SPECULATIVE mode when doing reads in pre-content-handler
* phase, but should use a normal (READBYTES) read otherwise.
*/
@@ -220,10 +222,13 @@
{
dR;
ap_filter_t *f = get_apreq_filter(r);
+ struct filter_ctx *ctx;
+
if (f == NULL)
return APR_NOTFOUND;
+ ctx = f->ctx;
- return ap_get_brigade(f, NULL, AP_MODE_SPECULATIVE, block, bytes);
+ return ap_get_brigade(f, NULL, ctx->mode, block, bytes);
}
APR_INLINE
@@ -234,8 +239,10 @@
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->bytes_seen = 0;
ctx->status = APR_INCOMPLETE;
+ ctx->mode = AP_MODE_SPECULATIVE;
apreq_log(APREQ_DEBUG 0, r,
"apreq filter context created." );
@@ -289,8 +296,7 @@
req->parser = NULL;
req->body = NULL;
-
- ctx->bytes_seen = 0;
+ apr_brigade_cleanup(ctx->spool);
apr_brigade_cleanup(ctx->bb);
ctx->status = APR_INCOMPLETE;
}
@@ -300,18 +306,19 @@
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->bytes_seen = 0;
ctx->status = APR_INCOMPLETE;
-
apreq_log(APREQ_DEBUG 0, r,
"apreq filter is initialized" );
}
-
+
+ ctx->bytes_seen = 0;
+ ctx->mode = AP_MODE_READBYTES;
return APR_SUCCESS;
}
-
static apr_status_t apreq_filter(ap_filter_t *f,
apr_bucket_brigade *bb,
ap_input_mode_t mode,
@@ -332,122 +339,77 @@
switch (ctx->status) {
case APR_INCOMPLETE:
break;
- case APR_EOF:
- return APR_EOF;
-
case APR_SUCCESS:
+ if (bb != NULL)
+ return ap_get_brigade(f->next, bb, mode, block, readbytes);
+ case APR_EOF:
default:
- return ap_get_brigade(f->next, bb, mode, block, readbytes);
+ return APR_EOF;
}
- switch (mode) {
-
- case AP_MODE_SPECULATIVE:
- if (bb == NULL) {
-
- /* prefetch read! */
-
- apr_off_t skip_bytes = ctx->bytes_seen;
-
- bb = ctx->bb;
- e = APR_BRIGADE_LAST(bb);
- rv = ap_get_brigade(f->next, bb, mode, block,
- readbytes + skip_bytes);
- if (rv != APR_SUCCESS)
- return rv;
- e = APR_BUCKET_NEXT(e);
-
- /* throw away buckets we've already seen */
+ if (bb != NULL) {
+ rv = ap_get_brigade(f->next, bb, mode, block, readbytes);
- while (skip_bytes > 0 && e != APR_BRIGADE_SENTINEL(bb)) {
- apr_bucket *f = e;
- apr_size_t len;
- const char *dummy;
-
- if (APR_BUCKET_IS_EOS(e)) {
- ctx->status = APR_EOF;
- break;
- }
- rv = apr_bucket_read(e, &dummy, &len, APR_BLOCK_READ);
- if (rv != APR_SUCCESS)
- return rv;
-
- if (skip_bytes < len) {
- apr_bucket_split(e, skip_bytes);
- len = skip_bytes;
- }
- e = APR_BUCKET_NEXT(e);
- apr_bucket_delete(f);
- skip_bytes -= len;
- }
+ switch (mode) {
+ apr_bucket_brigade *tmp;
- /* add the new buckets to the ctx->bytes_seen count */
+ case AP_MODE_SPECULATIVE:
+ return rv;
- while (e != APR_BRIGADE_SENTINEL(bb)) {
- apr_bucket *f = e;
- apr_size_t len;
- const char *dummy;
-
- if (APR_BUCKET_IS_EOS(e)) {
- ctx->status = APR_EOF;
- break;
+ case AP_MODE_EXHAUSTIVE:
+ case AP_MODE_READBYTES:
+ tmp = apreq_copy_brigade(bb);
+ APR_BRIGADE_CONCAT(ctx->bb, tmp);
+
+ if (!APR_BRIGADE_EMPTY(ctx->spool)) {
+ APR_BRIGADE_PREPEND(bb, ctx->spool);
+ if (mode == AP_MODE_READBYTES) {
+ rv = apr_brigade_partition(bb, readbytes, &e);
+ if (rv != APR_SUCCESS)
+ return rv;
+ ctx->spool = apr_brigade_split(bb, e);
}
- rv = apr_bucket_read(e, &dummy, &len, APR_BLOCK_READ);
- if (rv != APR_SUCCESS)
- return rv;
-
- ctx->bytes_seen += len;
}
+ break;
+ case AP_MODE_EATCRLF:
+ case AP_MODE_GETLINE:
+ default:
+ return APR_ENOTIMPL;
}
- else {
- /* not a prefetch read; can simply get out of the way */
- return ap_get_brigade(f->next, bb, mode, block, readbytes);
- }
- break;
-
- case AP_MODE_EXHAUSTIVE:
- case AP_MODE_READBYTES:
- e = APR_BRIGADE_LAST(bb);
+ }
+ else {
+ /* prefetch read! */
+ apr_bucket_brigade *tmp = apr_brigade_create(r->pool,
+ apr_bucket_alloc_create(r->pool));
+
+ rv = ap_get_brigade(f->next, tmp, mode, block,
+ readbytes + ctx->bytes_seen);
+ if (rv != APR_SUCCESS)
+ return rv;
- rv = ap_get_brigade(f->next, bb, mode, block, readbytes);
+ if (mode == AP_MODE_SPECULATIVE) {
+ apr_off_t len;
+ /* throw away buckets we've already seen */
+ rv = apr_brigade_partition(tmp, ctx->bytes_seen, &e);
if (rv != APR_SUCCESS)
return rv;
- for (e = APR_BUCKET_NEXT(e);
- e != APR_BRIGADE_SENTINEL(bb);
- e = APR_BUCKET_NEXT(e))
- {
- apr_bucket *b;
-
- if (ctx->bytes_seen) {
- const char *dummy;
- apr_size_t len;
- rv = apr_bucket_read(e, &dummy, &len, APR_BLOCK_READ);
- if (rv != APR_SUCCESS)
- return rv;
- if (ctx->bytes_seen < len) {
- apr_bucket_split(e, ctx->bytes_seen);
- len = ctx->bytes_seen;
- }
- ctx->bytes_seen -= len;
- continue;
- }
+ bb = apr_brigade_split(tmp,e);
+ apr_brigade_destroy(tmp);
- apr_bucket_copy(e, &b);
- apr_bucket_setaside(b, r->pool);
- APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
-
- if (APR_BUCKET_IS_EOS(e)) {
- ctx->status = APR_EOF;
- break;
- }
+ rv = apr_brigade_length(bb, 1, &len);
+ if (rv != APR_SUCCESS)
+ return rv;
+
+ ctx->bytes_seen += len;
+ }
+ else {
+ /* append a copy of the brigade to the spool */
+ bb = apreq_copy_brigade(tmp);
+ APR_BRIGADE_CONCAT(ctx->spool, tmp);
}
- break;
- case AP_MODE_EATCRLF:
- case AP_MODE_GETLINE:
- default:
- return APR_ENOTIMPL;
+ APR_BRIGADE_CONCAT(ctx->bb, bb);
}
rv = apreq_parse_request(apreq_request(r, NULL), ctx->bb);
1.2 +41 -1 httpd-apreq-2/env/t/TEST.PL
Index: TEST.PL
===================================================================
RCS file: /home/cvs/httpd-apreq-2/env/t/TEST.PL,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TEST.PL 16 Jun 2003 09:37:45 -0000 1.1
+++ TEST.PL 30 Jun 2003 20:42:14 -0000 1.2
@@ -15,7 +15,7 @@
"$base_dir/win32/libs" : "$env_dir/.libs";
use base 'Apache::TestRun';
-
+$Apache::TestTrace::Level = 'debug';
main::->new->run(@ARGV);
sub configure {
@@ -23,5 +23,45 @@
my $cfg = $self->{test_config};
$cfg->preamble(IfModule => '!mod_apreq.c',
qq(LoadModule apreq_module "$env_dir_libs/mod_apreq.so"\n));
+ bless $cfg, "My::TestConfig";
$self->SUPER::configure();
+}
+
+
+
+package My::TestConfig;
+use Apache::TestTrace;
+use Apache::TestConfigC;
+
+use base 'Apache::TestConfig';
+
+sub cmodules_httpd_conf {
+ my $self = shift;
+ debug "WRITING httpd.conf with " . join", ",map $_->{name},
+ @{$self->{cmodules}};
+ $self->SUPER::cmodules_httpd_conf(@_);
+}
+sub cmodules_write_makefile {
+ my($self, $mod) = @_;
+ my $dversion = $self->server->dversion;
+ my $name = $mod->{name};
+ my $makefile = "$mod->{dir}/Makefile";
+ debug "WRITING $makefile for $name";
+ my $lib = $self->cmodules_build_so($name);
+
+ my $fh = Symbol::gensym();
+ open $fh, ">$makefile" or die "open $makefile: $!";
+
+ print $fh <<EOF;
+APXS=$self->{APXS}
+all: $lib
+
+$lib: $name.c
+ \$(APXS) -L../../../src -I../../../src -lapreq $dversion -I$self->{cmodules_dir} -c $name.c
+
+clean:
+ -rm -rf $name.o $name.lo $name.slo $name.la .libs
+EOF
+
+ close $fh or die "close $makefile: $!";
}
1.12 +1 -1 httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_functions.map
Index: apreq_functions.map
===================================================================
RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_functions.map,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- apreq_functions.map 29 Jun 2003 03:41:17 -0000 1.11
+++ apreq_functions.map 30 Jun 2003 20:42:14 -0000 1.12
@@ -22,7 +22,7 @@
########## Apache::Upload:: Functions ##########
MODULE=Apache::Request PACKAGE=Apache::Upload PREFIX=Apache__Upload_
- apr_bucket_brigade *:DEFINE_bb | apreq_param_brigade(apreq_xs_rv2param(sv)) | SV *:sv
+ apr_bucket_brigade *:DEFINE_bb | apreq_copy_brigade(apreq_xs_rv2param(sv)->bb) | SV *:sv
apr_table_t *:DEFINE_info | apreq_param_info(apreq_xs_rv2param(sv)) | SV *:sv
const char *:DEFINE_name | apreq_param_name(apreq_xs_rv2param(sv)) | SV *:sv
char *:DEFINE_filename | apreq_param_value(apreq_xs_rv2param(sv)) | SV *:sv
1.24 +15 -0 httpd-apreq-2/src/apreq.c
Index: apreq.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/src/apreq.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- apreq.c 28 Jun 2003 17:51:38 -0000 1.23
+++ apreq.c 30 Jun 2003 20:42:14 -0000 1.24
@@ -735,3 +735,18 @@
else
return NULL;
}
+
+APREQ_DECLARE(apr_bucket_brigade *)
+ apreq_copy_brigade(const apr_bucket_brigade *bb)
+{
+ apr_bucket_brigade *copy;
+ apr_bucket *e;
+
+ copy = apr_brigade_create(bb->p, bb->bucket_alloc);
+ APR_BRIGADE_FOREACH(e,bb) {
+ apr_bucket *c;
+ apr_bucket_copy(e, &c);
+ APR_BRIGADE_INSERT_TAIL(copy, c);
+ }
+ return copy;
+}
1.31 +32 -2 httpd-apreq-2/src/apreq.h
Index: apreq.h
===================================================================
RCS file: /home/cvs/httpd-apreq-2/src/apreq.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- apreq.h 28 Jun 2003 22:25:07 -0000 1.30
+++ apreq.h 30 Jun 2003 20:42:14 -0000 1.31
@@ -87,8 +87,34 @@
* @verbinclude INSTALL
*/
/**
- * @page CHANGES
- * @verbinclude CHANGES
+ * @defgroup XS Perl
+ * @ingroup GLUE
+ */
+/**
+ * @defgroup TCL TCL
+ * @ingroup GLUE
+ */
+/**
+ * @defgroup PYTHON Python
+ * @ingroup GLUE
+ */
+/**
+ * @defgroup PHP PHP
+ * @ingroup GLUE
+ */
+/**
+ * @defgroup RUBY Ruby
+ * @ingroup GLUE
+ */
+/**
+ * @defgroup XS_Request Apache::Request
+ * @ingroup XS
+ * @htmlinclude Request.html
+ */
+/**
+ * @defgroup XS_Cookie Apache::Cookie
+ * @ingroup XS
+ * @htmlinclude Cookie.html
*/
/**
@@ -369,6 +395,10 @@
*/
APREQ_DECLARE(apr_file_t *) apreq_brigade_spoolfile(apr_bucket_brigade *bb);
+
+
+APREQ_DECLARE(apr_bucket_brigade *)
+ apreq_copy_brigade(const apr_bucket_brigade *bb);
/** @} */
1.18 +8 -5 httpd-apreq-2/src/apreq_env.h
Index: apreq_env.h
===================================================================
RCS file: /home/cvs/httpd-apreq-2/src/apreq_env.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- apreq_env.h 27 Jun 2003 18:23:18 -0000 1.17
+++ apreq_env.h 30 Jun 2003 20:42:14 -0000 1.18
@@ -105,7 +105,11 @@
/**
* @file apreq_env.h
* @brief Logging and environment (module) declarations.
- *
+ */
+/**
+ * @defgroup ENV Environment declarations
+ * @ingroup LIBRARY
+ * @{
*/
#ifndef WIN32
@@ -118,6 +122,7 @@
#endif
#endif
+/** logger */
#define APREQ_DECLARE_LOG(f) APREQ_DECLARE_NONSTD(void)(f)(const char *file, \
int line, int level, apr_status_t status, \
void *env, const char *fmt, ...)
@@ -140,7 +145,7 @@
#define apreq_env_cookie(env) apreq_env_header_in(env, "Cookie")
#define apreq_env_cookie2(env) apreq_env_header_in(env, "Cookie2")
-
+/** header out */
APREQ_DECLARE(apr_status_t)apreq_env_header_out(void *env,
const char *name,
char *val);
@@ -148,13 +153,11 @@
#define apreq_env_set_cookie(e,s) apreq_env_header_out(e,"Set-Cookie",s)
#define apreq_env_set_cookie2(e,s) apreq_env_header_out(e,"Set-Cookie2",s)
-
-
APREQ_DECLARE(apr_status_t) apreq_env_read(void *env,
apr_read_type_e block,
apr_off_t bytes);
-
+/** @} */
#ifdef __cplusplus
}
#endif
1.29 +0 -18 httpd-apreq-2/src/apreq_params.c
Index: apreq_params.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/src/apreq_params.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- apreq_params.c 29 Jun 2003 03:41:17 -0000 1.28
+++ apreq_params.c 30 Jun 2003 20:42:14 -0000 1.29
@@ -95,24 +95,6 @@
return param;
}
-APREQ_DECLARE(apr_bucket_brigade *)
- apreq_param_brigade(const apreq_param_t *param)
-{
- apr_bucket_brigade *bb;
- apr_bucket *e;
- if (param->bb == NULL)
- return NULL;
-
- bb = apr_brigade_create(param->bb->p, param->bb->bucket_alloc);
- APR_BRIGADE_FOREACH(e,param->bb) {
- apr_bucket *c;
- apr_bucket_copy(e, &c);
- APR_BRIGADE_INSERT_TAIL(bb, c);
- }
- return bb;
-}
-
-
APREQ_DECLARE(apreq_request_t *) apreq_request(void *env, const char *qs)
{
1.24 +1 -4 httpd-apreq-2/src/apreq_params.h
Index: apreq_params.h
===================================================================
RCS file: /home/cvs/httpd-apreq-2/src/apreq_params.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- apreq_params.h 29 Jun 2003 03:41:17 -0000 1.23
+++ apreq_params.h 30 Jun 2003 20:42:14 -0000 1.24
@@ -94,10 +94,7 @@
#define apreq_param_value(p) ((p)->v.data)
#define apreq_param_info(p) ((p)->info)
#define apreq_param_status(p) ((p)->v.status)
-
-/** yields a copy of param->bb */
-APREQ_DECLARE(apr_bucket_brigade *)
- apreq_param_brigade(const apreq_param_t *param);
+#define apreq_param_brigade(p) ((p)->bb ? apreq_copy_brigade((p)->bb) : NULL)
/** creates a param from name/value information */
APREQ_DECLARE(apreq_param_t *) apreq_make_param(apr_pool_t *p,