You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2004/12/04 00:59:25 UTC
win32 bb->cleanup crashes are still there?
Randy, Steve, do you still have crashes with the following versions of
TestProtocol/echo_bbs2.pm test? Philippe no longer can reproduce it.
Please try the following 2 variations. Thanks!
If they don't fail is it possible that it was a problem in httpd and since
you use a newer version it just was solved in apr/httpd?
package TestProtocol::echo_bbs2;
# similar to TestProtocol::echo_bbs but here re-using one bucket
# brigade for input and output, using flatten to slurp all the data in
# the bucket brigade, and cleanup to get rid of the old buckets
use strict;
use warnings FATAL => 'all';
use Apache::Connection ();
use APR::Socket ();
use APR::Bucket ();
use APR::Brigade ();
use APR::Error ();
use Apache::Const -compile => qw(OK MODE_GETLINE);
use APR::Const -compile => qw(SUCCESS EOF SO_NONBLOCK);
sub handler {
my $c = shift;
# starting from Apache 2.0.49 several platforms require you to set
# the socket to a blocking IO mode
$c->client_socket->opt_set(APR::SO_NONBLOCK, 0);
my $bb_in = APR::Brigade->new($c->pool, $c->bucket_alloc);
my $last = 0;
while (1) {
my $bb_out = APR::Brigade->new($c->pool, $c->bucket_alloc);
my $rc = $c->input_filters->get_brigade($bb_in,
Apache::MODE_GETLINE);
last if $rc == APR::EOF;
die APR::Error::strerror($rc) unless $rc == APR::SUCCESS;
next unless $bb_in->flatten(my $data);
#warn "read: [$data]\n";
last if $data =~ /^[\r\n]+$/;
$bb_in->cleanup;
# transform data here
my $bucket = APR::Bucket->new(uc $data);
$bb_out->insert_tail($bucket);
$c->output_filters->fflush($bb_out);
# XXX: add DESTROY and remove explicit calls
$bb_out->destroy;
}
$bb_in->destroy;
Apache::OK;
}
1;
and one more:
package TestProtocol::echo_bbs2;
# similar to TestProtocol::echo_bbs but here re-using one bucket
# brigade for input and output, using flatten to slurp all the data in
# the bucket brigade, and cleanup to get rid of the old buckets
use strict;
use warnings FATAL => 'all';
use Apache::Connection ();
use APR::Socket ();
use APR::Bucket ();
use APR::Brigade ();
use APR::Error ();
use Apache::Const -compile => qw(OK MODE_GETLINE);
use APR::Const -compile => qw(SUCCESS EOF SO_NONBLOCK);
sub handler {
my $c = shift;
# starting from Apache 2.0.49 several platforms require you to set
# the socket to a blocking IO mode
$c->client_socket->opt_set(APR::SO_NONBLOCK, 0);
my $bb_in = APR::Brigade->new($c->pool, $c->bucket_alloc);
my $bb_out = APR::Brigade->new($c->pool, $c->bucket_alloc);
my $last = 0;
while (1) {
my $rc = $c->input_filters->get_brigade($bb_in,
Apache::MODE_GETLINE);
last if $rc == APR::EOF;
die APR::Error::strerror($rc) unless $rc == APR::SUCCESS;
next unless $bb_in->flatten(my $data);
#warn "read: [$data]\n";
last if $data =~ /^[\r\n]+$/;
# transform data here
my $bucket = APR::Bucket->new(uc $data);
$bb_out->insert_tail($bucket);
$c->output_filters->fflush($bb_out);
$bb_in->cleanup;
$bb_out->cleanup;
}
# XXX: add DESTROY and remove explicit calls
$bb_in->destroy;
$bb_out->destroy;
Apache::OK;
}
1;
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: win32 bb->cleanup crashes are still there?
Posted by Stas Bekman <st...@stason.org>.
Randy Kobes wrote:
> On Tue, 7 Dec 2004, Stas Bekman wrote:
>
>
>>Randy, please try this patch:
>
> [ ... ]
> Works great, Stas! And the patched echo_bbs2 tests (with the
> cleanup calls) all pass. Thanks.
Fantastic. Committed. Thank you guys.
I now can document the more efficient way to write the protocols handlers.
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: win32 bb->cleanup crashes are still there?
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Tue, 7 Dec 2004, Stas Bekman wrote:
> Randy, please try this patch:
[ ... ]
Works great, Stas! And the patched echo_bbs2 tests (with the
cleanup calls) all pass. Thanks.
--
best regards,
randy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: win32 bb->cleanup crashes are still there?
Posted by Stas Bekman <st...@stason.org>.
Randy, please try this patch:
Index: xs/maps/apr_functions.map
===================================================================
--- xs/maps/apr_functions.map (revision 110129)
+++ xs/maps/apr_functions.map (working copy)
@@ -94,7 +94,8 @@
!apr_brigade_write
!apr_brigade_puts
-apr_brigade_putc
- apr_brigade_cleanup
+~ apr_brigade_cleanup
+ mpxs_APR__Brigade_cleanup
~apr_brigade_flatten
~apr_brigade_pflatten
?apr_brigade_split_line
Index: xs/APR/Brigade/APR__Brigade.h
===================================================================
--- xs/APR/Brigade/APR__Brigade.h (revision 110129)
+++ xs/APR/Brigade/APR__Brigade.h (working copy)
@@ -14,6 +14,14 @@
*/
static MP_INLINE
+void mpxs_APR__Brigade_cleanup(apr_bucket_brigade *brigade)
+{
+ /* apr has a broken prototype (passing 'void *' instead of
+ * 'apr_bucket_brigade *', so use a wrapper here */
+ apr_brigade_cleanup(brigade);
+}
+
+static MP_INLINE
apr_bucket_brigade *mpxs_apr_brigade_create(pTHX_ SV *CLASS,
apr_pool_t *p,
apr_bucket_alloc_t *ba)
Index: xs/tables/current/ModPerl/FunctionTable.pm
===================================================================
--- xs/tables/current/ModPerl/FunctionTable.pm (revision 110129)
+++ xs/tables/current/ModPerl/FunctionTable.pm (working copy)
@@ -2,7 +2,7 @@
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# ! WARNING: generated by ModPerl::ParseSource/0.01
-# ! Mon Dec 6 09:38:51 2004
+# ! Tue Dec 7 13:02:32 2004
# ! do NOT edit, any changes will be lost !
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -5284,6 +5284,16 @@
},
{
'return_type' => 'void',
+ 'name' => 'mpxs_APR__Brigade_cleanup',
+ 'args' => [
+ {
+ 'type' => 'apr_bucket_brigade *',
+ 'name' => 'brigade'
+ }
+ ]
+ },
+ {
+ 'return_type' => 'void',
'name' => 'mpxs_APR__Brigade_concat',
'args' => [
{
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: win32 bb->cleanup crashes are still there?
Posted by Stas Bekman <st...@stason.org>.
Joe Schaefer wrote:
> Stas Bekman <st...@stason.org> writes:
>
> [...]
>
>
>>Hmm, the apr part does look wrong:
>>
>>APU_DECLARE(apr_status_t) apr_brigade_cleanup(void *data)
>>{
>> apr_bucket_brigade *b = data;
>> apr_bucket *e;
>>
>>shouldn't it be:
>>
>> apr_bucket_brigade *b = (apr_bucket_brigade *)data;
>
>
> In C, this cast makes no difference at all; and lots
> of C programmers would advise against it. The likely
> reason they use a (void *) argument in apr_brigade_cleanup
> instead of an (apr_bucket_brigade *) is because that
> function is also registered as a pool cleanup. I'm
> actually more suspicious of the APU_DECLARE vs
> APU_DECLARE_NONSTD part, because its possible (haven't
> checked tho) that Win32's calling coventions are different
> for the pool cleanup invocation verses a direct dll
> invocation.
>
> See if you can get wrowe's attention; he'll definitely
> know if I'm barking up the wrong tree or not.
Thanks Joe. I've posted a qestion to apr-dev. Seems like it's indeed
not-so-correct as Joe has replied.
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: win32 bb->cleanup crashes are still there?
Posted by Joe Schaefer <jo...@sunstarsys.com>.
Stas Bekman <st...@stason.org> writes:
[...]
> Hmm, the apr part does look wrong:
>
> APU_DECLARE(apr_status_t) apr_brigade_cleanup(void *data)
> {
> apr_bucket_brigade *b = data;
> apr_bucket *e;
>
> shouldn't it be:
>
> apr_bucket_brigade *b = (apr_bucket_brigade *)data;
In C, this cast makes no difference at all; and lots
of C programmers would advise against it. The likely
reason they use a (void *) argument in apr_brigade_cleanup
instead of an (apr_bucket_brigade *) is because that
function is also registered as a pool cleanup. I'm
actually more suspicious of the APU_DECLARE vs
APU_DECLARE_NONSTD part, because its possible (haven't
checked tho) that Win32's calling coventions are different
for the pool cleanup invocation verses a direct dll
invocation.
See if you can get wrowe's attention; he'll definitely
know if I'm barking up the wrong tree or not.
--
Joe Schaefer
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: win32 bb->cleanup crashes are still there?
Posted by Stas Bekman <st...@stason.org>.
Randy Kobes wrote:
[...]
> However, I tried changing WrapXS/APR/Brigade/Brigade.xs
> to read (in the declaration of apr_brigade_cleanup)
>
> apr_status_t
> apr_brigade_cleanup(data)
> APR::Brigade data
>
> With this, the above patched protocol/echo_bbs2 tests all
> pass.
Excellent. Sounds very logical to me.
> Given the declaration of apr_brigade_cleanup(void *data) in
> $APACHE2/include/apr_buckets.h, this change seems wrong -
> perhaps it indicates something's wrong in Win32?
Hmm, the apr part does look wrong:
APU_DECLARE(apr_status_t) apr_brigade_cleanup(void *data)
{
apr_bucket_brigade *b = data;
apr_bucket *e;
shouldn't it be:
apr_bucket_brigade *b = (apr_bucket_brigade *)data;
? let me run this through apr-dev.
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: win32 bb->cleanup crashes are still there?
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Sun, 5 Dec 2004, Stas Bekman wrote:
> Joe Schaefer wrote:
>
> Sorry, I've pasted the old examples without updating them. Here is a diff
> against the current test (just one for now):
[ ... ]
Just to confirm (the included patch didn't apply cleanly for
me), I used the following:
==========================================================
Index: t/protocol/TestProtocol/echo_bbs2.pm
===================================================================
--- t/protocol/TestProtocol/echo_bbs2.pm (revision 110089)
+++ t/protocol/TestProtocol/echo_bbs2.pm (working copy)
@@ -4,11 +4,6 @@
# brigade for input and output, using flatten to slurp all the data in
# the bucket brigade, and cleanup to get rid of the old buckets
-# XXX: ideally $bb->cleanup should be used here and no create/destroy
-# bb every time the loop is entered should be done. But it segfaults
-# on certain setups:
-# http://marc.theaimsgroup.com/?l=apache-modperl-dev&m=108967266419527&w=2
-
use strict;
use warnings FATAL => 'all';
@@ -28,10 +23,11 @@
# the socket to a blocking IO mode
$c->client_socket->opt_set(APR::SO_NONBLOCK, 0);
+ my $bb_in = APR::Brigade->new($c->pool, $c->bucket_alloc);
+ my $bb_out = APR::Brigade->new($c->pool, $c->bucket_alloc);
+
my $last = 0;
while (1) {
- my $bb_in = APR::Brigade->new($c->pool, $c->bucket_alloc);
- my $bb_out = APR::Brigade->new($c->pool, $c->bucket_alloc);
my $rc = $c->input_filters->get_brigade($bb_in,
Apache::MODE_GETLINE);
@@ -48,11 +44,14 @@
$c->output_filters->fflush($bb_out);
- # XXX: add DESTROY and remove explicit calls
- $bb_in->destroy;
- $bb_out->destroy;
+ $bb_in->cleanup;
+ $bb_out->cleanup;
}
+ # XXX: add DESTROY and remove explicit calls
+ $bb_in->destroy;
+ $bb_out->destroy;
+
Apache::OK;
}
=================================================================
With this, subtests 1 and 2 passed, but it failed on subtest
3 (it expected "WORLD", but received nothing, and there
was an access violation in libaprutil.lib). The troubling
call was in $bb_in->cleanup (or $bb_out->cleanup, if that
was moved before $bb_in->cleanup).
However, I tried changing WrapXS/APR/Brigade/Brigade.xs
to read (in the declaration of apr_brigade_cleanup)
apr_status_t
apr_brigade_cleanup(data)
APR::Brigade data
With this, the above patched protocol/echo_bbs2 tests all
pass. Given the declaration of apr_brigade_cleanup(void *data) in
$APACHE2/include/apr_buckets.h, this change seems wrong -
perhaps it indicates something's wrong in Win32?
--
best regards,
randy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: win32 bb->cleanup crashes are still there?
Posted by Stas Bekman <st...@stason.org>.
Joe Schaefer wrote:
Sorry, I've pasted the old examples without updating them. Here is a diff
against the current test (just one for now):
Index: t/protocol/TestProtocol/echo_bbs2.pm
===================================================================
--- t/protocol/TestProtocol/echo_bbs2.pm (revision 109678)
+++ t/protocol/TestProtocol/echo_bbs2.pm (working copy)
@@ -1,3 +1,4 @@
+
package TestProtocol::echo_bbs2;
# similar to TestProtocol::echo_bbs but here re-using one bucket
@@ -4,11 +5,6 @@
# brigade for input and output, using flatten to slurp all the data in
# the bucket brigade, and cleanup to get rid of the old buckets
-# XXX: ideally $bb->cleanup should be used here and no create/destroy
-# bb every time the loop is entered should be done. But it segfaults
-# on certain setups:
-# http://marc.theaimsgroup.com/?l=apache-modperl-dev&m=108967266419527&w=2
-
use strict;
use warnings FATAL => 'all';
@@ -28,11 +24,11 @@
# the socket to a blocking IO mode
$c->client_socket->opt_set(APR::SO_NONBLOCK, 0);
+ my $bb_in = APR::Brigade->new($c->pool, $c->bucket_alloc);
+ my $bb_out = APR::Brigade->new($c->pool, $c->bucket_alloc);
+
my $last = 0;
while (1) {
- my $bb_in = APR::Brigade->new($c->pool, $c->bucket_alloc);
- my $bb_out = APR::Brigade->new($c->pool, $c->bucket_alloc);
-
my $rc = $c->input_filters->get_brigade($bb_in,
Apache::MODE_GETLINE);
last if $rc == APR::EOF;
@@ -48,11 +44,14 @@
$c->output_filters->fflush($bb_out);
- # XXX: add DESTROY and remove explicit calls
- $bb_in->destroy;
- $bb_out->destroy;
+ $bb_in->cleanup;
+ $bb_out->cleanup;
}
+ # XXX: add DESTROY and remove explicit calls
+ $bb_in->destroy;
+ $bb_out->destroy;
+
Apache::OK;
}
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: win32 bb->cleanup crashes are still there?
Posted by Joe Schaefer <jo...@sunstarsys.com>.
Joe Schaefer <jo...@sunstarsys.com> writes:
> Randy Kobes <ra...@theoryx5.uwinnipeg.ca> writes:
>
>
> [...]
>
>>> # transform data here
>>> my $bucket = APR::Bucket->new(uc $data);
>>> $bb_out->insert_tail($bucket);
>
>> This one crashes for me, after subtest 1. it's an access
>> violation in libaprutil.lib - after calling it up in the
>> debugger, tests 2 and 3 run, but fail ("HELLO" and "WORLD"
>> are expected, but nothing is received).
>
> Err, unlesss something's changed recently, you're missing
> a bucket allocator argument:
>
> my $bucket = APR::Bucket->new(uc $data, $c->bucket_alloc);
Oops, looks like the args are reversed:
my $bucket = APR::Bucket->new($c->bucket_alloc, uc $data);
However, I'm still a bit confused why the XS didn't croak.
I must have missed something upthread in this discussion-
off to check now.
--
Joe Schaefer
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: win32 bb->cleanup crashes are still there?
Posted by Joe Schaefer <jo...@sunstarsys.com>.
Randy Kobes <ra...@theoryx5.uwinnipeg.ca> writes:
[...]
>> # transform data here
>> my $bucket = APR::Bucket->new(uc $data);
>> $bb_out->insert_tail($bucket);
> This one crashes for me, after subtest 1. it's an access
> violation in libaprutil.lib - after calling it up in the
> debugger, tests 2 and 3 run, but fail ("HELLO" and "WORLD"
> are expected, but nothing is received).
Err, unlesss something's changed recently, you're missing
a bucket allocator argument:
my $bucket = APR::Bucket->new(uc $data, $c->bucket_alloc);
Not sure why the mp2 glue didn't throw an error here.
--
Joe Schaefer
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: win32 bb->cleanup crashes are still there?
Posted by Stas Bekman <st...@stason.org>.
Randy Kobes wrote:
> Hi Stas,
> This one crashes for me, after subtest 1. it's an access
> violation in libaprutil.lib - after calling it up in the
> debugger, tests 2 and 3 run, but fail ("HELLO" and "WORLD"
> are expected, but nothing is received).
> I'll look at this further ...
[...]
> This one doesn't crash, but again tests 2 and 3 fail -
> "HELLO" and "WORLD" are expected, but nothing is received
> (ie, an empty string).
>
> This is with perl-5.8.4 and Apache/2.0.52, with today's
> svn mp2.
Thanks Randy!
I wonder what happens if someone writes this exact test in plain C. If it
breaks the same way, then we can hand it over to httpd-dev to resolve. If
it doesn't then we should see what gets on the way.
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: win32 bb->cleanup crashes are still there?
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Fri, 3 Dec 2004, Stas Bekman wrote:
> Randy, Steve, do you still have crashes with the following versions of
> TestProtocol/echo_bbs2.pm test? Philippe no longer can reproduce it.
>
> Please try the following 2 variations. Thanks!
>
> If they don't fail is it possible that it was a problem in httpd and since
> you use a newer version it just was solved in apr/httpd?
>
> package TestProtocol::echo_bbs2;
>
> # similar to TestProtocol::echo_bbs but here re-using one bucket
> # brigade for input and output, using flatten to slurp all the data in
> # the bucket brigade, and cleanup to get rid of the old buckets
>
> use strict;
> use warnings FATAL => 'all';
>
> use Apache::Connection ();
> use APR::Socket ();
> use APR::Bucket ();
> use APR::Brigade ();
> use APR::Error ();
>
> use Apache::Const -compile => qw(OK MODE_GETLINE);
> use APR::Const -compile => qw(SUCCESS EOF SO_NONBLOCK);
>
> sub handler {
> my $c = shift;
>
> # starting from Apache 2.0.49 several platforms require you to set
> # the socket to a blocking IO mode
> $c->client_socket->opt_set(APR::SO_NONBLOCK, 0);
>
> my $bb_in = APR::Brigade->new($c->pool, $c->bucket_alloc);
>
> my $last = 0;
> while (1) {
> my $bb_out = APR::Brigade->new($c->pool, $c->bucket_alloc);
>
> my $rc = $c->input_filters->get_brigade($bb_in,
> Apache::MODE_GETLINE);
> last if $rc == APR::EOF;
> die APR::Error::strerror($rc) unless $rc == APR::SUCCESS;
>
> next unless $bb_in->flatten(my $data);
> #warn "read: [$data]\n";
> last if $data =~ /^[\r\n]+$/;
>
> $bb_in->cleanup;
>
> # transform data here
> my $bucket = APR::Bucket->new(uc $data);
> $bb_out->insert_tail($bucket);
>
> $c->output_filters->fflush($bb_out);
>
> # XXX: add DESTROY and remove explicit calls
> $bb_out->destroy;
> }
>
> $bb_in->destroy;
> Apache::OK;
> }
>
> 1;
Hi Stas,
This one crashes for me, after subtest 1. it's an access
violation in libaprutil.lib - after calling it up in the
debugger, tests 2 and 3 run, but fail ("HELLO" and "WORLD"
are expected, but nothing is received).
I'll look at this further ...
> and one more:
>
> package TestProtocol::echo_bbs2;
>
> # similar to TestProtocol::echo_bbs but here re-using one bucket
> # brigade for input and output, using flatten to slurp all the data in
> # the bucket brigade, and cleanup to get rid of the old buckets
>
> use strict;
> use warnings FATAL => 'all';
>
> use Apache::Connection ();
> use APR::Socket ();
> use APR::Bucket ();
> use APR::Brigade ();
> use APR::Error ();
>
> use Apache::Const -compile => qw(OK MODE_GETLINE);
> use APR::Const -compile => qw(SUCCESS EOF SO_NONBLOCK);
>
> sub handler {
> my $c = shift;
>
> # starting from Apache 2.0.49 several platforms require you to set
> # the socket to a blocking IO mode
> $c->client_socket->opt_set(APR::SO_NONBLOCK, 0);
>
> my $bb_in = APR::Brigade->new($c->pool, $c->bucket_alloc);
> my $bb_out = APR::Brigade->new($c->pool, $c->bucket_alloc);
>
> my $last = 0;
> while (1) {
> my $rc = $c->input_filters->get_brigade($bb_in,
> Apache::MODE_GETLINE);
> last if $rc == APR::EOF;
> die APR::Error::strerror($rc) unless $rc == APR::SUCCESS;
>
> next unless $bb_in->flatten(my $data);
> #warn "read: [$data]\n";
> last if $data =~ /^[\r\n]+$/;
>
> # transform data here
> my $bucket = APR::Bucket->new(uc $data);
> $bb_out->insert_tail($bucket);
>
> $c->output_filters->fflush($bb_out);
>
> $bb_in->cleanup;
> $bb_out->cleanup;
> }
>
> # XXX: add DESTROY and remove explicit calls
> $bb_in->destroy;
> $bb_out->destroy;
>
> Apache::OK;
> }
>
> 1;
This one doesn't crash, but again tests 2 and 3 fail -
"HELLO" and "WORLD" are expected, but nothing is received
(ie, an empty string).
This is with perl-5.8.4 and Apache/2.0.52, with today's
svn mp2.
--
best regards,
randy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org