perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: PerlIO::APR: getting the memory pool
Date Wed, 05 Dec 2001 17:41:02 GMT
Doug MacEachern wrote:

> On Tue, 4 Dec 2001, Stas Bekman wrote:
> 
> 
>>I'm implementing PerlIO::APR (will be APR::IO in mod_perl)
>>
>>I need to get my hands on the memory pool. Currently I use the global 
>>pool via modperl_global_get_pconf(). which allows you to keep your code 
>>as a pure perl:
>>
>>open my $fh, ">:APR", $path or die "$!";
>>
>>Does calling modperl_global_get_pconf() make things slower? If it does, 
>>where do we stick $r/$s? something like this?
>>
> 
> you can use the modperl_sv2pool() function, see the
> ap_server_root_relative() wrapper for an example.
> 
> or just force an APR::Pool argument to be passed.  using the perl builtin
> open is just sugar, there should be an APR::File->open function that takes
> the same args as apr_file_open().

So should the open syntax be something like this:

my $fh = APR::File->open($r|$s, <apr_file_open args>) or die $!;

but I guess I don't understand something: why do we need to use 
APR::File->open? What's wrong with perl's open()? I've it working 
already.  If you don't use perl's open() do you also imply that we have 
to use $fh->close, $fh->seek and so on, using APR arguments? What's the 
point of having PerlIO layer at all?

I've basic tests working using a pure perl syntax and apr calls as its 
internals. Here is a snippet from the test:

         open my $fh, "<:APR", $file
             or die "Cannot open $file for reading: $!";

         open my $dup_fh, "<&:APR", $fh
             or die "Cannot dup $file for reading: $!";
         close $fh;

         my $received = <$dup_fh>;
         close $dup_fh;

so the only thing it misses is $r|$s, which can be:

   open my $fh, $r, ...

I'm not sure how to handle the best the forwarding of any errors from 
APR's side to Perl side. I don't think it's possible to convert APR's 
errno into Perl's errno, without a *lot* of hassle. what's the best way 
to go?

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message